From 310321d0abdde4e5c98a22b6c87025f5b6bb8752 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Mon, 26 May 2025 12:49:58 -0700 Subject: [PATCH] IO-3249 Delete Job Watchers Signed-off-by: Allan Carr --- .../jobs-detail-header-actions.component.jsx | 37 ++++++++++++------- client/src/translations/en_us/common.json | 3 +- client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx index 1db81a3b1..ec1ec32b6 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx @@ -9,6 +9,7 @@ import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { Link, useNavigate } from "react-router-dom"; import { createStructuredSelector } from "reselect"; +import { useNotification } from "../../contexts/Notifications/notificationContext.jsx"; import { useSocket } from "../../contexts/SocketIO/useSocket.js"; import { auth, logImEXEvent } from "../../firebase/firebase.utils"; import { CANCEL_APPOINTMENTS_BY_JOB_ID, INSERT_MANUAL_APPT } from "../../graphql/appointments.queries"; @@ -32,7 +33,6 @@ import ShareToTeamsButton from "../share-to-teams/share-to-teams.component.jsx"; import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util"; import DuplicateJob from "./jobs-detail-header-actions.duplicate.util"; import JobsDetailHeaderActionsToggleProduction from "./jobs-detail-header-actions.toggle-production"; -import { useNotification } from "../../contexts/Notifications/notificationContext.jsx"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -1078,17 +1078,26 @@ export function JobsDetailHeaderActions({ menuItems.push({ key: "deletejob", id: "job-actions-deletejob", - label: ( - e.stopPropagation()} - onConfirm={handleDeleteJob} - > - {t("menus.jobsactions.deletejob")} - - ) + label: + job.job_watchers.length === 0 ? ( + e.stopPropagation()} + onConfirm={handleDeleteJob} + > + {t("menus.jobsactions.deletejob")} + + ) : ( + e.stopPropagation()} + showCancel={false} + > + {t("menus.jobsactions.deletejob")} + + ) }); } @@ -1109,8 +1118,8 @@ export function JobsDetailHeaderActions({ e.stopPropagation()} onConfirm={handleVoidJob} > diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index dca4f62ef..52d6c1c00 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -2032,9 +2032,10 @@ "stands": "Stands", "waived": "Waived" }, - "deleteconfirm": "Are you sure you want to delete this Job? This cannot be undone. ", + "deleteconfirm": "Are you sure you want to delete this Job? This cannot be undone.", "deletedelivery": "Delete Delivery Checklist", "deleteintake": "Delete Intake Checklist", + "deletewatchers": "Remove Watchers before deleting this Job.", "deliverchecklist": "Deliver Checklist", "difference": "Difference", "diskscan": "Scan Disk for Estimates", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index cfc349043..b01353c1b 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -2035,6 +2035,7 @@ "deleteconfirm": "", "deletedelivery": "", "deleteintake": "", + "deletewatchers": "", "deliverchecklist": "", "difference": "", "diskscan": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 0e49be0e1..e77bd39c8 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -2035,6 +2035,7 @@ "deleteconfirm": "", "deletedelivery": "", "deleteintake": "", + "deletewatchers": "", "deliverchecklist": "", "difference": "", "diskscan": "",