diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 65d954ca0..525fa5515 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -196,6 +196,27 @@ actions + + block + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + cancel false @@ -442,6 +463,27 @@ + + blocked + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + cancelledappointment false diff --git a/client/src/components/invoice-add-line-button/invoice-add-line-button.component.jsx b/client/src/components/invoice-add-line-button/invoice-add-line-button.component.jsx deleted file mode 100644 index 18f4680c1..000000000 --- a/client/src/components/invoice-add-line-button/invoice-add-line-button.component.jsx +++ /dev/null @@ -1,36 +0,0 @@ -import React, { useState } from "react"; -import { Button, Popover, Input, InputNumber, Form } from "antd"; -import { SelectOutlined } from "@ant-design/icons"; -import { useTranslation } from "react-i18next"; - -export default function InvoiceAddLineButton({ jobLine, discount, disabled }) { - const [visibility, setVisibility] = useState(false); - const { t } = useTranslation(); - - const popContent = ( -
- - - - - - - - - - - - - DISC: {discount} - -
- ); - - return ( - - - - ); -} diff --git a/client/src/components/schedule-block-day/schedule-block-day.component.jsx b/client/src/components/schedule-block-day/schedule-block-day.component.jsx new file mode 100644 index 000000000..d8be28e71 --- /dev/null +++ b/client/src/components/schedule-block-day/schedule-block-day.component.jsx @@ -0,0 +1,61 @@ +import React from "react"; +import { MinusCircleTwoTone } from "@ant-design/icons"; +import { Dropdown, Menu } from "antd"; +import { useTranslation } from "react-i18next"; +import { useMutation } from "@apollo/react-hooks"; +import { INSERT_APPOINTMENT } from "../../graphql/appointments.queries"; +import moment from "moment"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); +export default connect(mapStateToProps, mapDispatchToProps)(ScheduleBlockDay); + +export function ScheduleBlockDay({ date, children, refetch, bodyshop }) { + const { t } = useTranslation(); + const [insertBlock] = useMutation(INSERT_APPOINTMENT); + + const handleMenu = async (e) => { + e.domEvent.stopPropagation(); + console.log("date", date); + + if (e.key === "block") { + console.log("Block."); + + const blockAppt = { + title: t("appointments.labels.blocked"), + block: true, + isintake: false, + bodyshopid: bodyshop.id, + start: moment(date).startOf("day"), + end: moment(date).endOf("day"), + }; + console.log("handleMenu -> blockAppt", blockAppt); + + const result = await insertBlock({ + variables: { app: [blockAppt] }, + }); + + if (!!refetch) refetch(); + } + }; + + const menu = ( + + {t("appointments.actions.block")} + 2nd menu item + 3rd menu item + + ); + + return ( + + {children} + + ); +} diff --git a/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js b/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js index 8873df7d7..4218c1885 100644 --- a/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js +++ b/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js @@ -9,6 +9,8 @@ import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component"; import { Progress } from "antd"; import { MdCallReceived, MdCallMissedOutgoing } from "react-icons/md"; import Icon from "@ant-design/icons"; +import ScheduleBlockDay from "../schedule-block-day/schedule-block-day.component"; + const ShopTargetHrs = 100; const mapStateToProps = createStructuredSelector({ @@ -23,6 +25,7 @@ const mapDispatchToProps = (dispatch) => ({ export function ScheduleCalendarHeaderComponent({ label, + refetch, date, load, calculating, @@ -37,7 +40,7 @@ export function ScheduleCalendarHeaderComponent({ percent={((loadData.expectedLoad || 0) / ShopTargetHrs) * 100} /> -
+
{(loadData.hoursIn || 0) && loadData.hoursIn.toFixed(2)} @@ -47,14 +50,16 @@ export function ScheduleCalendarHeaderComponent({ ) : null; return ( -
- {label} - {calculating || JSON.stringify(load) === "{}" ? ( - - ) : ( - LoadComponent - )} -
+ +
+ {label} + {calculating || JSON.stringify(load) === "{}" ? ( + + ) : ( + LoadComponent + )} +
+
); } export default connect( diff --git a/client/src/components/schedule-calendar-wrapper/schedule-calendar.styles.scss b/client/src/components/schedule-calendar-wrapper/schedule-calendar.styles.scss index 8b390f7c5..34e78d4b6 100644 --- a/client/src/components/schedule-calendar-wrapper/schedule-calendar.styles.scss +++ b/client/src/components/schedule-calendar-wrapper/schedule-calendar.styles.scss @@ -6,5 +6,9 @@ } .imex-event-arrived { - background-color: green; + background-color: rgba(4, 141, 4, 0.4); +} + +.imex-event-block { + background-color: rgba(212, 2, 2, 0.6); } 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 6dfa12634..156cb5ad2 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 @@ -37,14 +37,20 @@ export function ScheduleCalendarWrapperComponent({ // bucket.gte <= jobHrs && (!!bucket.lt ? bucket.lt > jobHrs : true) // )[0]; - return { className: event.arrived ? "imex-event-arrived" : "" }; + return { + className: `${event.arrived ? "imex-event-arrived" : ""} ${ + event.block ? "imex-event-block" : "" + }`, + }; }; + const selectedDate = new Date(date || moment(search.date) || Date.now()); + return ( { search.date = date.toISOString().substr(0, 10); history.push({ search: queryString.stringify(search) }); diff --git a/client/src/components/schedule-event/schedule-event.container.jsx b/client/src/components/schedule-event/schedule-event.container.jsx index ffb910496..8debac831 100644 --- a/client/src/components/schedule-event/schedule-event.container.jsx +++ b/client/src/components/schedule-event/schedule-event.container.jsx @@ -5,6 +5,8 @@ import { UPDATE_JOB } from "../../graphql/jobs.queries"; import ScheduleEventComponent from "./schedule-event.component"; import { notification } from "antd"; import { useTranslation } from "react-i18next"; + + export default function ScheduleEventContainer({ event, refetch }) { const { t } = useTranslation(); const [cancelAppointment] = useMutation(CANCEL_APPOINTMENT_BY_ID); diff --git a/client/src/graphql/appointments.queries.js b/client/src/graphql/appointments.queries.js index b34d76246..5b6bf73b5 100644 --- a/client/src/graphql/appointments.queries.js +++ b/client/src/graphql/appointments.queries.js @@ -18,6 +18,7 @@ export const QUERY_ALL_ACTIVE_APPOINTMENTS = gql` arrived title isintake + block job { ro_number ownr_ln @@ -42,6 +43,12 @@ export const INSERT_APPOINTMENT = gql` insert_appointments(objects: $app) { returning { id + start + end + arrived + title + isintake + block } } } @@ -85,6 +92,7 @@ export const CANCEL_APPOINTMENT_BY_ID = gql` ) { returning { id + canceled } } } diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 9247a8fc8..31b397efb 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -19,6 +19,7 @@ }, "appointments": { "actions": { + "block": "Block Day", "cancel": "Cancel", "intake": "Intake", "new": "New Appointment", @@ -36,6 +37,7 @@ }, "labels": { "arrivedon": "Arrived on: ", + "blocked": "Blocked", "cancelledappointment": "Canceled appointment for: ", "history": "History", "nodateselected": "No date has been selected.", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 3b0a38ba9..8550e2893 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -19,6 +19,7 @@ }, "appointments": { "actions": { + "block": "", "cancel": "Cancelar", "intake": "Consumo", "new": "Nueva cita", @@ -36,6 +37,7 @@ }, "labels": { "arrivedon": "Llegado el:", + "blocked": "", "cancelledappointment": "Cita cancelada para:", "history": "", "nodateselected": "No se ha seleccionado ninguna fecha.", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index c07a1b2b9..5613a52fd 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -19,6 +19,7 @@ }, "appointments": { "actions": { + "block": "", "cancel": "annuler", "intake": "Admission", "new": "Nouveau rendez-vous", @@ -36,6 +37,7 @@ }, "labels": { "arrivedon": "Arrivé le:", + "blocked": "", "cancelledappointment": "Rendez-vous annulé pour:", "history": "", "nodateselected": "Aucune date n'a été sélectionnée.", diff --git a/hasura/migrations/1593106950595_alter_table_public_appointments_add_column_block/down.yaml b/hasura/migrations/1593106950595_alter_table_public_appointments_add_column_block/down.yaml new file mode 100644 index 000000000..73f6fb5e0 --- /dev/null +++ b/hasura/migrations/1593106950595_alter_table_public_appointments_add_column_block/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."appointments" DROP COLUMN "block"; + type: run_sql diff --git a/hasura/migrations/1593106950595_alter_table_public_appointments_add_column_block/up.yaml b/hasura/migrations/1593106950595_alter_table_public_appointments_add_column_block/up.yaml new file mode 100644 index 000000000..3daeb9e4c --- /dev/null +++ b/hasura/migrations/1593106950595_alter_table_public_appointments_add_column_block/up.yaml @@ -0,0 +1,6 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."appointments" ADD COLUMN "block" boolean NOT NULL DEFAULT + false; + type: run_sql diff --git a/hasura/migrations/1593106965112_update_permission_user_public_table_appointments/down.yaml b/hasura/migrations/1593106965112_update_permission_user_public_table_appointments/down.yaml new file mode 100644 index 000000000..7a8708e39 --- /dev/null +++ b/hasura/migrations/1593106965112_update_permission_user_public_table_appointments/down.yaml @@ -0,0 +1,35 @@ +- args: + role: user + table: + name: appointments + schema: public + type: drop_insert_permission +- args: + permission: + check: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - id + - created_at + - updated_at + - jobid + - start + - end + - canceled + - arrived + - isintake + - bodyshopid + - title + set: {} + role: user + table: + name: appointments + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1593106965112_update_permission_user_public_table_appointments/up.yaml b/hasura/migrations/1593106965112_update_permission_user_public_table_appointments/up.yaml new file mode 100644 index 000000000..395eb2282 --- /dev/null +++ b/hasura/migrations/1593106965112_update_permission_user_public_table_appointments/up.yaml @@ -0,0 +1,36 @@ +- args: + role: user + table: + name: appointments + schema: public + type: drop_insert_permission +- args: + permission: + check: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - arrived + - block + - bodyshopid + - canceled + - created_at + - end + - id + - isintake + - jobid + - start + - title + - updated_at + set: {} + role: user + table: + name: appointments + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1593106971803_update_permission_user_public_table_appointments/down.yaml b/hasura/migrations/1593106971803_update_permission_user_public_table_appointments/down.yaml new file mode 100644 index 000000000..1c74631cf --- /dev/null +++ b/hasura/migrations/1593106971803_update_permission_user_public_table_appointments/down.yaml @@ -0,0 +1,36 @@ +- args: + role: user + table: + name: appointments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - arrived + - canceled + - isintake + - title + - created_at + - end + - start + - updated_at + - bodyshopid + - id + - jobid + computed_fields: [] + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: appointments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1593106971803_update_permission_user_public_table_appointments/up.yaml b/hasura/migrations/1593106971803_update_permission_user_public_table_appointments/up.yaml new file mode 100644 index 000000000..493ba4dcc --- /dev/null +++ b/hasura/migrations/1593106971803_update_permission_user_public_table_appointments/up.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: appointments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - arrived + - block + - bodyshopid + - canceled + - created_at + - end + - id + - isintake + - jobid + - start + - title + - updated_at + computed_fields: [] + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: appointments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1593106978517_update_permission_user_public_table_appointments/down.yaml b/hasura/migrations/1593106978517_update_permission_user_public_table_appointments/down.yaml new file mode 100644 index 000000000..4738d5505 --- /dev/null +++ b/hasura/migrations/1593106978517_update_permission_user_public_table_appointments/down.yaml @@ -0,0 +1,35 @@ +- args: + role: user + table: + name: appointments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - arrived + - canceled + - isintake + - title + - created_at + - end + - start + - updated_at + - bodyshopid + - id + - jobid + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: appointments + schema: public + type: create_update_permission diff --git a/hasura/migrations/1593106978517_update_permission_user_public_table_appointments/up.yaml b/hasura/migrations/1593106978517_update_permission_user_public_table_appointments/up.yaml new file mode 100644 index 000000000..ceb8763aa --- /dev/null +++ b/hasura/migrations/1593106978517_update_permission_user_public_table_appointments/up.yaml @@ -0,0 +1,36 @@ +- args: + role: user + table: + name: appointments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - arrived + - block + - bodyshopid + - canceled + - created_at + - end + - id + - isintake + - jobid + - start + - title + - updated_at + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: appointments + schema: public + type: create_update_permission diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index b7d93101b..e3053934d 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -105,32 +105,34 @@ tables: - active: _eq: true columns: - - id + - arrived + - block + - bodyshopid + - canceled - created_at - - updated_at + - end + - id + - isintake - jobid - start - - end - - canceled - - arrived - - isintake - - bodyshopid - title + - updated_at select_permissions: - role: user permission: columns: - arrived + - block + - bodyshopid - canceled - - isintake - - title - created_at - end - - start - - updated_at - - bodyshopid - id + - isintake - jobid + - start + - title + - updated_at filter: bodyshop: associations: @@ -146,16 +148,17 @@ tables: permission: columns: - arrived + - block + - bodyshopid - canceled - - isintake - - title - created_at - end - - start - - updated_at - - bodyshopid - id + - isintake - jobid + - start + - title + - updated_at filter: bodyshop: associations: