From 3150fdaade98bd69ee18a6c771af725e980d65e4 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Thu, 27 Aug 2020 11:27:56 -0700 Subject: [PATCH] Simplified profile page BOD-323 --- bodyshop_translations.babel | 47 +++++++++++++++++++ .../chat-conversation-title.component.jsx | 13 ++--- .../chat-tag-ro/chat-tag-ro.container.jsx | 5 +- .../invoice-enter-modal.container.jsx | 15 ++++-- .../profile-content.component.jsx | 20 -------- .../profile-shops/profile-shops.component.jsx | 19 +++++--- .../profile-sidebar.component.jsx | 35 -------------- .../pages/manage/manage.page.container.jsx | 10 ++-- .../pages/profile/profile.container.page.jsx | 17 +++++-- client/src/pages/profile/profile.page.jsx | 22 +++------ client/src/translations/en_us/common.json | 4 ++ client/src/translations/es/common.json | 4 ++ client/src/translations/fr/common.json | 4 ++ 13 files changed, 121 insertions(+), 94 deletions(-) delete mode 100644 client/src/components/profile-content/profile-content.component.jsx delete mode 100644 client/src/components/profile-sidebar/profile-sidebar.component.jsx diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index dba9f1097..388cccfec 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -19586,6 +19586,32 @@ + + labels + + + activeshop + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + @@ -21464,6 +21490,27 @@ + + profile + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + schedule false diff --git a/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx b/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx index cd2b89ebe..1d06f03cd 100644 --- a/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx +++ b/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx @@ -10,12 +10,13 @@ export default function ChatConversationTitle({ conversation }) { {conversation && conversation.phone_num} - {conversation.job_conversations.map( - (j) => - `${j.job.ownr_fn || ""} ${j.job.ownr_ln || ""} ${ - j.job.ownr_co_nm || "" - } | ` - )} + {conversation && + conversation.job_conversations.map( + (j) => + `${j.job.ownr_fn || ""} ${j.job.ownr_ln || ""} ${ + j.job.ownr_co_nm || "" + } | ` + )}
diff --git a/client/src/components/chat-tag-ro/chat-tag-ro.container.jsx b/client/src/components/chat-tag-ro/chat-tag-ro.container.jsx index 2cf1aa6d1..80b06af89 100644 --- a/client/src/components/chat-tag-ro/chat-tag-ro.container.jsx +++ b/client/src/components/chat-tag-ro/chat-tag-ro.container.jsx @@ -39,7 +39,10 @@ export default function ChatTagRoContainer({ conversation }) { setVisible(false); }; - const existingJobTags = conversation.job_conversations.map((i) => i.jobid); + const existingJobTags = + conversation && + conversation.job_conversations && + conversation.job_conversations.map((i) => i.jobid); const roOptions = data ? data.jobs.filter((job) => !existingJobTags.includes(job.id)) diff --git a/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx b/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx index 2ec74d89b..b18890b50 100644 --- a/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx +++ b/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx @@ -170,9 +170,18 @@ function InvoiceEnterModalContainer({ (invoiceEnterModal.context.job && invoiceEnterModal.context.job.id) || null, - federal_tax_rate: bodyshop.invoice_tax_rates.federal_tax_rate || 0, - state_tax_rate: bodyshop.invoice_tax_rates.state_tax_rate || 0, - local_tax_rate: bodyshop.invoice_tax_rates.local_tax_rate || 0, + federal_tax_rate: + (bodyshop.invoice_tax_rates && + bodyshop.invoice_tax_rates.federal_tax_rate) || + 0, + state_tax_rate: + (bodyshop.invoice_tax_rates && + bodyshop.invoice_tax_rates.state_tax_rate) || + 0, + local_tax_rate: + (bodyshop.invoice_tax_rates && + bodyshop.invoice_tax_rates.local_tax_rate) || + 0, }} > diff --git a/client/src/components/profile-content/profile-content.component.jsx b/client/src/components/profile-content/profile-content.component.jsx deleted file mode 100644 index 6854d4146..000000000 --- a/client/src/components/profile-content/profile-content.component.jsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from "react"; -import { useTranslation } from "react-i18next"; -import AlertComponent from "../alert/alert.component"; -import ProfileMyComponent from "../profile-my/profile-my.component"; -import ProfileShopsContainer from "../profile-shops/profile-shops.container"; - -export default function ProfileContent({ sidebarSelection }) { - const { t } = useTranslation(); - - switch (sidebarSelection.key) { - case "profile": - return ; - case "shops": - return ; - default: - return ( - - ); - } -} diff --git a/client/src/components/profile-shops/profile-shops.component.jsx b/client/src/components/profile-shops/profile-shops.component.jsx index 610aa25ee..7dc4ac91e 100644 --- a/client/src/components/profile-shops/profile-shops.component.jsx +++ b/client/src/components/profile-shops/profile-shops.component.jsx @@ -1,10 +1,10 @@ import React from "react"; import { useTranslation } from "react-i18next"; -import { Table, Button } from "antd"; +import { Table, Button, Typography } from "antd"; export default function ProfileShopsComponent({ loading, data, - updateActiveShop + updateActiveShop, }) { const { t } = useTranslation(); @@ -14,14 +14,14 @@ export default function ProfileShopsComponent({ dataIndex: "shopname", key: "shopname", width: "25%", - render: (text, record) => {record.bodyshop.shopname} + render: (text, record) => {record.bodyshop.shopname}, }, { title: t("associations.fields.active"), dataIndex: "active", key: "active", width: "25%", - render: (text, record) => {record.active ? "Yes" : "No"} + render: (text, record) => {record.active ? "Yes" : "No"}, }, { title: t("associations.labels.actions"), @@ -36,15 +36,20 @@ export default function ProfileShopsComponent({ )} - ) - } + ), + }, ]; return ( ( + + {t("profile.labels.activeshop")} + + )} loading={loading} size="small" - columns={columns.map(item => ({ ...item }))} + columns={columns.map((item) => ({ ...item }))} rowKey="id" dataSource={data} /> diff --git a/client/src/components/profile-sidebar/profile-sidebar.component.jsx b/client/src/components/profile-sidebar/profile-sidebar.component.jsx deleted file mode 100644 index 1ae5a5e17..000000000 --- a/client/src/components/profile-sidebar/profile-sidebar.component.jsx +++ /dev/null @@ -1,35 +0,0 @@ -import React from "react"; -import { useTranslation } from "react-i18next"; -import { Layout, Menu } from "antd"; -import { UserOutlined, BankFilled } from "@ant-design/icons"; - -export default function ProfileSideBar({ - sidebarSelection, - setSidebarSelection -}) { - const { t } = useTranslation(); - - const onMenuClick = e => { - setSidebarSelection({ ...sidebarSelection, key: e.key }); - }; - - return ( - - - - - {t("menus.profilesidebar.profile")} - - - - {t("menus.profilesidebar.shops")} - - - - ); -} diff --git a/client/src/pages/manage/manage.page.container.jsx b/client/src/pages/manage/manage.page.container.jsx index 13b2caba6..c737b487c 100644 --- a/client/src/pages/manage/manage.page.container.jsx +++ b/client/src/pages/manage/manage.page.container.jsx @@ -8,22 +8,24 @@ import ManagePage from "./manage.page.component"; import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component"; import { useTranslation } from "react-i18next"; -const mapDispatchToProps = dispatch => ({ - setBodyshop: bs => dispatch(setBodyshop(bs)) +const mapDispatchToProps = (dispatch) => ({ + setBodyshop: (bs) => dispatch(setBodyshop(bs)), }); function ManagePageContainer({ match, setBodyshop }) { const { loading, error, data } = useQuery(QUERY_BODYSHOP, { - fetchPolicy: "network-only" + fetchPolicy: "network-only", }); + const { t } = useTranslation(); + useEffect(() => { if (data) setBodyshop(data.bodyshops[0]); }, [data, setBodyshop]); if (loading) return ; - if (error) return ; + if (error) return ; return ; } diff --git a/client/src/pages/profile/profile.container.page.jsx b/client/src/pages/profile/profile.container.page.jsx index a2d7ece13..8283226ae 100644 --- a/client/src/pages/profile/profile.container.page.jsx +++ b/client/src/pages/profile/profile.container.page.jsx @@ -1,11 +1,22 @@ import React, { useEffect } from "react"; -import ProfilePage from "./profile.page"; import { useTranslation } from "react-i18next"; -export default function ProfileContainerPage() { +import { connect } from "react-redux"; +import { setBreadcrumbs } from "../../redux/application/application.actions"; +import ProfilePage from "./profile.page"; + +const mapDispatchToProps = (dispatch) => ({ + setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)), +}); + +export function ProfileContainerPage({ setBreadcrumbs }) { const { t } = useTranslation(); useEffect(() => { + setBreadcrumbs([ + { link: "/manage/profile", label: t("titles.bc.profile") }, + ]); document.title = t("titles.profile"); - }, [t]); + }, [t, setBreadcrumbs]); return ; } +export default connect(null, mapDispatchToProps)(ProfileContainerPage); diff --git a/client/src/pages/profile/profile.page.jsx b/client/src/pages/profile/profile.page.jsx index 5138c062b..f8d576d77 100644 --- a/client/src/pages/profile/profile.page.jsx +++ b/client/src/pages/profile/profile.page.jsx @@ -1,20 +1,12 @@ -import { Layout } from "antd"; -import React, { useState } from "react"; -import ProfileContent from "../../components/profile-content/profile-content.component"; -import ProfileSideBar from "../../components/profile-sidebar/profile-sidebar.component"; +import React from "react"; +import ProfileMyComponent from "../../components/profile-my/profile-my.component"; +import ProfileShopsContainer from "../../components/profile-shops/profile-shops.container"; export default function ProfilePage() { - const [sidebarSelection, setSidebarSelection] = useState({ key: "profile" }); return ( - - - - - - - +
+ + ; +
); } diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 20f0d28b0..8fb636e64 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1203,6 +1203,9 @@ "profile": { "errors": { "state": "Error reading page state. Please refresh." + }, + "labels": { + "activeshop": "Active Shop" } }, "scoreboard": { @@ -1326,6 +1329,7 @@ "payments-all": "All Payments", "productionboard": "Production Board - Visual", "productionlist": "Production Board - List", + "profile": "My Profile", "schedule": "Schedule", "scoreboard": "Scoreboard", "shop": "Manage my Shop ({{shopname}})", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 968e7b6fd..905f9116b 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1203,6 +1203,9 @@ "profile": { "errors": { "state": "Error al leer el estado de la página. Porfavor refresca." + }, + "labels": { + "activeshop": "" } }, "scoreboard": { @@ -1326,6 +1329,7 @@ "payments-all": "", "productionboard": "", "productionlist": "", + "profile": "", "schedule": "", "scoreboard": "", "shop": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 22e37884d..8e0efd463 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1203,6 +1203,9 @@ "profile": { "errors": { "state": "Erreur lors de la lecture de l'état de la page. Rafraichissez, s'il vous plait." + }, + "labels": { + "activeshop": "" } }, "scoreboard": { @@ -1326,6 +1329,7 @@ "payments-all": "", "productionboard": "", "productionlist": "", + "profile": "", "schedule": "", "scoreboard": "", "shop": "",