diff --git a/client/src/components/jobs-create-owner-info/jobs-create-owner-info.new.component.jsx b/client/src/components/jobs-create-owner-info/jobs-create-owner-info.new.component.jsx index 5509415a1..b4dc3302a 100644 --- a/client/src/components/jobs-create-owner-info/jobs-create-owner-info.new.component.jsx +++ b/client/src/components/jobs-create-owner-info/jobs-create-owner-info.new.component.jsx @@ -5,16 +5,25 @@ import JobCreateContext from "../../pages/jobs-create/jobs-create.context"; import FormItemEmail from "../form-items-formatted/email-form-item.component"; import FormItemPhone, { PhoneItemFormatterValidation } from "../form-items-formatted/phone-form-item.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; +import { buildOwnerPhoneTypeOptions } from "../../utils/phoneTypeOptions.js"; export default function JobsCreateOwnerInfoNewComponent() { - const PHONE_TYPE_OPTIONS = [ - { label: t("owners.labels.home"), value: "Home" }, - { label: t("owners.labels.work"), value: "Work" }, - { label: t("owners.labels.cell"), value: "Cell" } - ]; const [state] = useContext(JobCreateContext); - const { t } = useTranslation(); + + const PHONE_TYPE_OPTIONS = buildOwnerPhoneTypeOptions(t); + + const PREFERRED_CONTACT_OPTIONS = [ + { + label: t("owners.labels.email", { defaultValue: "Email" }), + options: [{ label: t("owners.labels.email", { defaultValue: "Email" }), value: "Email" }] + }, + { + label: t("owners.labels.phone", { defaultValue: "Phone" }), + options: PHONE_TYPE_OPTIONS + } + ]; + return (
@@ -162,7 +171,7 @@ export default function JobsCreateOwnerInfoNewComponent() { - + + diff --git a/client/src/pages/jobs-create/jobs-create.container.jsx b/client/src/pages/jobs-create/jobs-create.container.jsx index 9905a72fc..cc3aa888d 100644 --- a/client/src/pages/jobs-create/jobs-create.container.jsx +++ b/client/src/pages/jobs-create/jobs-create.container.jsx @@ -47,7 +47,7 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, curr const [form] = Form.useForm(); const [state, setState] = contextState; const [insertJob] = useMutation(INSERT_NEW_JOB); - const [loadOwner, RemoteOwnerData] = useLazyQuery(QUERY_OWNER_FOR_JOB_CREATION); + const [loadOwner, remoteOwnerData] = useLazyQuery(QUERY_OWNER_FOR_JOB_CREATION); useEffect(() => { if (state.owner.selectedid) { @@ -116,15 +116,20 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, curr let ownerData; if (!job.ownerid) { - ownerData = job.owner.data; - ownerData.shopid = bodyshop.id; + // Keep preferred_contact for the nested owner insert... + job.owner.data.shopid = bodyshop.id; + + // ...but do NOT flatten preferred_contact into the job row. + ownerData = _.cloneDeep(job.owner.data); delete ownerData.preferred_contact; + delete job.ownerid; } else { - ownerData = _.cloneDeep(RemoteOwnerData.data.owners_by_pk); + ownerData = _.cloneDeep(remoteOwnerData.data.owners_by_pk); delete ownerData.id; delete ownerData.__typename; } + if (!state.vehicle.none) { if (!job.vehicleid) { delete job.vehicleid; diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 9bbfe28fc..3bd09ca5c 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -2612,7 +2612,10 @@ "updateowner": "Update Owner", "work": "Work", "home": "Home", - "cell": "Cell" + "cell": "Cell", + "other": "Other", + "email": "Email", + "phone": "Phone" }, "successes": { "delete": "Owner deleted successfully.", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index c16b95b55..ff595ac47 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -2609,7 +2609,10 @@ "updateowner": "", "work": "", "home": "", - "cell": "" + "cell": "", + "other": "", + "email": "", + "phone": "" }, "successes": { "delete": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 6c1600d00..acc40e81b 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -2609,7 +2609,10 @@ "updateowner": "", "work": "", "home": "", - "cell": "" + "cell": "", + "other": "", + "email": "", + "phone": "" }, "successes": { "delete": "", diff --git a/client/src/utils/phoneTypeOptions.js b/client/src/utils/phoneTypeOptions.js new file mode 100644 index 000000000..d1f19ac48 --- /dev/null +++ b/client/src/utils/phoneTypeOptions.js @@ -0,0 +1,13 @@ +export const OWNER_PHONE_TYPE_VALUES = { + HOME: "Home", + WORK: "Work", + CELL: "Cell", + OTHER: "Other" +}; + +export const buildOwnerPhoneTypeOptions = (t) => [ + { label: t("owners.labels.home"), value: OWNER_PHONE_TYPE_VALUES.HOME }, + { label: t("owners.labels.work"), value: OWNER_PHONE_TYPE_VALUES.WORK }, + { label: t("owners.labels.cell"), value: OWNER_PHONE_TYPE_VALUES.CELL }, + { label: t("owners.labels.other"), value: OWNER_PHONE_TYPE_VALUES.OTHER } +];