From fcd5bf23ba7c0d3e4078b232a9a5d4be32d7c565 Mon Sep 17 00:00:00 2001 From: OGreeni Date: Wed, 22 May 2024 14:15:22 -0400 Subject: [PATCH] add delivery location dropdown --- .idea/workspace.xml | 4 +-- frontend/src/app/client-form/Client.tsx | 36 ++++++++++++++++++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c3b7f20..180408c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,7 +6,7 @@ - + diff --git a/frontend/src/app/client-form/Client.tsx b/frontend/src/app/client-form/Client.tsx index b7b43c2..d8a3f68 100644 --- a/frontend/src/app/client-form/Client.tsx +++ b/frontend/src/app/client-form/Client.tsx @@ -1,5 +1,6 @@ 'use client'; +import { useUserContext } from '@/context/userContext'; import React, { Dispatch, SetStateAction, useEffect, useState } from 'react'; import { Button } from '@/components/core/Button'; import { TextInput } from '@/components/core/TextInput'; @@ -30,6 +31,23 @@ interface ClientProps { function Client(props: ClientProps) { const [isError, setIsError] = useState(false); + const [siteLocations, setSiteLocations] = useState([]); + + const { accessToken } = useUserContext(); + + useEffect(() => { + fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/site/all`, { + credentials: 'include', + headers: { + 'cca-auth-token': accessToken, + }, + }) + .then((res) => res.json()) + .then((sites) => { + setSiteLocations(sites); + props.setSite(sites[0].location); + }); + }, [accessToken, props]); return (
@@ -57,12 +75,18 @@ function Client(props: ClientProps) {
Delivery Site Location
- +
Street Address