From 9b7c0af025ff47992f7c95c4d11312aaf66ccfa5 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Mon, 30 Oct 2023 16:51:26 -0700 Subject: [PATCH] IO-2431 Created By for Appointments --- .../schedule-job-modal/schedule-job-modal.container.jsx | 8 +++++++- hasura/metadata/tables.yaml | 3 +++ .../down.sql | 4 ++++ .../up.sql | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 hasura/migrations/1698709322872_alter_table_public_appointments_add_column_created_by/down.sql create mode 100644 hasura/migrations/1698709322872_alter_table_public_appointments_add_column_created_by/up.sql diff --git a/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx b/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx index ed3eace05..c8b85be38 100644 --- a/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx +++ b/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx @@ -16,13 +16,17 @@ import { QUERY_LBR_HRS_BY_PK, UPDATE_JOBS } from "../../graphql/jobs.queries"; import { setEmailOptions } from "../../redux/email/email.actions"; import { toggleModalVisible } from "../../redux/modals/modals.actions"; import { selectSchedule } from "../../redux/modals/modals.selectors"; -import { selectBodyshop } from "../../redux/user/user.selectors"; +import { + selectBodyshop, + selectCurrentUser, +} from "../../redux/user/user.selectors"; import { TemplateList } from "../../utils/TemplateConstants"; import ScheduleJobModalComponent from "./schedule-job-modal.component"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, scheduleModal: selectSchedule, + currentUser: selectCurrentUser, }); const mapDispatchToProps = (dispatch) => ({ toggleModalVisible: () => dispatch(toggleModalVisible("schedule")), @@ -34,6 +38,7 @@ export function ScheduleJobModalContainer({ bodyshop, toggleModalVisible, setEmailOptions, + currentUser, }) { const { visible, context, actions } = scheduleModal; const { jobId, job, previousEvent } = context; @@ -122,6 +127,7 @@ export function ScheduleJobModalContainer({ end: moment(values.start).add(bodyshop.appt_length || 60, "minutes"), color: values.color, note: values.note, + created_by: currentUser.email, }, jobId: jobId, altTransport: values.alt_transport, diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 701637a9c..69f30251b 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -110,6 +110,7 @@ - canceled - color - created_at + - created_by - end - id - isintake @@ -128,6 +129,7 @@ - canceled - color - created_at + - created_by - end - id - isintake @@ -156,6 +158,7 @@ - canceled - color - created_at + - created_by - end - id - isintake diff --git a/hasura/migrations/1698709322872_alter_table_public_appointments_add_column_created_by/down.sql b/hasura/migrations/1698709322872_alter_table_public_appointments_add_column_created_by/down.sql new file mode 100644 index 000000000..9562a8171 --- /dev/null +++ b/hasura/migrations/1698709322872_alter_table_public_appointments_add_column_created_by/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."appointments" add column "created_by" text +-- null; diff --git a/hasura/migrations/1698709322872_alter_table_public_appointments_add_column_created_by/up.sql b/hasura/migrations/1698709322872_alter_table_public_appointments_add_column_created_by/up.sql new file mode 100644 index 000000000..ef7952cf3 --- /dev/null +++ b/hasura/migrations/1698709322872_alter_table_public_appointments_add_column_created_by/up.sql @@ -0,0 +1,2 @@ +alter table "public"."appointments" add column "created_by" text + null;