From faed2c32b66f5cf715e3c3eb7873cc97a96d08b1 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 19 Feb 2020 13:26:50 -0800 Subject: [PATCH] Minor adjustments and fixes --- bodyshop_translations.babel | 42 +++++++++++++++++ client/src/App/App.js | 14 +++--- .../jobs-detail-header.component.jsx | 47 +++++++++---------- client/src/graphql/apollo-error-handling.js | 15 +++--- client/src/graphql/jobs.queries.js | 2 +- .../jobs-detail.page.container.jsx | 8 ++-- .../pages/manage/manage.page.container.jsx | 13 ++--- client/src/translations/en_us/common.json | 2 + client/src/translations/es/common.json | 2 + client/src/translations/fr/common.json | 2 + 10 files changed, 95 insertions(+), 52 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index f118d1958..0a097dcfb 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -1283,6 +1283,48 @@ + + loadingshop + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + loggingin + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + na false diff --git a/client/src/App/App.js b/client/src/App/App.js index aab027088..475571c60 100644 --- a/client/src/App/App.js +++ b/client/src/App/App.js @@ -1,5 +1,6 @@ import i18next from "i18next"; import React, { lazy, Suspense, useEffect } from "react"; +import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { Route, Switch } from "react-router-dom"; import { createStructuredSelector } from "reselect"; @@ -33,7 +34,7 @@ export default connect( checkUserSession(); return () => {}; }, [checkUserSession]); - + const { t } = useTranslation(); if (currentUser && currentUser.language) i18next.changeLanguage(currentUser.language, (err, t) => { if (err) @@ -41,8 +42,7 @@ export default connect( }); if (currentUser.authorized === null) { - //TODO: Translate this. - return ; + return ; } return ( @@ -50,15 +50,15 @@ export default connect( }> - - + + - + 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 e554946df..2c2ca281d 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 @@ -43,7 +43,7 @@ export default connect( const tombstoneTitle = (
- + {`${t("jobs.fields.ro_number")} ${ job.ro_number ? job.ro_number : t("general.labels.na") }`} @@ -54,8 +54,7 @@ export default connect( { updateJobStatus(e.key); - }} - > + }}> {bodyshop.md_ro_statuses.statuses.map(item => ( {item} ))} @@ -63,24 +62,23 @@ export default connect( ); const menuExtra = [ - + , - + , , ]; @@ -114,9 +110,9 @@ export default connect( title={tombstoneTitle} //subTitle={tombstoneSubtitle} tags={ - - {job.status ? {job.status} : null} - + + {job.status ? {job.status} : null} + {job.owner ? ( {`${job.ownr_co_nm || ""}${job.ownr_fn || ""} ${job.ownr_ln || @@ -126,7 +122,7 @@ export default connect( t("jobs.errors.noowner") )} - + {job.vehicle ? ( {job.vehicle.v_model_yr || t("general.labels.na")}{" "} @@ -140,11 +136,10 @@ export default connect( } - extra={menuExtra} - > - + extra={menuExtra}> + - {job.claim_total} + {job.clm_total} @@ -157,7 +152,7 @@ export default connect( {job.scheduled_completion ? ( - {job.scheduled_completion} + {job.scheduled_completion} ) : null} diff --git a/client/src/graphql/apollo-error-handling.js b/client/src/graphql/apollo-error-handling.js index ae9aa77e4..d6fdb1b7d 100644 --- a/client/src/graphql/apollo-error-handling.js +++ b/client/src/graphql/apollo-error-handling.js @@ -33,13 +33,14 @@ const errorLink = onError( console.log("Got the new token.", token); window.localStorage.setItem("token", token); - // const oldHeaders = operation.getContext().headers; - // operation.setContext({ - // headers: { - // ...oldHeaders, - // authorization: token ? `Bearer ${token}` : "" - // } - // }); + const oldHeaders = operation.getContext().headers; + operation.setContext({ + headers: { + ...oldHeaders, + authorization: token ? `Bearer ${token}` : "" + } + }); + console.log(operation.getContext()); // console.log("forward", forward); // console.log("operation", operation); return forward(operation); diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 3649c0737..6d630d9a0 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -44,7 +44,6 @@ export const QUERY_ALL_OPEN_JOBS = gql` scheduled_delivery status updated_at - clm_total ded_amt vehicle { id @@ -108,6 +107,7 @@ export const GET_JOB_BY_PK = gql` converted est_number ro_number + clm_total vehicle { id plate_no 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 0a5319ff6..b564728a0 100644 --- a/client/src/pages/jobs-detail/jobs-detail.page.container.jsx +++ b/client/src/pages/jobs-detail/jobs-detail.page.container.jsx @@ -36,8 +36,7 @@ function JobsDetailPageContainer({ match, form }) { refetch(); }) .catch(error => { - //TODO Error handling. - console.log("error", error); + notification[error]({ message: t("jobs.errors.saving") }); }); }; @@ -70,7 +69,6 @@ function JobsDetailPageContainer({ match, form }) { notification["success"]({ message: t("jobs.successes.savetitle") }); - //TODO: Better way to reset the field decorators? refetch().then(r => form.resetFields()); }); } @@ -78,7 +76,7 @@ function JobsDetailPageContainer({ match, form }) { }; if (loading) return ; - if (error) return ; + if (error) return ; return data.jobs_by_pk ? ( @@ -94,7 +92,7 @@ function JobsDetailPageContainer({ match, form }) { /> ) : ( - + ); } export default Form.create({ name: "JobsDetailPageContainer" })( diff --git a/client/src/pages/manage/manage.page.container.jsx b/client/src/pages/manage/manage.page.container.jsx index e9af1b033..0280e0282 100644 --- a/client/src/pages/manage/manage.page.container.jsx +++ b/client/src/pages/manage/manage.page.container.jsx @@ -7,7 +7,10 @@ import { createStructuredSelector } from "reselect"; import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component"; import { QUERY_BODYSHOP } from "../../graphql/bodyshop.queries"; import { setBodyshop } from "../../redux/user/user.actions"; -import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors"; +import { + selectBodyshop, + selectCurrentUser +} from "../../redux/user/user.selectors"; import ManagePage from "./manage.page"; const mapStateToProps = createStructuredSelector({ @@ -33,12 +36,10 @@ export default connect( useEffect(() => { if (data) setBodyshop(data.bodyshops[0]); - return () => { - // - }; + return () => {}; }, [data, setBodyshop]); - //TODO Translate later. - if (!bodyshop) return ; + if (!bodyshop) + return ; return ; }); diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 4accbc4c4..70a7a1959 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -106,6 +106,8 @@ "in": "In", "loading": "Loading...", "loadingapp": "Loading Bodyshop.app", + "loadingshop": "Loading shop data...", + "loggingin": "Logging you in...", "na": "N/A", "out": "Out", "save": "Save", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 0367b57b9..270442c45 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -106,6 +106,8 @@ "in": "en", "loading": "Cargando...", "loadingapp": "Cargando Bodyshop.app", + "loadingshop": "Cargando datos de la tienda ...", + "loggingin": "Iniciando sesión ...", "na": "N / A", "out": "Afuera", "save": "Salvar", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 753184d4c..e64421219 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -106,6 +106,8 @@ "in": "dans", "loading": "Chargement...", "loadingapp": "Chargement de Bodyshop.app", + "loadingshop": "Chargement des données de la boutique ...", + "loggingin": "Vous connecter ...", "na": "N / A", "out": "En dehors", "save": "sauvegarder",