Fix tabs.

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-01-04 16:34:51 -05:00
parent 2c8d1accea
commit 33a1ac9be4
7 changed files with 137 additions and 135 deletions

View File

@@ -191,7 +191,7 @@ export function EmailOverlayComponent({
items={[ items={[
{ {
key: "documents", key: "documents",
tab: t("emails.labels.documents"), label: t("emails.labels.documents"),
children: ( children: (
<EmailDocumentsComponent <EmailDocumentsComponent
selectedMediaState={selectedMediaState} selectedMediaState={selectedMediaState}
@@ -201,7 +201,7 @@ export function EmailOverlayComponent({
}, },
{ {
key: "attachments", key: "attachments",
tab: t("emails.labels.attachments"), label: t("emails.labels.attachments"),
children: ( children: (
<> <>
{bodyshop.uselocalmediaserver && emailConfig.jobid && ( {bodyshop.uselocalmediaserver && emailConfig.jobid && (

View File

@@ -39,6 +39,63 @@ export function ShopInfoComponent({bodyshop, form, saveLoading}) {
const location = useLocation(); const location = useLocation();
const search = queryString.parse(location.search); const search = queryString.parse(location.search);
const tabItems = [
{
key: "general",
label: t("bodyshop.labels.shopinfo"),
children: <ShopInfoGeneral form={form}/>,
},
{
key: "speedprint",
label: t("bodyshop.labels.speedprint"),
children: <ShopInfoSpeedPrint form={form}/>,
},
{
key: "rbac",
label: t("bodyshop.labels.rbac"),
children: <ShopInfoRbacComponent form={form}/>,
},
{
key: "roStatus",
label: t("bodyshop.labels.jobstatuses"),
children: <ShopInfoROStatusComponent form={form}/>,
},
{
key: "scheduling",
label: t("bodyshop.labels.scheduling"),
children: <ShopInfoSchedulingComponent form={form}/>,
},
{
key: "orderStatus",
label: t("bodyshop.labels.orderstatuses"),
children: <ShopInfoOrderStatusComponent form={form}/>,
},
{
key: "responsibilityCenters",
label: t("bodyshop.labels.responsibilitycenters.title"),
children: <ShopInfoResponsibilityCenterComponent form={form}/>,
},
{
key: "checklists",
label: t("bodyshop.labels.checklists"),
children: <ShopInfoIntakeChecklistComponent form={form}/>,
},
{
key: "laborrates",
label: t("bodyshop.labels.laborrates"),
children: <ShopInfoLaborRates form={form}/>,
},
...(CriticalPartsScanning.treatment === "on"
? [
{
key: "partsscan",
label: t("bodyshop.labels.partsscan"),
children: <ShopInfoPartsScan form={form}/>,
},
]
: []),
];
return ( return (
<Card <Card
extra={ extra={
@@ -58,62 +115,7 @@ export function ShopInfoComponent({bodyshop, form, saveLoading}) {
search: `?tab=${search.tab}&subtab=${key}`, search: `?tab=${search.tab}&subtab=${key}`,
}) })
} }
items={[ items={tabItems}
{
key: "general",
tab: t("bodyshop.labels.shopinfo"),
children: <ShopInfoGeneral form={form}/>,
},
{
key: "speedprint",
tab: t("bodyshop.labels.speedprint"),
children: <ShopInfoSpeedPrint form={form}/>,
},
{
key: "rbac",
tab: t("bodyshop.labels.rbac"),
children: <ShopInfoRbacComponent form={form}/>,
},
{
key: "roStatus",
tab: t("bodyshop.labels.jobstatuses"),
children: <ShopInfoROStatusComponent form={form}/>,
},
{
key: "scheduling",
tab: t("bodyshop.labels.scheduling"),
children: <ShopInfoSchedulingComponent form={form}/>,
},
{
key: "orderStatus",
tab: t("bodyshop.labels.orderstatuses"),
children: <ShopInfoOrderStatusComponent form={form}/>,
},
{
key: "responsibilityCenters",
tab: t("bodyshop.labels.responsibilitycenters.title"),
children: <ShopInfoResponsibilityCenterComponent form={form}/>,
},
{
key: "checklists",
tab: t("bodyshop.labels.checklists"),
children: <ShopInfoIntakeChecklistComponent form={form}/>,
},
{
key: "laborrates",
tab: t("bodyshop.labels.laborrates"),
children: <ShopInfoLaborRates form={form}/>,
},
...(CriticalPartsScanning.treatment === "on"
? [
{
key: "partsscan",
tab: t("bodyshop.labels.partsscan"),
children: <ShopInfoPartsScan form={form}/>,
},
]
: []),
]}
/> />
</Card> </Card>
); );

View File

@@ -19,6 +19,7 @@ export default function ShopInfoContainer() {
nextFetchPolicy: "network-only", nextFetchPolicy: "network-only",
}); });
const handleFinish = (values) => { const handleFinish = (values) => {
setSaveLoading(true); setSaveLoading(true);
logImEXEvent("shop_update"); logImEXEvent("shop_update");

View File

@@ -112,7 +112,7 @@ export function TechLookupJobsDrawer({bodyshop, setPrintCenterContext}) {
items={[ items={[
{ {
key: "lines", key: "lines",
tab: t("jobs.labels.lines"), label: t("jobs.labels.lines"),
children: ( children: (
<JobLinesContainer <JobLinesContainer
jobId={selected} jobId={selected}
@@ -124,7 +124,7 @@ export function TechLookupJobsDrawer({bodyshop, setPrintCenterContext}) {
}, },
{ {
key: "documents", key: "documents",
tab: t("jobs.labels.documents"), label: t("jobs.labels.documents"),
children: bodyshop.uselocalmediaserver ? ( children: bodyshop.uselocalmediaserver ? (
<JobsDocumentsLocalGallery <JobsDocumentsLocalGallery
job={data ? data.jobs_by_pk : null} job={data ? data.jobs_by_pk : null}
@@ -135,7 +135,7 @@ export function TechLookupJobsDrawer({bodyshop, setPrintCenterContext}) {
}, },
{ {
key: "notes", key: "notes",
tab: t("jobs.labels.notes"), label: t("jobs.labels.notes"),
children: <JobNotesContainer jobId={searchParams.selected}/>, children: <JobNotesContainer jobId={searchParams.selected}/>,
}, },
]} ]}

View File

@@ -261,7 +261,7 @@ export function JobsDetailPage({
items={[ items={[
{ {
key: "general", key: "general",
tab: ( label: (
<span><Icon component={FaShieldAlt} />{t("menus.jobsdetail.general")}</span> <span><Icon component={FaShieldAlt} />{t("menus.jobsdetail.general")}</span>
), ),
forceRender: true, forceRender: true,
@@ -269,7 +269,7 @@ export function JobsDetailPage({
}, },
{ {
key: "repairdata", key: "repairdata",
tab: ( label: (
<span><BarsOutlined />{t("menus.jobsdetail.repairdata")}</span> <span><BarsOutlined />{t("menus.jobsdetail.repairdata")}</span>
), ),
forceRender: true, forceRender: true,
@@ -284,7 +284,7 @@ export function JobsDetailPage({
}, },
{ {
key: "rates", key: "rates",
tab: ( label: (
<span><DollarCircleOutlined />{t("menus.jobsdetail.rates")}</span> <span><DollarCircleOutlined />{t("menus.jobsdetail.rates")}</span>
), ),
forceRender: true, forceRender: true,
@@ -292,28 +292,28 @@ export function JobsDetailPage({
}, },
{ {
key: "totals", key: "totals",
tab: ( label: (
<span><DollarCircleOutlined />{t("menus.jobsdetail.totals")}</span> <span><DollarCircleOutlined />{t("menus.jobsdetail.totals")}</span>
), ),
children: <JobsDetailTotals job={job} refetch={refetch} />, children: <JobsDetailTotals job={job} refetch={refetch} />,
}, },
{ {
key: "partssublet", key: "partssublet",
tab: ( label: (
<span><ToolFilled />{t("menus.jobsdetail.partssublet")}</span> <span><ToolFilled />{t("menus.jobsdetail.partssublet")}</span>
), ),
children: <JobsDetailPliContainer job={job} />, children: <JobsDetailPliContainer job={job} />,
}, },
{ {
key: "labor", key: "labor",
tab: ( label: (
<span><Icon component={FaHardHat} />{t("menus.jobsdetail.labor")}</span> <span><Icon component={FaHardHat} />{t("menus.jobsdetail.labor")}</span>
), ),
children: <JobsDetailLaborContainer job={job} jobId={job.id} />, children: <JobsDetailLaborContainer job={job} jobId={job.id} />,
}, },
{ {
key: "dates", key: "dates",
tab: ( label: (
<span><CalendarFilled />{t("menus.jobsdetail.dates")}</span> <span><CalendarFilled />{t("menus.jobsdetail.dates")}</span>
), ),
forceRender: true, forceRender: true,
@@ -321,7 +321,7 @@ export function JobsDetailPage({
}, },
{ {
key: "documents", key: "documents",
tab: ( label: (
<span><FileImageFilled />{t("jobs.labels.documents")}</span> <span><FileImageFilled />{t("jobs.labels.documents")}</span>
), ),
children: bodyshop.uselocalmediaserver ? ( children: bodyshop.uselocalmediaserver ? (
@@ -332,14 +332,14 @@ export function JobsDetailPage({
}, },
{ {
key: "notes", key: "notes",
tab: ( label: (
<span><Icon component={FaRegStickyNote} />{t("jobs.labels.notes")}</span> <span><Icon component={FaRegStickyNote} />{t("jobs.labels.notes")}</span>
), ),
children: <JobNotesContainer jobId={job.id} />, children: <JobNotesContainer jobId={job.id} />,
}, },
{ {
key: "audit", key: "audit",
tab: (<span><HistoryOutlined />{t("jobs.labels.audit")}</span> label: (<span><HistoryOutlined />{t("jobs.labels.audit")}</span>
), ),
children: <JobAuditTrail jobId={job.id} />, children: <JobAuditTrail jobId={job.id} />,
}, },

View File

@@ -77,21 +77,21 @@ export function ScoreboardContainer({ setBreadcrumbs, setSelectedHeader }) {
items={[ items={[
{ {
key: "sb", key: "sb",
tab: (<span><Icon component={FaShieldAlt} />{t("scoreboard.labels.jobs")}</span> label: (<span><Icon component={FaShieldAlt} />{t("scoreboard.labels.jobs")}</span>
), ),
forceRender: true, forceRender: true,
children: <ScoreboardDisplay />, children: <ScoreboardDisplay />,
}, },
{ {
key: "tickets", key: "tickets",
tab: (<span><FieldTimeOutlined />{t("scoreboard.labels.timeticketsemployee")}</span> label: (<span><FieldTimeOutlined />{t("scoreboard.labels.timeticketsemployee")}</span>
), ),
forceRender: true, forceRender: true,
children: <ScoreboardTimeTickets />, children: <ScoreboardTimeTickets />,
}, },
{ {
key: "ticketsstats", key: "ticketsstats",
tab: (<span><FieldTimeOutlined />{t("scoreboard.labels.allemployeetimetickets")}</span> label: (<span><FieldTimeOutlined />{t("scoreboard.labels.allemployeetimetickets")}</span>
), ),
forceRender: true, forceRender: true,
children: <ScoreboardTimeTicketsStats />, children: <ScoreboardTimeTicketsStats />,

View File

@@ -1,78 +1,77 @@
import { Tabs } from "antd"; import {Tabs} from "antd";
import React, { useEffect } from "react"; import React, {useEffect} from "react";
import { useNavigate, useLocation } from "react-router-dom"; import {useLocation, useNavigate} from "react-router-dom";
import queryString from "query-string"; import queryString from "query-string";
import { useTranslation } from "react-i18next"; import {useTranslation} from "react-i18next";
import ShopEmployeesContainer from "../../components/shop-employees/shop-employees.container"; import ShopEmployeesContainer from "../../components/shop-employees/shop-employees.container";
import ShopInfoContainer from "../../components/shop-info/shop-info.container"; import ShopInfoContainer from "../../components/shop-info/shop-info.container";
import ShopCsiConfig from "../../components/shop-csi-config/shop-csi-config.component"; import ShopCsiConfig from "../../components/shop-csi-config/shop-csi-config.component";
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component"; import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
import { connect } from "react-redux"; import {connect} from "react-redux";
import { createStructuredSelector } from "reselect"; import {createStructuredSelector} from "reselect";
import { import {setBreadcrumbs, setSelectedHeader,} from "../../redux/application/application.actions";
setSelectedHeader, import {selectBodyshop} from "../../redux/user/user.selectors";
setBreadcrumbs,
} from "../../redux/application/application.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
import ShopInfoUsersComponent from "../../components/shop-users/shop-users.component"; import ShopInfoUsersComponent from "../../components/shop-users/shop-users.component";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
}); });
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
setSelectedHeader: (key) => dispatch(setSelectedHeader(key)), setSelectedHeader: (key) => dispatch(setSelectedHeader(key)),
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)), setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
}); });
export function ShopPage({ bodyshop, setSelectedHeader, setBreadcrumbs }) { export function ShopPage({bodyshop, setSelectedHeader, setBreadcrumbs}) {
const { t } = useTranslation(); const {t} = useTranslation();
const history = useNavigate(); const history = useNavigate();
const search = queryString.parse(useLocation().search); const search = queryString.parse(useLocation().search);
useEffect(() => { useEffect(() => {
document.title = t("titles.shop"); document.title = t("titles.shop");
setSelectedHeader("shop"); setSelectedHeader("shop");
setBreadcrumbs([ setBreadcrumbs([
{ {
link: "/manage/shop", link: "/manage/shop",
label: t("titles.bc.shop", { shopname: bodyshop.shopname }), label: t("titles.bc.shop", {shopname: bodyshop.shopname}),
}, },
]); ]);
}, [t, setSelectedHeader, setBreadcrumbs, bodyshop.shopname]); }, [t, setSelectedHeader, setBreadcrumbs, bodyshop.shopname]);
useEffect(() => { useEffect(() => {
if (!search.tab) history({ search: "?tab=info" }); if (!search.tab) history({search: "?tab=info"});
}, [history, search]); }, [history, search]);
return ( return (
<RbacWrapper action="shop:config"> <RbacWrapper action="shop:config">
<Tabs <Tabs
activeKey={search.tab} activeKey={search.tab}
onChange={(key) => history({ search: `?tab=${key}` })} onChange={(key) => history({search: `?tab=${key}`})}
tabs={[ items={[
{ {
key: "info", key: "info",
tab: t("bodyshop.labels.shopinfo"), label: t("bodyshop.labels.shopinfo"),
children: <ShopInfoContainer />, children: <ShopInfoContainer/>,
}, },
{ {
key: "employees", key: "employees",
tab: t("bodyshop.labels.employees"), label: t("bodyshop.labels.employees"),
children: <ShopEmployeesContainer />, children: <ShopEmployeesContainer/>,
}, },
{ {
key: "licensing", key: "licensing",
tab: t("bodyshop.labels.licensing"), label: t("bodyshop.labels.licensing"),
children: <ShopInfoUsersComponent />, children: <ShopInfoUsersComponent/>,
}, },
{ {
key: "csiq", key: "csiq",
tab: t("bodyshop.labels.csiq"), label: t("bodyshop.labels.csiq"),
children: <ShopCsiConfig />, children: <ShopCsiConfig/>,
}, },
]} ]}
/> />
</RbacWrapper> </RbacWrapper>
); );
} }
export default connect(mapStateToProps, mapDispatchToProps)(ShopPage); export default connect(mapStateToProps, mapDispatchToProps)(ShopPage);