Merged in feature/IO-2264-schedule-filter (pull request #806)
Feature/IO-2264 schedule filter Approved-by: Patrick Fic
This commit is contained in:
@@ -39,20 +39,44 @@ export function ScheduleCalendarComponent({ data, refetch, bodyshop }) {
|
||||
employeevacation: true,
|
||||
ins_co_nm: null,
|
||||
});
|
||||
const [estimatorsFilter, setEstimatiorsFilter] = useLocalStorage(
|
||||
"estimators",
|
||||
[]
|
||||
);
|
||||
|
||||
const estimators = useMemo(
|
||||
() =>
|
||||
data
|
||||
.filter((d) => d.__typename === "appointments")
|
||||
.map((app) => `${app.job.est_ct_fn} ${app.job.est_ct_ln}`),
|
||||
[data]
|
||||
);
|
||||
|
||||
const filteredData = useMemo(() => {
|
||||
return data.filter(
|
||||
(d) =>
|
||||
(d.block ||
|
||||
(filter.intake && d.isintake) ||
|
||||
(filter.manual && !d.isintake && d.block === false) ||
|
||||
(d.__typename === "employee_vacation" &&
|
||||
filter.employeevacation &&
|
||||
!!d.employee)) &&
|
||||
(filter.ins_co_nm && filter.ins_co_nm.length > 0
|
||||
? filter.ins_co_nm.includes(d.job?.ins_co_nm)
|
||||
: true)
|
||||
);
|
||||
}, [data, filter]);
|
||||
return data
|
||||
.filter((d) => {
|
||||
if (d.__typename === "appointments") {
|
||||
if (estimatorsFilter.length === 0) return true;
|
||||
|
||||
return !!estimatorsFilter.find(
|
||||
(e) => e !== `${d.job.est_ct_fn} ${d.job.est_ct_ln}`
|
||||
);
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.filter(
|
||||
(d) =>
|
||||
(d.block ||
|
||||
(filter.intake && d.isintake) ||
|
||||
(filter.manual && !d.isintake && d.block === false) ||
|
||||
(d.__typename === "employee_vacation" &&
|
||||
filter.employeevacation &&
|
||||
!!d.employee)) &&
|
||||
(filter.ins_co_nm && filter.ins_co_nm.length > 0
|
||||
? filter.ins_co_nm.includes(d.job?.ins_co_nm)
|
||||
: true)
|
||||
);
|
||||
}, [data, filter, estimatorsFilter]);
|
||||
|
||||
return (
|
||||
<Row gutter={[16, 16]}>
|
||||
@@ -63,6 +87,21 @@ export function ScheduleCalendarComponent({ data, refetch, bodyshop }) {
|
||||
extra={
|
||||
<Space wrap>
|
||||
<ScheduleAtsSummary appointments={filteredData} />
|
||||
<Select
|
||||
style={{ minWidth: "15rem" }}
|
||||
mode="multiple"
|
||||
placeholder={t("schedule.labels.estimators")}
|
||||
allowClear
|
||||
onClear={() => setEstimatiorsFilter([])}
|
||||
value={[...estimatorsFilter]}
|
||||
onChange={(e) => {
|
||||
setEstimatiorsFilter(e);
|
||||
}}
|
||||
options={estimators.map((e) => ({
|
||||
label: e,
|
||||
value: e,
|
||||
}))}
|
||||
/>
|
||||
<Select
|
||||
style={{ minWidth: "15rem" }}
|
||||
mode="multiple"
|
||||
|
||||
@@ -57,6 +57,8 @@ export const QUERY_ALL_ACTIVE_APPOINTMENTS = gql`
|
||||
v_model_yr
|
||||
v_make_desc
|
||||
v_model_desc
|
||||
est_ct_fn
|
||||
est_ct_ln
|
||||
labhrs: joblines_aggregate(
|
||||
where: { mod_lbr_ty: { _neq: "LAR" }, removed: { _eq: false } }
|
||||
) {
|
||||
|
||||
@@ -2624,6 +2624,7 @@
|
||||
"atssummary": "ATS Summary",
|
||||
"employeevacation": "Employee Vacations",
|
||||
"ins_co_nm_filter": "Filter by Insurance Company",
|
||||
"estimators": "Filter by Writer/Customer Rep.",
|
||||
"intake": "Intake Events",
|
||||
"manual": "Manual Events",
|
||||
"manualevent": "Add Manual Event"
|
||||
|
||||
Reference in New Issue
Block a user