Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
robertgodfrey committed Nov 9, 2023
2 parents 63518d1 + 0206ebc commit fe58919
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
46 changes: 26 additions & 20 deletions my-app/src/components/events/EventReported.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -12,36 +13,39 @@ const EventRemoval = ({ event }) => {
<div className="p-3 bg-base-100 rounded-xl">
<header>
<div className="flex flex-col md:flex-row justify-between">
<h3 className="font-bold md:text-2xl">Event ID: {event._id}</h3>
<time className="font-bold md:text-2xl">
Date Reported: {event.reportedDate.toLocaleString("en-US")}
<h3 className="font-bold md:text-xl">Event ID: {event._id}</h3>
<time className="font-bold md:text-xl">
Date Reported: {prettyHstDate(event.reportedDate)}
</time>
</div>
</header>
<section className="py-3">
<div className="flex flex-col md:flex-row gap-x-12">
<div className="w-full md:w-1/2 h-96 bg-primary-content flex justify-center items-center rounded-md my-3">
{/* <div className="text-base-100">THIS IS WHERE MAP GOES</div> */}
<StaticMap latitude={event.mapLat} longitude={event.mapLong} />
{event.mapLat && event.mapLong ? (
<StaticMap latitude={event.mapLat} longitude={event.mapLong} />
) : (
<div className="text-base-100">No coordinates found.</div>
)}
</div>
<div className="w-full md:w-1/2 flex flex-col gap-x-12">
<section className="w-full md:w-1/2">
<section className="w-full md:w-3/4">
<h2 className="font-bold text-2xl">Location</h2>
<div className="flex justify-between">
<p>Longitude: </p>
<p>{event.mapLong}</p>
<p>{event.mapLong ?? "-"}</p>
</div>
<div className="flex justify-between">
<p>Latitude: </p>
<p>{event.mapLat}</p>
<p>{event.mapLat ?? "-"}</p>
</div>
<div className="flex justify-between">
<p>Island: </p>
<p>{event.closestIsland}</p>
<p>{event.closestIsland ?? "-"}</p>
</div>
</section>
<section className="w-full md:w-1/2">
<h2 className="font-bold text-2xl">Contact Information</h2>
<section className="w-full md:w-3/4">
<h2 className="font-bold md:text-2xl">Contact Information</h2>
<div className="flex justify-between">
<p>Email: </p>
<p>{event.publicContact.email}</p>
Expand All @@ -65,18 +69,20 @@ const EventRemoval = ({ event }) => {
<div className="w-full md:w-1/2">
<h2 className="text-2xl font-bold">Information</h2>
<ul className="list-disc pl-4 overflow-auto">
<li className="break-words">{event.publicType}</li>
<li className="break-words">{event.publicLocationDesc}</li>
<li className="break-works">{event.publicDebrisEnvDesc}</li>
<li className="break-words">
{event.publicType && (
<li className="break-words">Type: {event.publicType}</li>
)}
{event.publicLocationDesc && <li className="break-words">{event.publicLocationDesc}</li>}
{event.publicDebrisEnvDesc && <li className="break-works">{event.publicDebrisEnvDesc}</li>}
{event.publicBiofoulingRating && (<li className="break-words">
Biofouling Rating - {event.publicBiofoulingRating}
</li>
<li className="break-words">
</li>)}
{event.publicContainerFullness && (<li className="break-words">
Container Fullness - {event.publicContainerFullness}
</li>
<li className="break-words">
</li>)}
{event.publicClaimBoat && (<li className="break-words">
Contact claims boat - {event.publicClaimBoat}
</li>
</li>)}
</ul>
</div>
<div className="w-full md:w-1/2 h-96 bg-primary-content rounded-md flex items-center justify-center text-base-100 py-3">
Expand Down
2 changes: 1 addition & 1 deletion my-app/src/components/events/RemovalAndStorage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const RemovalAndStorage = ({ event, userOrgId }) => {
{STATUS.indexOf(event.status) <= 1 ? (
<MarkAsCompleteBtn eventId={event._id} nextStatus={STATUS[2]} />
) : (
<UndoStepBtn eventId={event._id} prevStatus={STATUS[1]} />
<UndoStepBtn eventId={event._id} prevStatus={STATUS[0]} />
)}
</section>
)}
Expand Down
1 change: 1 addition & 0 deletions my-app/src/components/events/common/UndoStepBtn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const UndoStepBtn = ({ eventId, prevStatus }) => {
},
body: JSON.stringify({
status: prevStatus,
removalOrgId: null,
}),
});
if (res.ok) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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");
}
}
Expand Down

0 comments on commit fe58919

Please sign in to comment.