Skip to content

Commit

Permalink
Merge pull request #7 from CarmenvStaden/main
Browse files Browse the repository at this point in the history
Page2-5 and universal inputs
  • Loading branch information
MechLizard authored Nov 14, 2024
2 parents 49ab745 + cf4ca50 commit 207e715
Show file tree
Hide file tree
Showing 7 changed files with 689 additions and 31 deletions.
8 changes: 8 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import SignIn from './components/SignIn/SignIn';
import Register from './components/Register/Register';
import Home from './components/Home/Home';
import Page1 from './components/Page1/Page1';
import Page2 from './components/Page2/Page2';
import Page3 from './components/Page3/Page3';
import Page4 from './components/Page4/Page4';
import Page5 from './components/Page5/Page5';

function App() {
return (
Expand All @@ -13,6 +17,10 @@ function App() {
<Route path="/register" element={<Register />} />
<Route path="/home" element={<Home />} />
<Route path="/page1" element={<Page1 />} />
<Route path="/page2" element={<Page2 />} />
<Route path="/page3" element={<Page3 />} />
<Route path="/page4" element={<Page4 />} />
<Route path="/page5" element={<Page5 />} />
</Routes>
</Router>
);
Expand Down
45 changes: 40 additions & 5 deletions src/components/GlobalStyles/Elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,33 @@ export const PageContainer = styled.div`
min-height: 100vh;
`;

// Form Container
// Form Container (Aligned Horizontally)
export const FormContainer = styled.form`
display: flex;
flex-direction: column;
gap: 20px;
flex-direction: row; /* Align elements horizontally */
gap: 20px; /* Space between elements */
margin: 20px 0;
align-items: center;
align-items: center; /* Center align the elements vertically */
justify-content: center; /* Center align the elements horizontally */
flex-wrap: wrap; /* Allow wrapping on smaller screens */
`;

// Form Container (Aligned Vertically)
export const FormContainer2 = styled.form`
display: flex;
flex-direction: column; /* Align elements horizontally */
gap: 20px; /* Space between elements */
margin: 20px 0;
align-items: center; /* Center align the elements vertically */
justify-content: center; /* Center align the elements horizontally */
flex-wrap: wrap; /* Allow wrapping on smaller screens */
`;


// Select (Drop-Down Menu)
export const Select = styled.select`
padding: 10px;
width: 200px;
width: 150px;
border-radius: 4px;
border: 1px solid ${({ theme }) => theme.colors.primary};
font-size: 16px;
Expand All @@ -269,4 +283,25 @@ export const TabImageAlt = styled.img`
height: 80%; /* Set a fixed height */
border-radius: 4px;
justify-content: center;
`;

export const Input = styled.input`
width: 150px;
padding: 10px 15px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
color: #333;
background-color: #f9f9f9;
outline: none;
&:focus {
border-color: #007bff;
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}
&::placeholder {
color: #999;
}
`;
111 changes: 85 additions & 26 deletions src/components/Page1/Page1.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,27 @@ import {
PageTitle,
PageDescription,
FormContainer,
FormContainer2,
Select,
SubmitButton,
TabImageAlt
TabImageAlt,
Input
} from '../GlobalStyles/Elements';

function Page1() {
const [selection, setSelection] = useState({
option1: '',
option2: '',
option3: ''
country: '',
categoryId: '',
startDate: '14-11-17',
endDate: '14-06-18',
tag: ''
});

// Sample options (replace with your actual values)
const countries = ['USA', 'Canada', 'UK', 'Australia'];
const categories = ['1', '2', '10', '15', '17', '20', '22']; // Example category IDs

// Handle input changes
const handleChange = (e) => {
const { name, value } = e.target;
setSelection((prev) => ({
Expand All @@ -26,9 +35,31 @@ function Page1() {
}));
};

// Handle form submission
const handleSubmit = (e) => {
e.preventDefault();
alert(`Selected options: ${selection.option1}, ${selection.option2}, ${selection.option3}`);

// Format date inputs if needed
const formattedStartDate = formatToOracleDate(selection.startDate);
const formattedEndDate = formatToOracleDate(selection.endDate);

// Construct query parameters
const query = {
country: selection.country || '%',
categoryId: selection.categoryId || null,
startDate: formattedStartDate,
endDate: formattedEndDate,
tag: selection.tag || '%'
};

alert(`Query Parameters: ${JSON.stringify(query)}`);
// You can now use `query` to make a request to your Oracle database.
};

// Helper function to format date to 'DD-MM-YY'
const formatToOracleDate = (date) => {
const [year, month, day] = date.split('-');
return `${day}-${month}-${year.slice(2)}`; // Convert 'YYYY-MM-DD' to 'DD-MM-YY'
};

return (
Expand All @@ -40,38 +71,66 @@ function Page1() {

{/* Page Title and Description */}
<PageTitle>Page 1</PageTitle>
<PageDescription>This page allows you to make selections from the drop-down menus.</PageDescription>
<PageDescription>Select your search criteria for trending videos.</PageDescription>

{/* Form Section */}
<FormContainer onSubmit={handleSubmit}>
<Select name="option1" value={selection.option1} onChange={handleChange}>
<option value="">Select Option 1</option>
<option value="Option 1A">Option 1A</option>
<option value="Option 1B">Option 1B</option>
<option value="Option 1C">Option 1C</option>
{/* Country Dropdown */}
<Select name="country" value={selection.country} onChange={handleChange}>
<option value="">Select Country</option>
{countries.map((country) => (
<option key={country} value={country}>
{country}
</option>
))}
</Select>

<Select name="option2" value={selection.option2} onChange={handleChange}>
<option value="">Select Option 2</option>
<option value="Option 2A">Option 2A</option>
<option value="Option 2B">Option 2B</option>
<option value="Option 2C">Option 2C</option>
{/* Category ID Dropdown */}
<Select name="categoryId" value={selection.categoryId} onChange={handleChange}>
<option value="">Select Category ID</option>
{categories.map((id) => (
<option key={id} value={id}>
{id}
</option>
))}
</Select>

<Select name="option3" value={selection.option3} onChange={handleChange}>
<option value="">Select Option 3</option>
<option value="Option 3A">Option 3A</option>
<option value="Option 3B">Option 3B</option>
<option value="Option 3C">Option 3C</option>
</Select>
{/* Start Date Input */}
<Input
type="date"
name="startDate"
value={selection.startDate}
onChange={handleChange}
placeholder="Start Date"
/>

{/* End Date Input */}
<Input
type="date"
name="endDate"
value={selection.endDate}
onChange={handleChange}
placeholder="End Date"
/>

{/* Tag Input with Autocomplete (Basic Implementation) */}
<Input
type="text"
name="tag"
value={selection.tag}
onChange={handleChange}
placeholder="Enter a tag (e.g., 'comedy', 'news')"
/>

<SubmitButton type="submit">Submit</SubmitButton>

{/* Image Section */}
<TabImageAlt src="/images/tab1.jpg" alt="Tab 1 Image" />

</FormContainer>
<FormContainer2>
{/* Submit Button */}
<SubmitButton type="submit">Submit</SubmitButton>

{/* Image Section */}
<TabImageAlt src="/images/tab1.jpg" alt="Tab 1 Image" />
</FormContainer2>

</PageContainer>
);
Expand Down
139 changes: 139 additions & 0 deletions src/components/Page2/Page2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import React, { useState } from 'react';
import {
PageContainer,
Header,
Icon,
PageTitle,
PageDescription,
FormContainer,
FormContainer2,
Select,
SubmitButton,
TabImageAlt,
Input
} from '../GlobalStyles/Elements';

function Page2() {
const [selection, setSelection] = useState({
country: '',
categoryId: '',
startDate: '14-11-17',
endDate: '14-06-18',
tag: ''
});

// Sample options (replace with your actual values)
const countries = ['USA', 'Canada', 'UK', 'Australia'];
const categories = ['1', '2', '10', '15', '17', '20', '22']; // Example category IDs

// Handle input changes
const handleChange = (e) => {
const { name, value } = e.target;
setSelection((prev) => ({
...prev,
[name]: value
}));
};

// Handle form submission
const handleSubmit = (e) => {
e.preventDefault();

// Format date inputs if needed
const formattedStartDate = formatToOracleDate(selection.startDate);
const formattedEndDate = formatToOracleDate(selection.endDate);

// Construct query parameters
const query = {
country: selection.country || '%',
categoryId: selection.categoryId || null,
startDate: formattedStartDate,
endDate: formattedEndDate,
tag: selection.tag || '%'
};

alert(`Query Parameters: ${JSON.stringify(query)}`);
// You can now use `query` to make a request to your Oracle database.
};

// Helper function to format date to 'DD-MM-YY'
const formatToOracleDate = (date) => {
const [year, month, day] = date.split('-');
return `${day}-${month}-${year.slice(2)}`; // Convert 'YYYY-MM-DD' to 'DD-MM-YY'
};

return (
<PageContainer>
{/* Logo and Navigation */}
<Header>
<Icon to="/home">YouTrend</Icon>
</Header>

{/* Page Title and Description */}
<PageTitle>Page 2</PageTitle>
<PageDescription>Select your search criteria for trending videos.</PageDescription>

{/* Form Section */}
<FormContainer onSubmit={handleSubmit}>
{/* Country Dropdown */}
<Select name="country" value={selection.country} onChange={handleChange}>
<option value="">Select Country</option>
{countries.map((country) => (
<option key={country} value={country}>
{country}
</option>
))}
</Select>

{/* Category ID Dropdown */}
<Select name="categoryId" value={selection.categoryId} onChange={handleChange}>
<option value="">Select Category ID</option>
{categories.map((id) => (
<option key={id} value={id}>
{id}
</option>
))}
</Select>

{/* Start Date Input */}
<Input
type="date"
name="startDate"
value={selection.startDate}
onChange={handleChange}
placeholder="Start Date"
/>

{/* End Date Input */}
<Input
type="date"
name="endDate"
value={selection.endDate}
onChange={handleChange}
placeholder="End Date"
/>

{/* Tag Input with Autocomplete (Basic Implementation) */}
<Input
type="text"
name="tag"
value={selection.tag}
onChange={handleChange}
placeholder="Enter a tag (e.g., 'comedy', 'news')"
/>


</FormContainer>
<FormContainer2>
{/* Submit Button */}
<SubmitButton type="submit">Submit</SubmitButton>

{/* Image Section */}
<TabImageAlt src="/images/tab2.jpg" alt="Tab 2 Image" />
</FormContainer2>

</PageContainer>
);
}

export default Page2;
Loading

0 comments on commit 207e715

Please sign in to comment.