Skip to content
Snippets Groups Projects
Commit e7f71f6a authored by Tonge, Marcus A (UG - Comp Sci & Elec Eng)'s avatar Tonge, Marcus A (UG - Comp Sci & Elec Eng)
Browse files

Added postcode to create on admin page

parent a53d9e08
No related branches found
No related tags found
No related merge requests found
......@@ -78,10 +78,25 @@ const AdminPageView = () => {
// Fetch locations from the server
const loadLocations = async () => {
const response = await fetch("/api/locations");
const data = await response.json();
setLocations(data);
try {
const baseUrl = process.env.REACT_APP_LOCATION_SERVICE_ENDPOINT;
const response = await fetch(`${baseUrl}/location/parking-locations/all`, {
method: "GET",
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});
const data = await response.json();
setLocations(data);
}
catch (error) {
toast({
title: error.message ?? "Failed to add location.",
status: "error",
duration: 2000,
isClosable: true,
});
}
};
// Add a new location
......@@ -276,6 +291,16 @@ const AdminPageView = () => {
}
/>
</FormControl>
<FormControl id="city">
<FormLabel>City</FormLabel>
<Input
type="text"
value={newLocation.city}
onChange={(e) =>
setNewLocation({ ...newLocation, city: e.target.value })
}
/>
</FormControl>
<FormControl id="street_address">
<FormLabel>Street Address</FormLabel>
<Input
......@@ -286,13 +311,13 @@ const AdminPageView = () => {
}
/>
</FormControl>
<FormControl id="city">
<FormLabel>City</FormLabel>
<FormControl id="postcode">
<FormLabel>Postcode</FormLabel>
<Input
type="text"
value={newLocation.city}
value={newLocation.postcode}
onChange={(e) =>
setNewLocation({ ...newLocation, city: e.target.value })
setNewLocation({ ...newLocation, postcode: e.target.value })
}
/>
</FormControl>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment