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

further enhance trip creation sequence #16

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1,628 changes: 1,610 additions & 18 deletions client/package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.9",
"@mui/material": "^5.14.10",
"@mui/material": "^5.14.13",
"@mui/styles": "^5.14.10",
"@mui/x-date-pickers": "^6.16.2",
"@types/node": "20.4.10",
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.14",
"date-fns": "^2.30.0",
"eslint": "8.47.0",
"eslint-config-next": "13.4.13",
"next": "13.4.13",
"postcss": "8.4.27",
"react": "18.2.0",
"react-date-range": "^1.4.0",
"react-dom": "18.2.0",
"styled-components": "^6.1.0",
"tailwindcss": "3.3.3",
"typescript": "5.1.6"
}
Expand Down
Binary file added client/public/NewTripPlaceholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion client/public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion client/public/vercel.svg

This file was deleted.

341 changes: 341 additions & 0 deletions client/src/app/(components)/(forms)/MultiPageForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,341 @@
"use client";

import React, { useState, useEffect, ReactNode, ChangeEvent } from "react";
import {
Stepper,
Step,
Button,
IconButton,
Paper,
LinearProgress,
Typography,
TextField,
Grid,
} from "@mui/material";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import CloseIcon from "@mui/icons-material/Close";
import { DateRange } from "react-date-range";
import { addDays } from "date-fns";
import "react-date-range/dist/styles.css";
import "react-date-range/dist/theme/default.css";

import Image from "next/image";

const steps = ["Step 1", "Step 2", "Step 3", "Step 4"];

interface StepPageProps {
children: ReactNode;
buttonClick: () => void;
isDisable: Boolean;
}

const maxCharacters: number = 24;

const styles = {
resultListStyle: {
borderBottom: "2px dashed grey",
padding: "15px 0px",
},
resultKeyStyle: {
color: "grey",
fontSize: "1 rem",
display: "flex",
justifyContent: "flex-start",
},
resultValueStyle: {
fontSize: "0.95 rem",
display: "flex",
justifyContent: "flex-end",
},
};

const StepPage: React.FC<StepPageProps> = ({ children, buttonClick, isDisable = true}) => {
return (
<div
style={{
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
height: "100%",
width: "100%",
marginTop: "30px",
}}
>
<div style={{ width: "90%" }}>{children}</div>
<div
style={{
flex: 1,
display: "flex",
flexDirection: "column",
justifyContent: "flex-end",
alignItems: "center",
width: "100%",
marginBottom: "20%",
}}
>
<Button
onClick={buttonClick}
disabled={isDisable}
style={{
backgroundColor: isDisable ? "grey" : "#fb3f04",
color: "white",
borderRadius: "25px",
width: "90%",
padding: "10px 0px",
}}
>
Sounds great
</Button>
</div>
</div>
);
};

