feature/IO-3096-GlobalNotifications - Code Review Part 1
This commit is contained in:
@@ -24,8 +24,9 @@ const populateWatchers = (data, result) => {
|
||||
/**
|
||||
* Builds notification data for changes to alternate transport.
|
||||
*/
|
||||
// Verified
|
||||
const alternateTransportChangedBuilder = (data) => {
|
||||
const body = `The alternate transport status has been updated from ${data?.changedFields?.altTransport?.old}.`;
|
||||
const body = `The Alternate Transport status has been updated to ${data?.data?.alt_transport}.`;
|
||||
const result = {
|
||||
app: {
|
||||
jobId: data.jobId,
|
||||
@@ -56,8 +57,12 @@ const alternateTransportChangedBuilder = (data) => {
|
||||
/**
|
||||
* Builds notification data for bill posted events.
|
||||
*/
|
||||
//verified
|
||||
const billPostedHandler = (data) => {
|
||||
const body = `A bill of $${data.data.clm_total} has been posted.`;
|
||||
const facing = data?.data?.isinhouse ? "In-House" : "External";
|
||||
|
||||
const body = `An ${facing} Bill has been posted${data?.data?.is_credit_memo ? " (Credit Memo)" : ""}.`.trim();
|
||||
|
||||
const result = {
|
||||
app: {
|
||||
jobId: data.jobId,
|
||||
@@ -66,7 +71,8 @@ const billPostedHandler = (data) => {
|
||||
key: "notifications.job.billPosted",
|
||||
body,
|
||||
variables: {
|
||||
clmTotal: data.data.clm_total
|
||||
facing,
|
||||
is_credit_memo: data?.data?.is_credit_memo
|
||||
},
|
||||
recipients: []
|
||||
},
|
||||
@@ -87,6 +93,7 @@ const billPostedHandler = (data) => {
|
||||
/**
|
||||
* Builds notification data for changes to critical parts status.
|
||||
*/
|
||||
// TODO: Needs change
|
||||
const criticalPartsStatusChangedBuilder = (data) => {
|
||||
const body = `The critical parts status has changed to ${data.data.queued_for_parts ? "queued" : "not queued"}.`;
|
||||
const result = {
|
||||
@@ -119,8 +126,9 @@ const criticalPartsStatusChangedBuilder = (data) => {
|
||||
/**
|
||||
* Builds notification data for completed intake or delivery checklists.
|
||||
*/
|
||||
// Verified
|
||||
const intakeDeliveryChecklistCompletedBuilder = (data) => {
|
||||
const checklistType = data.changedFields.intakechecklist ? "intake" : "delivery";
|
||||
const checklistType = data?.changedFields?.intakechecklist ? "Intake" : "Delivery";
|
||||
const body = `The ${checklistType.charAt(0).toUpperCase() + checklistType.slice(1)} checklist has been completed.`;
|
||||
const result = {
|
||||
app: {
|
||||
@@ -152,6 +160,7 @@ const intakeDeliveryChecklistCompletedBuilder = (data) => {
|
||||
/**
|
||||
* Builds notification data for job assignment events.
|
||||
*/
|
||||
// Verified
|
||||
const jobAssignedToMeBuilder = (data) => {
|
||||
const body = `You have been assigned to ${getJobAssignmentType(data.scenarioFields?.[0])}`;
|
||||
const result = {
|
||||
@@ -183,8 +192,9 @@ const jobAssignedToMeBuilder = (data) => {
|
||||
/**
|
||||
* Builds notification data for jobs added to production.
|
||||
*/
|
||||
// Verified
|
||||
const jobsAddedToProductionBuilder = (data) => {
|
||||
const body = `Job has been added to production.`;
|
||||
const body = `Has been added to Production.`;
|
||||
const result = {
|
||||
app: {
|
||||
jobId: data.jobId,
|
||||
@@ -212,6 +222,7 @@ const jobsAddedToProductionBuilder = (data) => {
|
||||
/**
|
||||
* Builds notification data for job status changes.
|
||||
*/
|
||||
// Verified
|
||||
const jobStatusChangeBuilder = (data) => {
|
||||
const body = `The status has changed from ${data.changedFields.status.old} to ${data.changedFields.status.new}`;
|
||||
const result = {
|
||||
@@ -244,8 +255,15 @@ const jobStatusChangeBuilder = (data) => {
|
||||
/**
|
||||
* Builds notification data for new media added or reassigned events.
|
||||
*/
|
||||
// Verified
|
||||
const newMediaAddedReassignedBuilder = (data) => {
|
||||
const body = `New media has been added.`;
|
||||
// Determine if it's an image or document
|
||||
const mediaType = data?.data?.type?.startsWith("image") ? "Image" : "Document";
|
||||
// Determine if it's added or updated
|
||||
const action = data.isNew ? "added" : "updated";
|
||||
// Construct the body string
|
||||
const body = `An ${mediaType} has been ${action}.`;
|
||||
|
||||
const result = {
|
||||
app: {
|
||||
jobId: data.jobId,
|
||||
@@ -253,7 +271,10 @@ const newMediaAddedReassignedBuilder = (data) => {
|
||||
bodyShopId: data.bodyShopId,
|
||||
key: "notifications.job.newMediaAdded",
|
||||
body,
|
||||
variables: {},
|
||||
variables: {
|
||||
mediaType,
|
||||
action
|
||||
},
|
||||
recipients: []
|
||||
},
|
||||
email: {
|
||||
@@ -274,7 +295,7 @@ const newMediaAddedReassignedBuilder = (data) => {
|
||||
* Builds notification data for new notes added to a job.
|
||||
*/
|
||||
const newNoteAddedBuilder = (data) => {
|
||||
const body = `A new note has been added: "${data.data.text}"`;
|
||||
const body = `An Note has been added: "${data.data.text}"`;
|
||||
const result = {
|
||||
app: {
|
||||
jobId: data.jobId,
|
||||
@@ -305,7 +326,10 @@ const newNoteAddedBuilder = (data) => {
|
||||
* Builds notification data for new time tickets posted.
|
||||
*/
|
||||
const newTimeTicketPostedBuilder = (data) => {
|
||||
const body = `A new time ticket has been posted.`;
|
||||
consoleDir(data);
|
||||
const type = data?.data?.cost_center;
|
||||
const body = `An ${type} time ticket has been posted${data?.data?.flat_rate ? " (Flat Rate)" : ""}.`.trim();
|
||||
|
||||
const result = {
|
||||
app: {
|
||||
jobId: data.jobId,
|
||||
@@ -313,7 +337,9 @@ const newTimeTicketPostedBuilder = (data) => {
|
||||
bodyShopId: data.bodyShopId,
|
||||
key: "notifications.job.newTimeTicketPosted",
|
||||
body,
|
||||
variables: {},
|
||||
variables: {
|
||||
type
|
||||
},
|
||||
recipients: []
|
||||
},
|
||||
email: {
|
||||
|
||||
Reference in New Issue
Block a user