Skip to content

Commit

Permalink
Merge pull request #97 from WildCodeSchool-2023-09/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
FredP21 authored Feb 7, 2024
2 parents 575c976 + 11b5360 commit 8ac214d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions backend/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ const seed = async () => {
await database.query("delete from reservation");
queries.push(
database.query(
"insert into reservation (parent_id,child_id, status, reservation_date_start, reservation_date_end, start_time, end_time, prices ) values ('1','1', 'waiting', '2024-01-24', '2024-02-09', '08:00:00', '18:00:00', '35.00')"
"insert into reservation (parent_id,child_id, status, reservation_date_start, reservation_date_end, start_time, end_time, prices ) values ('1','1', 'waiting', '2024-02-09', '2024-02-09', '08:00:00', '18:00:00', '35.00')"
)
);
queries.push(
database.query(
"insert into reservation (parent_id,child_id, status, reservation_date_start, reservation_date_end, start_time, end_time, prices ) values ('1','1', 'waiting', '2024-01-30', '2024-02-09', '09:00:00', '17:00:00', '28.00')"
"insert into reservation (parent_id,child_id, status, reservation_date_start, reservation_date_end, start_time, end_time, prices ) values ('1','1', 'waiting', '2024-02-09', '2024-02-09', '09:00:00', '17:00:00', '28.00')"
)
);

Expand Down
29 changes: 17 additions & 12 deletions frontend/src/components/structure/Calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Calendar() {
const handleEventClick = useCallback(async ({ event }) => {
setSelectedEvent(event);
const response = await fetch(
`http://localhost:3310/api/available-employees?date=${
`${import.meta.env.VITE_BACKEND_URL}/api/available-employees?date=${
event.start.toISOString().split("T")[0]
}&startTime=${event.start.toISOString().split("T")[1]}&endTime=${
event.end.toISOString().split("T")[1]
Expand Down Expand Up @@ -62,7 +62,9 @@ function Calendar() {
return;
}

const url = `http://localhost:3310/api/disponibilities/${selectedEvent.id}/decrement`;
const url = `${import.meta.env.VITE_BACKEND_URL}/api/disponibilities/${
selectedEvent.id
}/decrement`;

const updateResponse = await fetch(url, {
method: "PUT",
Expand All @@ -77,16 +79,19 @@ function Calendar() {
return;
}

const response = await fetch(`http://localhost:3310/api/assignments`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
reservationId: selectedEvent.id,
employeeId: selectedEmployee,
}),
});
const response = await fetch(
`${import.meta.env.VITE_BACKEND_URL}/api/assignments`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
reservationId: selectedEvent.id,
employeeId: selectedEmployee,
}),
}
);

if (!response.ok) {
console.error("Error:", response.status, response.statusText);
Expand Down

0 comments on commit 8ac214d

Please sign in to comment.