const MultiPageForm: React.FC = () => {
const [activeStep, setActiveStep] = useState(0);
const [progress, setProgress] = useState(25);
const [startDate, setStartDate] = useState(new Date());
const [endDate, setEndDate] = useState(addDays(new Date(), 7));
const [title, setTitle] = useState("");
const [destination, setDestination] = useState("");

useEffect(() => {
setProgress(((activeStep + 1) / steps.length) * 100);
}, [activeStep]);

const handleTitle = (event: ChangeEvent<HTMLInputElement>) => {
const newValue = event.target.value;
if (newValue.length <= maxCharacters) {
setTitle(newValue);
}
};

const handleDateChange = (ranges: {
selection: { startDate: Date; endDate: Date };
}) => {
const { selection } = ranges;
setStartDate(selection.startDate);
setEndDate(selection.endDate);
};

const handleDestination = (event: ChangeEvent<HTMLInputElement>) => {
const newValue = event.target.value;
setDestination(newValue);
};

const handleNext = () => {
setActiveStep(activeStep + 1);
};

const handleBack = () => {
setActiveStep(activeStep - 1);
};

return (
<div
style={{
display: "flex",
flexDirection: "column",
height: "100vh",
}}
>
<Stepper
activeStep={activeStep}
alternativeLabel
style={{
backgroundColor: "transparent",
display: "flex",
alignItems: "center",
justifyContent: "space-between",
}}
>
<IconButton disabled={activeStep === 0} onClick={handleBack}>
<ArrowBackIcon />
</IconButton>
<Typography style={{ fontSize: "1rem" }}>Add a travel note</Typography>
<IconButton onClick={() => {}}>
<CloseIcon />
</IconButton>
</Stepper>
<LinearProgress
variant="determinate"
value={progress}
color="success"
style={{
backgroundColor: "white",
height: "5px",
borderRadius: "10px",
width: "90%",
margin: "0px 20px",
marginTop: "20px",
marginBottom: "0px",
}}
/>
<div
style={{
flex: 1,
display: "flex",
justifyContent: "center",
}}
>
{activeStep === 0 && (
<StepPage buttonClick={handleNext}>
<div
style={{
fontSize: "1.7rem",
fontWeight: "bold",
width: "80%",
lineHeight: 1.4,
}}
>
Where are you going for the trip?
</div>
<TextField
variant="standard"
fullWidth
placeholder="Please choose a travel destination"
style={{
marginTop: "25px",
}}
value={destination}
onChange={handleDestination}
/>
</StepPage>
)}
{activeStep === 1 && (
<StepPage buttonClick={handleNext}>
<div
style={{
fontSize: "1.7rem",
fontWeight: "bold",
width: "80%",
}}
>
When shall we go?
</div>
<div style={{ marginTop: "30px" }}>
<DateRange
ranges={[
{
startDate: startDate,
endDate: endDate,
key: "selection",
},
]}
onChange={handleDateChange}
editableDateInputs={true}
moveRangeOnFirstSelection={false}
showDateDisplay={false}
// rangeColors={["yellow", "#3ecf8e", "#fed14c"]}
/>
</div>
</StepPage>
)}
{activeStep === 2 && (
<StepPage buttonClick={handleNext}>
<div
style={{
fontSize: "1.7rem",
fontWeight: "bold",
}}
>
What is the Trip's name?
</div>
<div>
<TextField
variant="standard"
fullWidth
placeholder="Propose a travel title"
style={{
marginTop: "20px",
}}
value={title}
onChange={handleTitle}
/>
<div
style={{
color: "grey",
marginTop: "5px",
fontSize: "0.8rem",
}}
>
{title.length} / {maxCharacters} Characters
</div>
</div>
</StepPage>
)}
{activeStep === 3 && (
<StepPage buttonClick={() => {}}>
<div
style={{
display: "flex",
flexDirection: "column",
textAlign: "center",
alignItems: "center",
}}
>
<div
style={{ fontSize: "2rem", fontWeight: "bold", width: "80%" }}
>
A new travel note has been created
</div>
<div style={{ marginTop: "20px", marginBottom: "30px" }}>
<Image
src="/NewTripPlaceholder.png"
alt="My Image"
width={200}
height={200}
/>
</div>

<Grid container>
{/* Trip Title */}
<Grid container style={styles.resultListStyle}>
<Grid item xs={6} style={styles.resultKeyStyle}>
Note name
</Grid>
<Grid item xs={6} style={styles.resultValueStyle}>
{title}
</Grid>
</Grid>

{/* Trip Destination */}
<Grid container style={styles.resultListStyle}>
<Grid item xs={6} style={styles.resultKeyStyle}>
Travel Destination
</Grid>
<Grid item xs={6} style={styles.resultValueStyle}>
{destination}
</Grid>
</Grid>

{/* Trip Start Date */}
<Grid container style={styles.resultListStyle}>
<Grid item xs={6} style={styles.resultKeyStyle}>
Start Date
</Grid>
<Grid item xs={6} style={styles.resultValueStyle}>
{startDate?.toDateString()}
</Grid>
</Grid>

{/* Trip End Date */}
<Grid container style={styles.resultListStyle}>
<Grid item xs={6} style={styles.resultKeyStyle}>
End Date
</Grid>
<Grid item xs={6} style={styles.resultValueStyle}>
{endDate?.toDateString()}
</Grid>
</Grid>
</Grid>
</div>
</StepPage>
)}
</div>
</div>
);
};

export default MultiPageForm;
3 changes: 2 additions & 1 deletion client/src/app/(components)/(forms)/TripCreation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const TripCreation = () => {
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
color: 'black',
}}
>
<Box sx={{ fontSize: "1rem", marginTop: "20px" }}>Add a travel note</Box>
Expand All @@ -33,7 +34,7 @@ const TripCreation = () => {

<Button
style={{
marginTop: "20%",
marginTop: "50%",
backgroundColor: "#fb3f04",
color: "white",
borderRadius: "25px",
Expand Down
Loading