diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index ee4afc6cf..6af655c07 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -188,6 +188,32 @@ general + + actions + + + reset + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + labels @@ -387,6 +413,32 @@ + + messages + + + unsavedchanges + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + diff --git a/client/src/components/jobs-detail-claims/jobs-detail-claims.component.jsx b/client/src/components/jobs-detail-claims/jobs-detail-claims.component.jsx new file mode 100644 index 000000000..3aec766b1 --- /dev/null +++ b/client/src/components/jobs-detail-claims/jobs-detail-claims.component.jsx @@ -0,0 +1,44 @@ +import React, { useContext } from "react"; +import { Form, Input } from "antd"; +import FormItemPhone from "../form-items-formatted/phone-form-item.component"; +import JobDetailFormContext from "../../pages/jobs-detail/jobs-detail.page.context"; + +export default function JobsDetailClaims({ job }) { + const form = useContext(JobDetailFormContext); + const { getFieldDecorator, isFieldTouched } = form; + + return ( +
+
+ + {isFieldTouched("est_ct_ln") ? "Yes" : "No"} + {getFieldDecorator("est_ct_ln", { + initialValue: job.est_ct_ln + })()} + + + {getFieldDecorator("est_ct_fn", { + initialValue: job.est_ct_fn + })()} + + + {getFieldDecorator("est_ph1", { + initialValue: job.est_ph1 + })()} + + + {getFieldDecorator("est_ea", { + initialValue: job.est_ea, + + rules: [ + { + type: "email", + message: "This is not a valid email address." + } + ] + })()} + +
+
+ ); +} diff --git a/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx b/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx index 82d420c6c..4d8148ac6 100644 --- a/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx +++ b/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx @@ -1,14 +1,4 @@ -import { - Avatar, - Button, - Descriptions, - notification, - PageHeader, - Tag, - Input, - Form, - Checkbox -} from "antd"; +import { Avatar, Button, Checkbox, Descriptions, notification, PageHeader, Tag } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import Moment from "react-moment"; @@ -95,7 +85,7 @@ export default function JobsDetailHeader({ - $NO BINDING YET + ##NO BINDING YET## diff --git a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx index 7e3afddd3..9faa7bdcc 100644 --- a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx +++ b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx @@ -1,24 +1,31 @@ -import { Form, Icon, Tabs } from "antd"; -import React from "react"; +import { Form, Icon, Tabs, Alert, Button } from "antd"; +import React, { useContext } from "react"; import { useTranslation } from "react-i18next"; -import { FaRegStickyNote } from "react-icons/fa"; +import { + FaInfo, + FaRegStickyNote, + FaShieldAlt, + FaHardHat +} from "react-icons/fa"; import JobLinesContainer from "../../components/job-lines/job-lines.container.component"; +import JobsDetailClaims from "../../components/jobs-detail-claims/jobs-detail-claims.component"; import JobsDetailHeader from "../../components/jobs-detail-header/jobs-detail-header.component"; import JobsDocumentsContainer from "../../components/jobs-documents/jobs-documents.container"; import JobNotesContainer from "../../components/jobs-notes/jobs-notes.container"; import JobsRatesContainer from "../../components/jobs-rates/jobs-rates.container"; +import JobDetailFormContext from "./jobs-detail.page.context"; export default function JobsDetailPage({ job, mutationUpdateJob, mutationConvertJob, handleSubmit, - handleChange, - getFieldDecorator, refetch }) { const { t } = useTranslation(); + const { isFieldsTouched, resetFields } = useContext(JobDetailFormContext); + const formItemLayout = { labelCol: { xs: { span: 12 }, @@ -30,69 +37,44 @@ export default function JobsDetailPage({ } }; - // const TEMP = ( - //
- // {" "} - // - // {getFieldDecorator("est_ct_ln", { - // initialValue: jobContext.est_ct_ln - // })()} - // - // - // {getFieldDecorator("est_ct_fn", { - // initialValue: jobContext.est_ct_fn - // })()} - // - // - // {getFieldDecorator("est_ph1", { - // initialValue: jobContext.est_ph1 - // })( - // - // )} - // - // - // {getFieldDecorator("est_ea", { - // initialValue: jobContext.est_ea, - // rules: [ - // { - // type: "email", - // message: "This is not a valid email address." - // } - // ] - // })()} - // - //
- // ); - return (
+ {isFieldsTouched() ? ( + + {t("general.messages.unsavedchanges")} + + + } + closable + /> + ) : null} + - + {t("menus.jobsdetail.claimdetail")} } key='claimdetail'> - Claim detail + - + {t("menus.jobsdetail.insurance")} } @@ -125,7 +107,7 @@ export default function JobsDetailPage({ - + {t("menus.jobsdetail.partssublet")} } @@ -136,7 +118,7 @@ export default function JobsDetailPage({ - + {t("menus.jobsdetail.labor")} } @@ -147,7 +129,7 @@ export default function JobsDetailPage({ - + {t("menus.jobsdetail.dates")} } diff --git a/client/src/pages/jobs-detail/jobs-detail.page.container.jsx b/client/src/pages/jobs-detail/jobs-detail.page.container.jsx index 3d6691f66..7003ea7f0 100644 --- a/client/src/pages/jobs-detail/jobs-detail.page.container.jsx +++ b/client/src/pages/jobs-detail/jobs-detail.page.container.jsx @@ -5,11 +5,12 @@ import { useTranslation } from "react-i18next"; import AlertComponent from "../../components/alert/alert.component"; import SpinComponent from "../../components/loading-spinner/loading-spinner.component"; import { + CONVERT_JOB_TO_RO, GET_JOB_BY_PK, - UPDATE_JOB, - CONVERT_JOB_TO_RO + UPDATE_JOB } from "../../graphql/jobs.queries"; import JobsDetailPage from "./jobs-detail.page.component"; +import JobDetailFormContext from "./jobs-detail.page.context"; function JobsDetailPageContainer({ match, form }) { const { jobId } = match.params; @@ -44,32 +45,30 @@ function JobsDetailPageContainer({ match, form }) { if (!err) { mutationUpdateJob({ variables: { jobId: data.jobs_by_pk.id, job: values } - }).then(r => + }).then(r => { notification["success"]({ message: t("jobs.successes.savetitle") - }) - ); + }); + //TODO: Better way to reset the field decorators? + refetch().then(r => form.resetFields()); + }); } }); }; - const handleChange = event => { - //const { name, value } = event.target ? event.target : event; - //setJobContext({ ...jobContext, [name]: value }); - }; - if (loading) return ; if (error) return ; return data.jobs_by_pk ? ( - + + + ) : ( ); diff --git a/client/src/pages/jobs-detail/jobs-detail.page.context.jsx b/client/src/pages/jobs-detail/jobs-detail.page.context.jsx new file mode 100644 index 000000000..60056c8de --- /dev/null +++ b/client/src/pages/jobs-detail/jobs-detail.page.context.jsx @@ -0,0 +1,3 @@ +import React from "react"; +const JobDetailFormContext = React.createContext(null); +export default JobDetailFormContext; diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 8584f8721..49b3b7c52 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -16,6 +16,9 @@ } }, "general": { + "actions": { + "reset": "Reset to original." + }, "labels": { "in": "In", "loading": "Loading...", @@ -28,6 +31,9 @@ "english": "English", "french": "French", "spanish": "Spanish" + }, + "messages": { + "unsavedchanges": "You have unsaved changes." } }, "jobs": { diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 869653e41..365a7846c 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -16,6 +16,9 @@ } }, "general": { + "actions": { + "reset": "Restablecer a original." + }, "labels": { "in": "en", "loading": "Cargando...", @@ -28,6 +31,9 @@ "english": "Inglés", "french": "francés", "spanish": "español" + }, + "messages": { + "unsavedchanges": "Usted tiene cambios no guardados." } }, "jobs": { diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index f067a76a3..222e5ce94 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -16,6 +16,9 @@ } }, "general": { + "actions": { + "reset": "Rétablir l'original." + }, "labels": { "in": "dans", "loading": "Chargement...", @@ -28,6 +31,9 @@ "english": "Anglais", "french": "Francais", "spanish": "Espanol" + }, + "messages": { + "unsavedchanges": "Vous avez des changements non enregistrés." } }, "jobs": {