BOD-70 refactor schedule to use query string
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import queryString from "query-string";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Calendar, momentLocalizer } from "react-big-calendar";
|
import { Calendar, momentLocalizer } from "react-big-calendar";
|
||||||
//import "react-big-calendar/lib/css/react-big-calendar.css";
|
import { useHistory, useLocation } from "react-router-dom";
|
||||||
import "./schedule-calendar.styles.scss";
|
|
||||||
import DateCellWrapper from "../schedule-datecellwrapper/schedule-datecellwrapper.component";
|
import DateCellWrapper from "../schedule-datecellwrapper/schedule-datecellwrapper.component";
|
||||||
import Event from "../schedule-event/schedule-event.container";
|
import Event from "../schedule-event/schedule-event.container";
|
||||||
|
//import "react-big-calendar/lib/css/react-big-calendar.css";
|
||||||
|
import "./schedule-calendar.styles.scss";
|
||||||
|
|
||||||
const localizer = momentLocalizer(moment);
|
const localizer = momentLocalizer(moment);
|
||||||
|
|
||||||
export default function ScheduleCalendarWrapperComponent({
|
export default function ScheduleCalendarWrapperComponent({
|
||||||
@@ -13,20 +16,26 @@ export default function ScheduleCalendarWrapperComponent({
|
|||||||
defaultView,
|
defaultView,
|
||||||
...otherProps
|
...otherProps
|
||||||
}) {
|
}) {
|
||||||
|
const search = queryString.parse(useLocation().search);
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Calendar
|
<Calendar
|
||||||
events={data}
|
events={data}
|
||||||
defaultView={defaultView}
|
defaultView={defaultView}
|
||||||
|
date={new Date(search.date || Date.now())}
|
||||||
|
onNavigate={(date, view, action) => {
|
||||||
|
search.date = date.toISOString().substr(0, 10);
|
||||||
|
history.push({ search: queryString.stringify(search) });
|
||||||
|
}}
|
||||||
step={30}
|
step={30}
|
||||||
showMultiDayTimes
|
showMultiDayTimes
|
||||||
localizer={localizer}
|
localizer={localizer}
|
||||||
min={new Date("2020-01-01T06:00:00")} //TODO Read from business settings.
|
min={new Date("2020-01-01T06:00:00")} //TODO Read from business settings.
|
||||||
max={new Date("2020-01-01T20:00:00")}
|
max={new Date("2020-01-01T20:00:00")}
|
||||||
components={{
|
components={{
|
||||||
event: e => {
|
event: (e) => Event({ event: e.event, refetch: refetch }),
|
||||||
return Event({ event: e.event, refetch: refetch });
|
dateCellWrapper: DateCellWrapper,
|
||||||
},
|
|
||||||
dateCellWrapper: DateCellWrapper
|
|
||||||
}}
|
}}
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default function ScheduleCalendarContainer() {
|
|||||||
|
|
||||||
if (loading) return <LoadingSpinner />;
|
if (loading) return <LoadingSpinner />;
|
||||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||||
let normalizedData = data.appointments.map(e => {
|
let normalizedData = data.appointments.map((e) => {
|
||||||
//Required becuase Hasura returns a string instead of a date object.
|
//Required becuase Hasura returns a string instead of a date object.
|
||||||
return Object.assign(
|
return Object.assign(
|
||||||
{},
|
{},
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
[]
|
||||||
19
hasura/migrations/1588869001045_run_sql_migration/up.yaml
Normal file
19
hasura/migrations/1588869001045_run_sql_migration/up.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
- args:
|
||||||
|
cascade: true
|
||||||
|
read_only: false
|
||||||
|
sql: "CREATE OR REPLACE VIEW \"public\".\"productionview\" AS \n SELECT j.id,\n
|
||||||
|
\ j.status,\n j.ro_number,\n j.est_number,\n j.ownr_fn,\n j.ownr_ln,\n
|
||||||
|
\ j.v_model_yr,\n j.v_model_desc,\n j.clm_no,\n j.v_make_desc,\n
|
||||||
|
\ j.v_color,\n j.plate_no,\n j.actual_in,\n j.scheduled_completion,\n
|
||||||
|
\ j.scheduled_delivery,\n j.ins_co_nm,\n j.clm_total,\n j.ownr_ph1,\n
|
||||||
|
\ j.special_coverage_policy,\n j.production_vars,\n lab.labhrs,\n lar.larhrs,\n
|
||||||
|
\ j.shopid,\n parts.partcount\n FROM (((jobs j\n LEFT JOIN ( SELECT
|
||||||
|
l.jobid,\n sum(l.mod_lb_hrs) AS labhrs\n FROM joblines
|
||||||
|
l\n WHERE (l.mod_lbr_ty = 'LAB'::text)\n GROUP BY l.jobid)
|
||||||
|
lab ON ((lab.jobid = j.id)))\n LEFT JOIN ( SELECT l2.jobid,\n sum(l2.mod_lb_hrs)
|
||||||
|
AS larhrs\n FROM joblines l2\n WHERE (l2.mod_lbr_ty = 'LAR'::text)\n
|
||||||
|
\ GROUP BY l2.jobid) lar ON ((lar.jobid = j.id)))\n LEFT JOIN (
|
||||||
|
SELECT l3.jobid,\n json_agg(l3.status) AS partcount\n FROM
|
||||||
|
joblines l3\n where l3.part_type IS NOT NULL\n GROUP BY l3.jobid)
|
||||||
|
parts ON ((parts.jobid = j.id)))\n WHERE (j.inproduction = true);"
|
||||||
|
type: run_sql
|
||||||
@@ -439,6 +439,7 @@ tables:
|
|||||||
- federal_tax_id
|
- federal_tax_id
|
||||||
- id
|
- id
|
||||||
- insurance_vendor_id
|
- insurance_vendor_id
|
||||||
|
- invoice_tax_rates
|
||||||
- logo_img_path
|
- logo_img_path
|
||||||
- md_order_statuses
|
- md_order_statuses
|
||||||
- md_responsibility_centers
|
- md_responsibility_centers
|
||||||
@@ -474,6 +475,7 @@ tables:
|
|||||||
- federal_tax_id
|
- federal_tax_id
|
||||||
- id
|
- id
|
||||||
- insurance_vendor_id
|
- insurance_vendor_id
|
||||||
|
- invoice_tax_rates
|
||||||
- logo_img_path
|
- logo_img_path
|
||||||
- md_order_statuses
|
- md_order_statuses
|
||||||
- md_responsibility_centers
|
- md_responsibility_centers
|
||||||
@@ -1080,28 +1082,32 @@ tables:
|
|||||||
- active:
|
- active:
|
||||||
_eq: true
|
_eq: true
|
||||||
columns:
|
columns:
|
||||||
- id
|
|
||||||
- created_at
|
|
||||||
- updated_at
|
|
||||||
- invoiceid
|
|
||||||
- line_desc
|
|
||||||
- actual_price
|
|
||||||
- actual_cost
|
- actual_cost
|
||||||
|
- actual_price
|
||||||
|
- applicable_taxes
|
||||||
- cost_center
|
- cost_center
|
||||||
|
- created_at
|
||||||
|
- id
|
||||||
|
- invoiceid
|
||||||
- joblineid
|
- joblineid
|
||||||
|
- line_desc
|
||||||
|
- quantity
|
||||||
|
- updated_at
|
||||||
select_permissions:
|
select_permissions:
|
||||||
- role: user
|
- role: user
|
||||||
permission:
|
permission:
|
||||||
columns:
|
columns:
|
||||||
- actual_cost
|
- actual_cost
|
||||||
- actual_price
|
- actual_price
|
||||||
|
- applicable_taxes
|
||||||
- cost_center
|
- cost_center
|
||||||
- line_desc
|
|
||||||
- created_at
|
- created_at
|
||||||
- updated_at
|
|
||||||
- joblineid
|
|
||||||
- id
|
- id
|
||||||
- invoiceid
|
- invoiceid
|
||||||
|
- joblineid
|
||||||
|
- line_desc
|
||||||
|
- quantity
|
||||||
|
- updated_at
|
||||||
filter:
|
filter:
|
||||||
invoice:
|
invoice:
|
||||||
job:
|
job:
|
||||||
@@ -1119,13 +1125,15 @@ tables:
|
|||||||
columns:
|
columns:
|
||||||
- actual_cost
|
- actual_cost
|
||||||
- actual_price
|
- actual_price
|
||||||
|
- applicable_taxes
|
||||||
- cost_center
|
- cost_center
|
||||||
- line_desc
|
|
||||||
- created_at
|
- created_at
|
||||||
- updated_at
|
|
||||||
- joblineid
|
|
||||||
- id
|
- id
|
||||||
- invoiceid
|
- invoiceid
|
||||||
|
- joblineid
|
||||||
|
- line_desc
|
||||||
|
- quantity
|
||||||
|
- updated_at
|
||||||
filter:
|
filter:
|
||||||
invoice:
|
invoice:
|
||||||
job:
|
job:
|
||||||
@@ -1190,33 +1198,39 @@ tables:
|
|||||||
- active:
|
- active:
|
||||||
_eq: true
|
_eq: true
|
||||||
columns:
|
columns:
|
||||||
- id
|
|
||||||
- created_at
|
- created_at
|
||||||
- updated_at
|
|
||||||
- vendorid
|
|
||||||
- jobid
|
|
||||||
- date
|
- date
|
||||||
- due_date
|
- due_date
|
||||||
- exported
|
- exported
|
||||||
- exported_at
|
- exported_at
|
||||||
- is_credit_memo
|
- federal_tax_rate
|
||||||
- total
|
- id
|
||||||
- invoice_number
|
- invoice_number
|
||||||
|
- is_credit_memo
|
||||||
|
- jobid
|
||||||
|
- local_tax_rate
|
||||||
|
- state_tax_rate
|
||||||
|
- total
|
||||||
|
- updated_at
|
||||||
|
- vendorid
|
||||||
select_permissions:
|
select_permissions:
|
||||||
- role: user
|
- role: user
|
||||||
permission:
|
permission:
|
||||||
columns:
|
columns:
|
||||||
- exported
|
- created_at
|
||||||
- is_credit_memo
|
|
||||||
- date
|
- date
|
||||||
- due_date
|
- due_date
|
||||||
- total
|
- exported
|
||||||
- invoice_number
|
|
||||||
- created_at
|
|
||||||
- exported_at
|
- exported_at
|
||||||
- updated_at
|
- federal_tax_rate
|
||||||
- id
|
- id
|
||||||
|
- invoice_number
|
||||||
|
- is_credit_memo
|
||||||
- jobid
|
- jobid
|
||||||
|
- local_tax_rate
|
||||||
|
- state_tax_rate
|
||||||
|
- total
|
||||||
|
- updated_at
|
||||||
- vendorid
|
- vendorid
|
||||||
filter:
|
filter:
|
||||||
job:
|
job:
|
||||||
@@ -1232,17 +1246,20 @@ tables:
|
|||||||
- role: user
|
- role: user
|
||||||
permission:
|
permission:
|
||||||
columns:
|
columns:
|
||||||
- exported
|
- created_at
|
||||||
- is_credit_memo
|
|
||||||
- date
|
- date
|
||||||
- due_date
|
- due_date
|
||||||
- total
|
- exported
|
||||||
- invoice_number
|
|
||||||
- created_at
|
|
||||||
- exported_at
|
- exported_at
|
||||||
- updated_at
|
- federal_tax_rate
|
||||||
- id
|
- id
|
||||||
|
- invoice_number
|
||||||
|
- is_credit_memo
|
||||||
- jobid
|
- jobid
|
||||||
|
- local_tax_rate
|
||||||
|
- state_tax_rate
|
||||||
|
- total
|
||||||
|
- updated_at
|
||||||
- vendorid
|
- vendorid
|
||||||
filter:
|
filter:
|
||||||
job:
|
job:
|
||||||
|
|||||||
Reference in New Issue
Block a user