From 5f530f759cc3e20bf2bb471bfdea9329e2b69d44 Mon Sep 17 00:00:00 2001 From: Giorgio Date: Wed, 8 Nov 2023 23:32:26 -1000 Subject: [PATCH 1/3] Adjust conditional renedering of elements --- .../src/components/events/EventReported.jsx | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/my-app/src/components/events/EventReported.jsx b/my-app/src/components/events/EventReported.jsx index 4032197..7836205 100644 --- a/my-app/src/components/events/EventReported.jsx +++ b/my-app/src/components/events/EventReported.jsx @@ -12,8 +12,8 @@ const EventRemoval = ({ event }) => {
-

Event ID: {event._id}

-
@@ -21,27 +21,30 @@ const EventRemoval = ({ event }) => {
- {/*
THIS IS WHERE MAP GOES
*/} - + {event.mapLat && event.mapLong ? ( + + ) : ( +
No coordinates found.
+ )}
-
+

Location

Longitude:

-

{event.mapLong}

+

{event.mapLong ?? "-"}

Latitude:

-

{event.mapLat}

+

{event.mapLat ?? "-"}

Island:

-

{event.closestIsland}

+

{event.closestIsland ?? "-"}

-
-

Contact Information

+
+

Contact Information

Email:

{event.publicContact.email}

@@ -65,18 +68,20 @@ const EventRemoval = ({ event }) => {

Information

    -
  • {event.publicType}
  • -
  • {event.publicLocationDesc}
  • -
  • {event.publicDebrisEnvDesc}
  • -
  • + {event.publicType && ( +
  • Type: {event.publicType}
  • + )} + {event.publicLocationDesc &&
  • {event.publicLocationDesc}
  • } + {event.publicDebrisEnvDesc &&
  • {event.publicDebrisEnvDesc}
  • } + {event.publicBiofoulingRating && (
  • Biofouling Rating - {event.publicBiofoulingRating} -
  • -
  • +
  • )} + {event.publicContainerFullness && (
  • Container Fullness - {event.publicContainerFullness} -
  • -
  • +
  • )} + {event.publicClaimBoat && (
  • Contact claims boat - {event.publicClaimBoat} -
  • + )}
From 701f6985aa26c104c430fdf089021b40139f023f Mon Sep 17 00:00:00 2001 From: Giorgio Date: Thu, 9 Nov 2023 00:06:52 -1000 Subject: [PATCH 2/3] Add edge case for undo at Removal and Storage page --- my-app/src/components/events/RemovalAndStorage.jsx | 2 +- my-app/src/components/events/common/UndoStepBtn.jsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/my-app/src/components/events/RemovalAndStorage.jsx b/my-app/src/components/events/RemovalAndStorage.jsx index 860b00b..40c8f70 100644 --- a/my-app/src/components/events/RemovalAndStorage.jsx +++ b/my-app/src/components/events/RemovalAndStorage.jsx @@ -138,7 +138,7 @@ const RemovalAndStorage = ({ event, userOrgId }) => { {STATUS.indexOf(event.status) <= 1 ? ( ) : ( - + )}
)} diff --git a/my-app/src/components/events/common/UndoStepBtn.jsx b/my-app/src/components/events/common/UndoStepBtn.jsx index 2091252..2ed0ca9 100644 --- a/my-app/src/components/events/common/UndoStepBtn.jsx +++ b/my-app/src/components/events/common/UndoStepBtn.jsx @@ -8,6 +8,7 @@ const UndoStepBtn = ({ eventId, prevStatus }) => { }, body: JSON.stringify({ status: prevStatus, + removalOrgId: null, }), }); if (res.ok) { From 0206ebc742bb8191029374c288d305bfe7f31083 Mon Sep 17 00:00:00 2001 From: Giorgio Date: Thu, 9 Nov 2023 00:46:14 -1000 Subject: [PATCH 3/3] Fix dispatch bug --- my-app/src/components/events/EventReported.jsx | 3 ++- .../components/events/event-reported/DispatchTeamBtn.jsx | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/my-app/src/components/events/EventReported.jsx b/my-app/src/components/events/EventReported.jsx index 7836205..e446c7f 100644 --- a/my-app/src/components/events/EventReported.jsx +++ b/my-app/src/components/events/EventReported.jsx @@ -3,6 +3,7 @@ import EventCollapse from "./common/EventCollapse"; import DispatchTeamBtn from "./event-reported/DispatchTeamBtn"; import DismissBtn from "./event-reported/DismissBtn"; import StaticMap from "../map/StaticLocationMap/StaticMap"; +import { prettyHstDate } from "@/utils/dateConverter"; const EventRemoval = ({ event }) => { const { data: session } = useSession(); @@ -14,7 +15,7 @@ const EventRemoval = ({ event }) => {

Event ID: {event._id}

diff --git a/my-app/src/components/events/event-reported/DispatchTeamBtn.jsx b/my-app/src/components/events/event-reported/DispatchTeamBtn.jsx index c102b7d..dd694fc 100644 --- a/my-app/src/components/events/event-reported/DispatchTeamBtn.jsx +++ b/my-app/src/components/events/event-reported/DispatchTeamBtn.jsx @@ -1,5 +1,9 @@ +import { STATUS } from "@/constants/constants"; + const DispatchTeamBtn = ({ userOrgId, eventId }) => { async function dispatchTeam() { + console.log("userOrgId", userOrgId); + console.log("eventId", eventId); try { const res = await fetch(`/api/mongo/event/id/${eventId}`, { method: "PUT", @@ -11,12 +15,11 @@ const DispatchTeamBtn = ({ userOrgId, eventId }) => { status: STATUS[1], }), }); - if (res.status === 200) { + if (res.ok) { console.log("Successfully dispatched team"); - } else { - throw new Error("Failed to dispatch team"); } } catch (err) { + console.log(err); console.log("Failed to dispatch team"); } }