Skip to content

Commit

Permalink
Temporarily saving changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iaAbdulghani committed Apr 4, 2024
1 parent 207025c commit 5240b68
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 6 deletions.
211 changes: 211 additions & 0 deletions frontend/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 frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@types/react-datepicker": "^6.0.2",
"@types/react-dom": "18.2.14",
"autoprefixer": "10.4.16",
"axios": "^1.6.8",
"eslint": "8.50.0",
"eslint-config-next": "13.5.3",
"next": "13.5.6",
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/app/form/Pet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ function Pet(props: PetProps) {
Type of Food
</div>
<TextInput value={props.foodType || ''} placeholder={''} onChange={props.setFoodType}/>






<div className='mt-5 '>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/app/form/Submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import TextInput from '../components/TextInput';
import DatePicker from '../components/DatePicker';

interface SubmitProps {

name: string
updated: boolean
selectedDate: Date
submitted: boolean
setName: Dispatch<SetStateAction<string>>;
setUpdated: Dispatch<SetStateAction<boolean>>;
setSelectedDate: Dispatch<SetStateAction<Date>>;
setFormPage: Dispatch<SetStateAction<string>>;
setSubmitted: Dispatch<SetStateAction<boolean>>;

}

Expand Down
46 changes: 44 additions & 2 deletions frontend/src/app/form/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Button from '../components/Button'
import Assessment from './Assessment'
import Submit from './Submit'
import Confirmation from './Confirmation'
import axios from 'axios'


export default function DeliveryReportForm() {
Expand Down Expand Up @@ -41,10 +42,51 @@ export default function DeliveryReportForm() {
const [name,setName]=useState("")
const [selectedDate,setSelectedDate] = useState(new Date())
const [updated, setUpdated]=useState(false)
const [submitted, setSubmitted] = useState(false)

const handleClick = async () => {
try {
const requestBody = {
firstName,
lastName,
address,
city,
zipCode,
phone,
instructions,
pets: [
{ name: petName1, foodType: foodType1, foodAmount: foodAmount1 },
{ name: petName2, foodType: foodType2, foodAmount: foodAmount2 },
{ name: petName3, foodType: foodType3, foodAmount: foodAmount3 }
],
lasting,
cup,
scale,
comments,
supplies,
needs,
updated,
selectedDate,
orderId: "123456789", // Replace with actual orderId
volunteerId: "volunteer123" // Replace with actual volunteerId

};

const response = await axios.post('/your-api-endpoint', requestBody);
console.log(response.data); // Handle response if needed
} catch (error) {
console.error('Error submitting form:', error);
}
};

useEffect(() => {
if(formPage=="Confirm"){
handleClick()
}
window.scrollTo(0, 0)
}, [formPage]);



return (
<div>
Expand All @@ -69,8 +111,8 @@ export default function DeliveryReportForm() {
{formPage=="Pet1" && <Pet petName={petName1} setPetName={setPetName1} foodType={foodType1} setFoodType={setFoodType1} foodAmount={foodAmount1} setFoodAmount={setFoodAmount1} setFormPage={setFormPage} num={1}/>}
{formPage=="Pet2" && <Pet petName={petName2} setPetName={setPetName2} foodType={foodType2} setFoodType={setFoodType2} foodAmount={foodAmount2} setFoodAmount={setFoodAmount2} setFormPage={setFormPage} num={2}/>}
{formPage=="Pet3" && <Pet petName={petName3} setPetName={setPetName3} foodType={foodType3} setFoodType={setFoodType3} foodAmount={foodAmount3} setFoodAmount={setFoodAmount3} setFormPage={setFormPage} num={3}/>}
{formPage === "Assessment" && <Assessment lasting={lasting} setLasting={setLasting} comments={comments} setComments={setComments} supplies={supplies} setSupplies={setSupplies} needs={needs} setNeeds={setNeeds} cup={cup} setCup={setCup} scale={scale} setScale={setScale} setFormPage={setFormPage} />}
{formPage=="Submit" && <Submit name={name} setName={setName} selectedDate={selectedDate} setSelectedDate={setSelectedDate} updated={updated} setUpdated={setUpdated} setFormPage={setFormPage}/>}
{formPage === "Assessment" && < Assessment lasting={lasting} setLasting={setLasting} comments={comments} setComments={setComments} supplies={supplies} setSupplies={setSupplies} needs={needs} setNeeds={setNeeds} cup={cup} setCup={setCup} scale={scale} setScale={setScale} setFormPage={setFormPage} />}
{formPage=="Submit" && < Submit name={name} setName={setName} selectedDate={selectedDate} setSelectedDate={setSelectedDate} updated={updated} setUpdated={setUpdated} setFormPage={setFormPage} submitted={submitted} setSubmitted={setSubmitted}/>}

</div>

Expand Down

0 comments on commit 5240b68

Please sign in to comment.