Skip to content
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
8 changes: 5 additions & 3 deletions apps/frontend/src/components/map/MapLegend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import circleSVG from '../../images/markers/circle.svg';
import diamondSVG from '../../images/markers/diamond.svg';
import starSVG from '../../images/markers/star.svg';
import pentagonSVG from '../../images/markers/pentagon.svg';
import { CheckboxOptionType, CheckboxValueType } from 'antd/es/checkbox/Group';
import { CheckboxOptionType } from 'antd/es/checkbox/Group';

type CheckboxValueType = string | number | boolean;

const Title = styled.h1`
font-size: 15px;
Expand Down Expand Up @@ -413,8 +415,8 @@ const MapLegend: React.FC<MapLegendProps> = ({
<LegendItem>
{icons && (
<StatusCheckbox
onChange={(values: CheckboxValueType[]) =>
handleStatusClick(values)
onChange={(values) =>
handleStatusClick(values as CheckboxValueType[])
}
value={selectedStatuses}
options={options}
Expand Down
75 changes: 62 additions & 13 deletions apps/frontend/src/components/volunteer/signup/SignUpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@chakra-ui/react';
import { Checkbox } from '@mui/material';
import CloseIcon from '@mui/icons-material/Close';
import React from 'react';
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import CircleIcon from '@mui/icons-material/Circle';
import CircleOutlinedIcon from '@mui/icons-material/CircleOutlined';
Expand Down Expand Up @@ -41,10 +41,7 @@ const personalInfoCheckboxesMap: CheckboxField[] = [

const personalInfoInputFieldsMap: InputFieldGroup[] = [
{
fields: [
{ label: 'First Name', width: '250px' },
{ label: 'Last Name', width: '350px' },
],
fields: [{ label: 'First Name', width: '250px'}, { label: 'Last Name', width: '350px' }],
type: 'double',
height: '40px',
width: '810px',
Expand Down Expand Up @@ -299,7 +296,22 @@ function PersonalInfo({ onSubmit }: PersonalInfoProps) {
);
}

function TermsAndConditions() {
function TermsAndConditions({
onCheckboxChange,
}: {
onCheckboxChange: (checked: boolean[]) => void;
}) {
const [checkedState, setCheckedState] = useState(
new Array(termsAndConditionsCheckboxesMap.length).fill(false),
);

const handleCheckboxChange = (index: number) => {
const updatedCheckedState = checkedState.map((item, i) =>
i === index ? !item : item,
);
setCheckedState(updatedCheckedState);
onCheckboxChange(updatedCheckedState); // notify parent component
};
return (
<Box className="terms-and-conditions-box">
<VStack
Expand All @@ -326,6 +338,8 @@ function TermsAndConditions() {
{field.label}
</Text>
<Checkbox
checked={checkedState[i]}
onChange={() => handleCheckboxChange(i)}
sx={{
color: '#808080',
'&.Mui-checked': { color: '#808080' },
Expand Down Expand Up @@ -355,17 +369,23 @@ interface Props {
}

export default function SignUpPage({ setShowSignUp }: Props) {
const [isSubmitted, setIsSubmitted] = React.useState(false);
const [isSubmitted, setIsSubmitted] = useState(false); // Step 1
const [isChecked, setIsChecked] = useState(
new Array(termsAndConditionsCheckboxesMap.length).fill(false),
);
const navigate = useNavigate();

const closeSignUp = () => {
setShowSignUp(false);
};

const handleSubmit = (values: any) => {
console.log(values);
setIsSubmitted(true);
navigate('/success');
const handleSubmit = () => {
if (isChecked.every(Boolean)) {
// check all checkboxes checked
// You can add form validation logic here if needed
setIsSubmitted(true);
navigate('/success'); // Step 2
}
};

return (
Expand Down Expand Up @@ -418,10 +438,39 @@ export default function SignUpPage({ setShowSignUp }: Props) {
Welcome, Volunteer!
</Text>
</Box>
<Box width="90%" mt="10px">
<PersonalInfo onSubmit={handleSubmit} />
<Box className="input-fields-main" width="90%" mt="10px">
{/* Comment these in and out to display the different pop up pages */}
{/* <PersonalInfo onSubmit={handleSubmit} /> */}
<TermsAndConditions onCheckboxChange={setIsChecked} />
</Box>

{/* Conditional rendering for the submit button */}
{!isSubmitted && (
<Button
size="large"
marginBottom="7%"
fontSize="20px"
onClick={handleSubmit}
bottom="10%"
left="50%"
transform="translateX(-50%)"
isDisabled={!isChecked.every(Boolean)}

Choose a reason for hiding this comment

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

Looks good 👍

>
Submit
</Button>
)}

{/* Success message */}
{isSubmitted && (
<Box>
<Text fontSize="24px" fontWeight={600}>
Thank you for submitting the form!
</Text>
You can add additional content for the success page
</Box>
)}
</Box>
</Box>
);
}

Loading
Loading