Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new car #9

Merged
merged 3 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"devDependencies": {
"@babel/core": "^7.23.5",
"@babel/eslint-parser": "^7.23.3",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/plugin-syntax-jsx": "^7.23.3",
"@babel/preset-react": "^7.23.3",
"eslint": "^7.32.0",
Expand Down
6 changes: 3 additions & 3 deletions src/components/Card/DisplayCartCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import styled from '@emotion/styled';
import { FaFacebook, FaTwitter, FaInstagram } from 'react-icons/fa';
import { Link } from 'react-router-dom';

const DisplayCartCard = ({ imageName, name, shortNote }) => (
const DisplayCartCard = ({ imgSrc, name, shortNote }) => (
<Container to="/u/dashboard/item-details">
<Image src={require(`../asset/${imageName}.jpg`).default} alt={name} />
<Image src={imgSrc} alt={name} />
<Content>
<Name>{name}</Name>
<Note>{shortNote}</Note>
Expand All @@ -26,7 +26,7 @@ const DisplayCartCard = ({ imageName, name, shortNote }) => (
);

DisplayCartCard.propTypes = {
imageName: PropTypes.string.isRequired,
imgSrc: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
shortNote: PropTypes.string.isRequired,
};
Expand Down
53 changes: 38 additions & 15 deletions src/components/Card/DisplayItemCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { FaCog, FaArrowRight, FaSyncAlt } from 'react-icons/fa';
import colorWheel from '../../components/asset/small_color_wheel.png';

const DisplayItemCard = ({ name, imgSrc, amount, description }) => {
const [rotation, setRotation] = useState(0);
Expand All @@ -14,7 +15,10 @@ const DisplayItemCard = ({ name, imgSrc, amount, description }) => {
<Image>
<Image1 src={imgSrc} alt={name} rotation={rotation} />
<RotateButton onClick={handleRotate}>
<FaSyncAlt />
<Rotate>
<FaSyncAlt />
Rotate vehicle
</Rotate>
</RotateButton>
</Image>
<Content>
Expand Down Expand Up @@ -44,7 +48,8 @@ const DisplayItemCard = ({ name, imgSrc, amount, description }) => {
5.9% APR Representative
</BoldText>
<ColorWheel>
DISCOVER MORE MODEL
DISCOVER MORE MODEL
<img src={colorWheel} alt='Color Wheel'/>
</ColorWheel>
<ConfigureButton>
<SettingIcon>
Expand All @@ -71,16 +76,16 @@ const Container = styled.div`
display: flex;
border-radius: 8px;
text-align: right;
// margin-right: -20rem;
// width: 40%;
overflow: hidden;
// overflow: hidden;
// box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
`;

const Image = styled.div`
border: 1px solid blue;
// border: 1px solid blue;
width: 40rem;
margin-right: 2rem;
margin-right: 5rem;
margin-top: 3rem;
postion: relative;
`;

Expand All @@ -94,41 +99,52 @@ const Image1 = styled.img`

const RotateButton = styled.button`
position: absolute;
bottom: 1rem;
right: 55rem;
background-color: #fff;
top: 40rem;
right: 50rem;
background-color: white;
border: none;
border-radius: 50%;
padding: 0.5rem;
// padding: 0.5rem;
cursor: pointer;
`;

const Rotate = styled.div`
// border: 1px solid blue;
color: green;
display: flex;
flex-direction: column;
align-items: center;
border-radius: 50%;
padding: 10px;
`;

const Content = styled.div`
padding: 4rem 2rem;
`;

const Name = styled.h2`
font-size: 1.5rem;
margin-bottom: 1rem;
margin-top: -4rem;
`;

const Description = styled.p`
font-size: 1rem;
margin-bottom: 1rem;
margin-bottom: 0.5rem;
`;

const Table = styled.table`
width: 100%;
margin-bottom: 2rem;
margin-top: 3rem;
margin-top: 2rem;
`;

const TableRow = styled.tr`
background-color: ${(props) => props.color};
`;

const TableData = styled.td`
padding: 1rem;
padding: 0.5rem;
text-align: center;
`;

Expand All @@ -140,7 +156,13 @@ const BoldText = styled.div`

const ColorWheel = styled.div`
/* Add styles for the color wheel */
margin-bottom: 5rem;
// border: 1px solid blue;
display: flex;
flex-direction: column;
// margin-bottom: 2rem;
margin-left: 9rem;
width: 15rem;
// height: 1rem;
`;

const ConfigureButton = styled.button`
Expand All @@ -149,7 +171,8 @@ const ConfigureButton = styled.button`
padding: 8px 16px;
display: flex;
align-items: center;
margin-left: 15rem;
margin-left: 10rem;
margin-top: 0.8rem;
border: none;
border-radius: 5rem;
cursor: pointer;
Expand Down
8 changes: 2 additions & 6 deletions src/components/Form/FormComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ FormComponent.propTypes = {
};

const StyledForm = styled(Form)`
border: 1px solid orange;
// border: 1px solid blue;
padding: 2rem;

&.flex {
display: flex;
Expand All @@ -59,11 +60,6 @@ const StyledForm = styled(Form)`
margin-left: 15%;
margin-right: 15%;
}

&.horizontalForm {
grid-template-columns: 5fr 1fr;
align-items: last baseline;
}
`;

export default FormComponent;
3 changes: 2 additions & 1 deletion src/components/Form/FormField.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const StyledDatePicker = styled(DatePicker)`

export const InputWrapper = styled.div`
width: 100%;
margin-bottom: .5rem;
`;

export const InputLabel = styled.label`
Expand Down Expand Up @@ -208,7 +209,7 @@ const Select = styled.select`
export const Input = styled.input`
border: 2px solid white;
border-radius: 4px;
padding: 0.5rem;
padding: .5rem;
text-align: left;
font-weight: bolder;
color: black;
Expand Down
Binary file added src/components/asset/Linear_RGB_color_wheel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/asset/small_color_wheel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 4 additions & 7 deletions src/layout/UsersDashboard/UsersDashboardLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,14 @@ const UsersDashboardLayout = () => {
export default UsersDashboardLayout;

const Container = styled.div`
display: grid;
grid-template-columns: 18rem auto;
height: 100vh;
width: 100vw;
overflow: scroll;
background-color: white;
// border: 1px solid blue;
`;

const Section = styled.section`
/* border: 2px solid yellow; */
width: 100%;
// border: 2px solid blue;
width: 80%;
margin-left: 17rem;
`;

const MainContent = styled.main`
Expand Down
4 changes: 3 additions & 1 deletion src/layout/UsersDashboard/sideNav/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const Container = styled.nav`
background-color: white;
flex-direction: column;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
position: fixed;
height: 100%;
gap: 3.8rem;
top: 0;

Expand All @@ -48,6 +50,6 @@ const NavbtnSection = styled.section`
`;

const LogoutBtn = styled.div`
margin-top: auto;
margin-top: 8rem;
`;

17 changes: 17 additions & 0 deletions src/models/car.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as Yup from 'yup';

export const CarSchema = Yup.object().shape({
name: Yup.string().required('Car Name is required'),
description: Yup.string().required('Car description is required'),
pricePerHr: Yup.string().required('Price is required'),
sitting_capacity: Yup.number().required('State sitting capacity'),
rental_duration: Yup.number().required('State the duration'),
});

export const carInitialValues = {
name: '',
description: '',
pricePerHr: '',
sitting_capacity: '',
rental_duration: '',
};
5 changes: 0 additions & 5 deletions src/pages/LandingPage/AddNewCar/AddNewCar.js

This file was deleted.

40 changes: 40 additions & 0 deletions src/pages/UserDashboard/AddNewCar/AddNewCar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import styled from '@emotion/styled';
import AddNewCarForm from './AddNewCarForm';

const AddNewCar = () => {
return(
<Container>
<SignUpContent>
<Title>CREATE A VEHICLE</Title>
<AddNewCarForm />
</SignUpContent>
</Container>
)
}

export default AddNewCar;

const Container = styled.div`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
// min-height: 100vh;
// height: fit-content;
`;

const SignUpContent = styled.div`
margin-top: -.5rem;
padding: .2rem;
// // border: 1px solid blue;
width: 600px;
align-items: center;
background-color: white;
box-shadow: 0 7px 8px rgba(0, 0, 0, 0.1);
`;

const Title = styled.p`
font-size: 1rem;
`;

36 changes: 36 additions & 0 deletions src/pages/UserDashboard/AddNewCar/AddNewCarForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { useDispatch } from 'react-redux';
import FormComponent from '../../../components/Form/FormComponent';
import { CarSchema, carInitialValues } from '../../../models/car.model';
import FormSubmitButton from '../../../components/Button/FormSubmitButton';
import { TextAreaInputField, TextInputField } from '../../../components/Form/FormField';


const AddNewCarForm = () => {
const dispatch = useDispatch();

const handleSubmit = (values) => {
console.log(values);
dispatch(userSignUp(values));
};

return (
<FormComponent
initialValues={carInitialValues}
schema={CarSchema}
onSubmit={handleSubmit}
className=""
>
<TextInputField label="Car Name" name="name" placeholder="Car Name" />
<TextAreaInputField label="Description" name="description" placeholder="Description" />
<TextInputField label="Price/hr" name="pricePrHr" placeholder="Price"/>
<TextInputField label="Sitting Capacity" name="sitting_capacity" placeholder="Sitting Capacity" />
<TextInputField label="Rental Duration" name="rental_duration" placeholder="Duration" />
<FormSubmitButton type="submit" className="sign-up-submit">
Create
</FormSubmitButton>
</FormComponent>
Copy link
Owner

@tan12082001 tan12082001 Dec 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form looks good! But can you also add another form text field for image input so that a user can provide the link for the car they are going to create? Update the CarSchema accordingly. 👍☺️

);
};

export default AddNewCarForm;
Loading