diff --git a/client/src/components/schedule-calendar-wrapper/schedule-calendar-header-graph.component.js b/client/src/components/schedule-calendar-wrapper/schedule-calendar-header-graph.component.js index 63332437d..557ae611b 100644 --- a/client/src/components/schedule-calendar-wrapper/schedule-calendar-header-graph.component.js +++ b/client/src/components/schedule-calendar-wrapper/schedule-calendar-header-graph.component.js @@ -1,15 +1,18 @@ import { Popover } from "antd"; -import React from "react"; +import React, { useMemo } from "react"; import { connect } from "react-redux"; import { PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, + Legend, RadarChart, + Tooltip, } from "recharts"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; +import { RadarChartOutlined } from "@ant-design/icons"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -21,44 +24,54 @@ const mapDispatchToProps = (dispatch) => ({ export function ScheduleCalendarHeaderGraph({ bodyshop, loadData }) { const { ssbuckets } = bodyshop; - const data = Object.keys(loadData.expectedLoad).map((key) => { - const metadataBucket = ssbuckets.filter((b) => b.id === key)[0]; + const data = useMemo(() => { + return Object.keys(loadData.expectedLoad).map((key) => { + const metadataBucket = ssbuckets.filter((b) => b.id === key)[0]; - return { - bucket: loadData.expectedLoad[key].label, - current: loadData.expectedLoad[key].count, - target: metadataBucket && metadataBucket.target, - }; - }); + return { + bucket: loadData.expectedLoad[key].label, + current: loadData.expectedLoad[key].count, + target: metadataBucket && metadataBucket.target, + }; + }); + }, [loadData, ssbuckets]); -//d console.log("data", data); const popContent = (
- + + + +
); return ( - G + ); } diff --git a/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx b/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx index 3aa8352b0..eb6723820 100644 --- a/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx +++ b/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx @@ -70,12 +70,20 @@ export function ScheduleCalendarWrapperComponent({ search.view = view; history.push({ search: queryString.stringify(search) }); }} - step={15} + step={30} timeslots={1} showMultiDayTimes localizer={localizer} - min={new Date("2020-01-01T06:00:00")} //TODO Read from business settings. - max={new Date("2020-01-01T20:00:00")} + min={ + bodyshop.schedule_start_time + ? new Date(bodyshop.schedule_start_time) + : new Date("2020-01-01T06:00:00") + } //TODO Read from business settings. + max={ + bodyshop.schedule_end_time + ? new Date(bodyshop.schedule_end_time) + : new Date("2020-01-01T20:00:00") + } eventPropGetter={handleEventPropStyles} components={{ event: (e) => Event({ event: e.event, refetch: refetch }), diff --git a/client/src/components/shop-info/shop-info.container.jsx b/client/src/components/shop-info/shop-info.container.jsx index 2d2646f30..122d66aaf 100644 --- a/client/src/components/shop-info/shop-info.container.jsx +++ b/client/src/components/shop-info/shop-info.container.jsx @@ -8,7 +8,7 @@ import AlertComponent from "../alert/alert.component"; import { useTranslation } from "react-i18next"; import { logImEXEvent } from "../../firebase/firebase.utils"; import FormsFieldChanged from "../form-fields-changed-alert/form-fields-changed-alert.component"; - +import moment from "moment"; export default function ShopInfoContainer() { const [form] = Form.useForm(); const { t } = useTranslation(); @@ -49,7 +49,17 @@ export default function ShopInfoContainer() { layout="vertical" autoComplete="new-password" onFinish={handleFinish} - initialValues={data ? data.bodyshops[0] : null} + initialValues={ + data + ? { + ...data.bodyshops[0], + schedule_start_time: moment( + data.bodyshops[0].schedule_start_time + ), + schedule_end_time: moment(data.bodyshops[0].schedule_end_time), + } + : null + } > diff --git a/client/src/components/shop-info/shop-info.scheduling.component.jsx b/client/src/components/shop-info/shop-info.scheduling.component.jsx index e6f81504d..b3b23aa54 100644 --- a/client/src/components/shop-info/shop-info.scheduling.component.jsx +++ b/client/src/components/shop-info/shop-info.scheduling.component.jsx @@ -1,5 +1,14 @@ import { DeleteFilled } from "@ant-design/icons"; -import { Button, Col, Form, Input, InputNumber, Row, Select } from "antd"; +import { + Button, + Col, + Form, + Input, + InputNumber, + Row, + Select, + TimePicker, +} from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import ColorpickerFormItemComponent from "../form-items-formatted/colorpicker-form-item.component"; @@ -11,6 +20,30 @@ export default function ShopInfoSchedulingComponent({ form }) { return (
+ + + + + + {t("bodyshop.labels.orderstatuses")} diff --git a/client/src/graphql/bodyshop.queries.js b/client/src/graphql/bodyshop.queries.js index dfca953e2..695d6885c 100644 --- a/client/src/graphql/bodyshop.queries.js +++ b/client/src/graphql/bodyshop.queries.js @@ -72,6 +72,8 @@ export const QUERY_BODYSHOP = gql` target_touchtime appt_colors appt_alt_transport + schedule_start_time + schedule_end_time employees { id first_name @@ -142,6 +144,8 @@ export const UPDATE_SHOP = gql` target_touchtime appt_colors appt_alt_transport + schedule_start_time + schedule_end_time employees { id first_name diff --git a/client/src/redux/application/application.sagas.js b/client/src/redux/application/application.sagas.js index 5b2864002..a1c5009ec 100644 --- a/client/src/redux/application/application.sagas.js +++ b/client/src/redux/application/application.sagas.js @@ -114,7 +114,6 @@ export function* calculateScheduleLoad({ payload: end }) { load[current].jobsOut || [] ); } - console.log(load); } yield put(scheduleLoadSuccess(load)); diff --git a/client/src/utils/SSSUtils.js b/client/src/utils/SSSUtils.js index f64777fcc..c0e457b03 100644 --- a/client/src/utils/SSSUtils.js +++ b/client/src/utils/SSSUtils.js @@ -1,9 +1,11 @@ +import _ from "lodash"; + export const CheckJobBucket = (buckets, job) => { const jobHours = job.labhrs.aggregate.sum.mod_lb_hrs + job.larhrs.aggregate.sum.mod_lb_hrs; - const matchingBucket = buckets.filter( - (b) => b.gte <= jobHours && b.lt > jobHours + const matchingBucket = buckets.filter((b) => + b.gte <= jobHours && b.lt ? b.lt > jobHours : true ); return matchingBucket[0] && matchingBucket[0].id; @@ -11,7 +13,7 @@ export const CheckJobBucket = (buckets, job) => { export const CalculateLoad = (currentLoad, buckets, jobsIn, jobsOut) => { //Add the jobs coming - const newLoad = { ...currentLoad }; + const newLoad = _.cloneDeep(currentLoad); jobsIn.forEach((job) => { const bucketId = CheckJobBucket(buckets, job); if (bucketId) { @@ -30,13 +32,11 @@ export const CalculateLoad = (currentLoad, buckets, jobsIn, jobsOut) => { newLoad[bucketId].count = newLoad[bucketId].count - 1; } else { console.log( - "[Util Arr Job]Uh oh, this job doesn't fit in a bucket!", + "[Util Out Job]Uh oh, this job doesn't fit in a bucket!", job ); } }); - console.log("newLoad", newLoad); - return newLoad; }; diff --git a/hasura/migrations/1602196074485_alter_table_public_bodyshops_add_column_schedule_start_time/down.yaml b/hasura/migrations/1602196074485_alter_table_public_bodyshops_add_column_schedule_start_time/down.yaml new file mode 100644 index 000000000..b88e99456 --- /dev/null +++ b/hasura/migrations/1602196074485_alter_table_public_bodyshops_add_column_schedule_start_time/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "schedule_start_time"; + type: run_sql diff --git a/hasura/migrations/1602196074485_alter_table_public_bodyshops_add_column_schedule_start_time/up.yaml b/hasura/migrations/1602196074485_alter_table_public_bodyshops_add_column_schedule_start_time/up.yaml new file mode 100644 index 000000000..5eaf4970d --- /dev/null +++ b/hasura/migrations/1602196074485_alter_table_public_bodyshops_add_column_schedule_start_time/up.yaml @@ -0,0 +1,6 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "schedule_start_time" timestamptz + NULL; + type: run_sql diff --git a/hasura/migrations/1602196087643_alter_table_public_bodyshops_add_column_schedule_end_time/down.yaml b/hasura/migrations/1602196087643_alter_table_public_bodyshops_add_column_schedule_end_time/down.yaml new file mode 100644 index 000000000..ae46e6567 --- /dev/null +++ b/hasura/migrations/1602196087643_alter_table_public_bodyshops_add_column_schedule_end_time/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "schedule_end_time"; + type: run_sql diff --git a/hasura/migrations/1602196087643_alter_table_public_bodyshops_add_column_schedule_end_time/up.yaml b/hasura/migrations/1602196087643_alter_table_public_bodyshops_add_column_schedule_end_time/up.yaml new file mode 100644 index 000000000..3d06fe40f --- /dev/null +++ b/hasura/migrations/1602196087643_alter_table_public_bodyshops_add_column_schedule_end_time/up.yaml @@ -0,0 +1,6 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "schedule_end_time" timestamptz + NULL; + type: run_sql diff --git a/hasura/migrations/1602196105066_update_permission_user_public_table_bodyshops/down.yaml b/hasura/migrations/1602196105066_update_permission_user_public_table_bodyshops/down.yaml new file mode 100644 index 000000000..2b690bd5e --- /dev/null +++ b/hasura/migrations/1602196105066_update_permission_user_public_table_bodyshops/down.yaml @@ -0,0 +1,72 @@ +- args: + role: user + table: + name: bodyshops + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - accountingconfig + - address1 + - address2 + - appt_alt_transport + - appt_colors + - appt_length + - bill_tax_rates + - city + - country + - created_at + - deliverchecklist + - email + - enforce_class + - federal_tax_id + - id + - inhousevendorid + - insurance_vendor_id + - intakechecklist + - logo_img_path + - md_categories + - md_classes + - md_ins_cos + - md_labor_rates + - md_messaging_presets + - md_notes_presets + - md_order_statuses + - md_parts_locations + - md_rbac + - md_referral_sources + - md_responsibility_centers + - md_ro_statuses + - messagingservicesid + - phone + - prodtargethrs + - production_config + - region_config + - scoreboard_target + - shopname + - shoprates + - speedprint + - ssbuckets + - state + - state_tax_id + - stripe_acct_id + - target_touchtime + - template_header + - textid + - updated_at + - zip_post + computed_fields: [] + filter: + associations: + bodyshop: + associations: + user: + authid: + _eq: X-Hasura-User-Id + role: user + table: + name: bodyshops + schema: public + type: create_select_permission diff --git a/hasura/migrations/1602196105066_update_permission_user_public_table_bodyshops/up.yaml b/hasura/migrations/1602196105066_update_permission_user_public_table_bodyshops/up.yaml new file mode 100644 index 000000000..b595b5e10 --- /dev/null +++ b/hasura/migrations/1602196105066_update_permission_user_public_table_bodyshops/up.yaml @@ -0,0 +1,74 @@ +- args: + role: user + table: + name: bodyshops + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - accountingconfig + - address1 + - address2 + - appt_alt_transport + - appt_colors + - appt_length + - bill_tax_rates + - city + - country + - created_at + - deliverchecklist + - email + - enforce_class + - federal_tax_id + - id + - inhousevendorid + - insurance_vendor_id + - intakechecklist + - logo_img_path + - md_categories + - md_classes + - md_ins_cos + - md_labor_rates + - md_messaging_presets + - md_notes_presets + - md_order_statuses + - md_parts_locations + - md_rbac + - md_referral_sources + - md_responsibility_centers + - md_ro_statuses + - messagingservicesid + - phone + - prodtargethrs + - production_config + - region_config + - schedule_end_time + - schedule_start_time + - scoreboard_target + - shopname + - shoprates + - speedprint + - ssbuckets + - state + - state_tax_id + - stripe_acct_id + - target_touchtime + - template_header + - textid + - updated_at + - zip_post + computed_fields: [] + filter: + associations: + bodyshop: + associations: + user: + authid: + _eq: X-Hasura-User-Id + role: user + table: + name: bodyshops + schema: public + type: create_select_permission diff --git a/hasura/migrations/1602196112070_update_permission_user_public_table_bodyshops/down.yaml b/hasura/migrations/1602196112070_update_permission_user_public_table_bodyshops/down.yaml new file mode 100644 index 000000000..49004b66e --- /dev/null +++ b/hasura/migrations/1602196112070_update_permission_user_public_table_bodyshops/down.yaml @@ -0,0 +1,66 @@ +- args: + role: user + table: + name: bodyshops + schema: public + type: drop_update_permission +- args: + permission: + columns: + - accountingconfig + - address1 + - address2 + - appt_alt_transport + - appt_colors + - appt_length + - bill_tax_rates + - city + - country + - created_at + - deliverchecklist + - email + - enforce_class + - federal_tax_id + - id + - inhousevendorid + - insurance_vendor_id + - intakechecklist + - logo_img_path + - md_categories + - md_classes + - md_ins_cos + - md_labor_rates + - md_messaging_presets + - md_notes_presets + - md_order_statuses + - md_parts_locations + - md_rbac + - md_referral_sources + - md_responsibility_centers + - md_ro_statuses + - phone + - prodtargethrs + - production_config + - scoreboard_target + - shopname + - shoprates + - speedprint + - ssbuckets + - state + - state_tax_id + - target_touchtime + - updated_at + - zip_post + filter: + associations: + bodyshop: + associations: + user: + authid: + _eq: X-Hasura-User-Id + set: {} + role: user + table: + name: bodyshops + schema: public + type: create_update_permission diff --git a/hasura/migrations/1602196112070_update_permission_user_public_table_bodyshops/up.yaml b/hasura/migrations/1602196112070_update_permission_user_public_table_bodyshops/up.yaml new file mode 100644 index 000000000..660df165c --- /dev/null +++ b/hasura/migrations/1602196112070_update_permission_user_public_table_bodyshops/up.yaml @@ -0,0 +1,68 @@ +- args: + role: user + table: + name: bodyshops + schema: public + type: drop_update_permission +- args: + permission: + columns: + - accountingconfig + - address1 + - address2 + - appt_alt_transport + - appt_colors + - appt_length + - bill_tax_rates + - city + - country + - created_at + - deliverchecklist + - email + - enforce_class + - federal_tax_id + - id + - inhousevendorid + - insurance_vendor_id + - intakechecklist + - logo_img_path + - md_categories + - md_classes + - md_ins_cos + - md_labor_rates + - md_messaging_presets + - md_notes_presets + - md_order_statuses + - md_parts_locations + - md_rbac + - md_referral_sources + - md_responsibility_centers + - md_ro_statuses + - phone + - prodtargethrs + - production_config + - schedule_end_time + - schedule_start_time + - scoreboard_target + - shopname + - shoprates + - speedprint + - ssbuckets + - state + - state_tax_id + - target_touchtime + - updated_at + - zip_post + filter: + associations: + bodyshop: + associations: + user: + authid: + _eq: X-Hasura-User-Id + set: {} + role: user + table: + name: bodyshops + schema: public + type: create_update_permission diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index f5b748995..164dc62f6 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -734,6 +734,8 @@ tables: - prodtargethrs - production_config - region_config + - schedule_end_time + - schedule_start_time - scoreboard_target - shopname - shoprates @@ -792,6 +794,8 @@ tables: - phone - prodtargethrs - production_config + - schedule_end_time + - schedule_start_time - scoreboard_target - shopname - shoprates