Hasura Migrations for parts order, parts order line objects. Fixed error on whiteboard component card.

This commit is contained in:
Patrick Fic
2020-01-07 14:06:41 -08:00
parent 62e71dfa5b
commit e65273f2b6
39 changed files with 732 additions and 20 deletions

View File

@@ -31,32 +31,33 @@ export default function WhiteBoardCard({ metadata }) {
const menu = (
<Menu>
<Menu.Item key="images">
<Icon type="file-image" />
<Menu.Item key='images'>
<Icon type='file-image' />
{t("jobs.actions.viewJobImages")}
</Menu.Item>
<Menu.Item key="printing">
<Icon type="printer" />
<Menu.Item key='printing'>
<Icon type='printer' />
{t("jobs.actions.printCenter")}
</Menu.Item>
<Menu.Item key="notes">
<Icon type="edit" />
<Menu.Item key='notes'>
<Icon type='edit' />
{t("jobs.actions.notes")}
</Menu.Item>
<Menu.Item key="postinvoices">
<Icon type="shopping-cart" />
<Menu.Item key='postinvoices'>
<Icon type='shopping-cart' />
{t("jobs.actions.postInvoices")}
</Menu.Item>
<Menu.Item key="receiveparts">
<Icon type="inbox" />
<Menu.Item key='receiveparts'>
<Icon type='inbox' />
{t("jobs.actions.receiveParts")}
</Menu.Item>
<Menu.Item key="partstatus">
<Icon type="tool" />
<Menu.Item key='partstatus'>
<Icon type='tool' />
{t("jobs.actions.partStatus")}
</Menu.Item>
</Menu>
);
return (
<div>
@@ -72,17 +73,16 @@ export default function WhiteBoardCard({ metadata }) {
bodyStyle={{ padding: 10 }}
actions={[
<Link to={`/manage/jobs/${metadata.id}`}>
<Icon type="eye" key="view" />
<Icon type='eye' key='view' />
</Link>,
<Icon type="message" key="message" />,
<Icon type='message' key='message' />,
<Dropdown overlay={menu} trigger={["click"]}>
<Icon type="ellipsis" />
<Icon type='ellipsis' />
</Dropdown>
]}
>
]}>
<Row>
<Col span={6}>
<Avatar size="large" alt="Vehicle Image" src={CarImage} />
<Avatar size='large' alt='Vehicle Image' src={CarImage} />
</Col>
<Col span={18}>
<Row>
@@ -104,11 +104,11 @@ export default function WhiteBoardCard({ metadata }) {
<Row>
<Col span={12}>
{t("general.labels.in")}:
<Moment format="MM/DD/YYYY">{metadata.actual_in}</Moment>
<Moment format='MM/DD/YYYY'>{metadata.actual_in}</Moment>
</Col>
<Col span={12}>
{t("general.labels.out")}:
<Moment format="MM/DD/YYYY">{metadata.scheduled_completion}</Moment>
<Moment format='MM/DD/YYYY'>{metadata.scheduled_completion}</Moment>
</Col>
</Row>
</Card>

View File

@@ -5,6 +5,10 @@ import { auth } from "../firebase/firebase.utils";
const errorLink = onError(
({ graphQLErrors, networkError, operation, forward }) => {
let access_token = window.localStorage.getItem("token");
console.log("graphQLErrors", graphQLErrors);
console.log("networkError", networkError);
console.log("operation", operation);
console.log("forward", forward);
if (graphQLErrors) {
// User access token has expired
if (graphQLErrors[0].message.includes("JWTExpired")) {

View File

@@ -0,0 +1,3 @@
- args:
sql: DROP TABLE "public"."vendors"
type: run_sql

View File

@@ -0,0 +1,23 @@
- args:
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
sql: "CREATE TABLE \"public\".\"vendors\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"bodyshopid\" uuid NOT NULL, \"name\" text NOT NULL,
\"street1\" text, \"street2\" text, \"city\" text, \"state\" text, \"zip\" text,
\"country\" text, \"email\" text, \"taxid\" text, \"discount\" numeric NOT NULL
DEFAULT 0, \"prompt_discount\" numeric NOT NULL DEFAULT 0, \"due_date\" integer,
\"terms\" text, \"display_name\" text, PRIMARY KEY (\"id\") , FOREIGN KEY (\"bodyshopid\")
REFERENCES \"public\".\"bodyshops\"(\"id\") ON UPDATE cascade ON DELETE cascade);\nCREATE
OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS
TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\"
= NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_vendors_updated_at\"\nBEFORE
UPDATE ON \"public\".\"vendors\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_vendors_updated_at\" ON \"public\".\"vendors\" \nIS
'trigger to set value of column \"updated_at\" to current timestamp on row update';\n"
type: run_sql
- args:
name: vendors
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,12 @@
- args:
relationship: vendors
table:
name: bodyshops
schema: public
type: drop_relationship
- args:
relationship: bodyshop
table:
name: vendors
schema: public
type: drop_relationship

View File

@@ -0,0 +1,20 @@
- args:
name: vendors
table:
name: bodyshops
schema: public
using:
foreign_key_constraint_on:
column: bodyshopid
table:
name: vendors
schema: public
type: create_array_relationship
- args:
name: bodyshop
table:
name: vendors
schema: public
using:
foreign_key_constraint_on: bodyshopid
type: create_object_relationship

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: vendors
schema: public
type: drop_insert_permission

View File

@@ -0,0 +1,40 @@
- args:
permission:
allow_upsert: true
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- due_date
- discount
- prompt_discount
- city
- country
- display_name
- email
- name
- state
- street1
- street2
- taxid
- terms
- zip
- created_at
- updated_at
- bodyshopid
- id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: vendors
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: vendors
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,37 @@
- args:
permission:
allow_aggregations: false
columns:
- due_date
- discount
- prompt_discount
- city
- country
- display_name
- email
- name
- state
- street1
- street2
- taxid
- terms
- zip
- created_at
- updated_at
- bodyshopid
- id
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: vendors
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: vendors
schema: public
type: drop_update_permission

View File

@@ -0,0 +1,39 @@
- args:
permission:
columns:
- due_date
- discount
- prompt_discount
- city
- country
- display_name
- email
- name
- state
- street1
- street2
- taxid
- terms
- zip
- created_at
- updated_at
- bodyshopid
- id
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: vendors
schema: public
type: create_update_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: vendors
schema: public
type: drop_delete_permission

View File

@@ -0,0 +1,16 @@
- args:
permission:
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: vendors
schema: public
type: create_delete_permission

View File

@@ -0,0 +1,3 @@
- args:
sql: DROP TABLE "public"."parts_order"
type: run_sql

View File

@@ -0,0 +1,25 @@
- args:
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
sql: "CREATE TABLE \"public\".\"parts_order\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"jobid\" uuid NOT NULL, \"vendorid\" uuid NOT NULL,
\"order_number\" text NOT NULL, \"order_date\" date NOT NULL DEFAULT now(),
\"ordered_by_user_id\" text NOT NULL, \"status\" text NOT NULL, \"deliver_by\"
date, PRIMARY KEY (\"id\") , FOREIGN KEY (\"jobid\") REFERENCES \"public\".\"jobs\"(\"id\")
ON UPDATE cascade ON DELETE cascade, FOREIGN KEY (\"vendorid\") REFERENCES \"public\".\"vendors\"(\"id\")
ON UPDATE restrict ON DELETE restrict, FOREIGN KEY (\"ordered_by_user_id\")
REFERENCES \"public\".\"users\"(\"email\") ON UPDATE restrict ON DELETE restrict);\nCREATE
OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS
TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\"
= NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_parts_order_updated_at\"\nBEFORE
UPDATE ON \"public\".\"parts_order\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_parts_order_updated_at\" ON \"public\".\"parts_order\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';\n"
type: run_sql
- args:
name: parts_order
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,36 @@
- args:
relationship: parts_orders
table:
name: jobs
schema: public
type: drop_relationship
- args:
relationship: user
table:
name: parts_order
schema: public
type: drop_relationship
- args:
relationship: job
table:
name: parts_order
schema: public
type: drop_relationship
- args:
relationship: vendor
table:
name: parts_order
schema: public
type: drop_relationship
- args:
relationship: parts_orders
table:
name: users
schema: public
type: drop_relationship
- args:
relationship: parts_orders
table:
name: vendors
schema: public
type: drop_relationship

View File

@@ -0,0 +1,60 @@
- args:
name: parts_orders
table:
name: jobs
schema: public
using:
foreign_key_constraint_on:
column: jobid
table:
name: parts_order
schema: public
type: create_array_relationship
- args:
name: user
table:
name: parts_order
schema: public
using:
foreign_key_constraint_on: ordered_by_user_id
type: create_object_relationship
- args:
name: job
table:
name: parts_order
schema: public
using:
foreign_key_constraint_on: jobid
type: create_object_relationship
- args:
name: vendor
table:
name: parts_order
schema: public
using:
foreign_key_constraint_on: vendorid
type: create_object_relationship
- args:
name: parts_orders
table:
name: users
schema: public
using:
foreign_key_constraint_on:
column: ordered_by_user_id
table:
name: parts_order
schema: public
type: create_array_relationship
- args:
name: parts_orders
table:
name: vendors
schema: public
using:
foreign_key_constraint_on:
column: vendorid
table:
name: parts_order
schema: public
type: create_array_relationship

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: parts_order
schema: public
type: drop_insert_permission

View File

@@ -0,0 +1,33 @@
- args:
permission:
allow_upsert: true
check:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- deliver_by
- order_date
- ordered_by_user_id
- order_number
- status
- created_at
- updated_at
- id
- jobid
- vendorid
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: parts_order
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: parts_order
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,30 @@
- args:
permission:
allow_aggregations: false
columns:
- deliver_by
- order_date
- ordered_by_user_id
- order_number
- status
- created_at
- updated_at
- id
- jobid
- vendorid
filter:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: parts_order
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: parts_order
schema: public
type: drop_update_permission

View File

@@ -0,0 +1,32 @@
- args:
permission:
columns:
- deliver_by
- order_date
- ordered_by_user_id
- order_number
- status
- created_at
- updated_at
- id
- jobid
- vendorid
filter:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: parts_order
schema: public
type: create_update_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: parts_order
schema: public
type: drop_delete_permission

View File

@@ -0,0 +1,17 @@
- args:
permission:
filter:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: parts_order
schema: public
type: create_delete_permission

View File

@@ -0,0 +1,3 @@
- args:
sql: DROP TABLE "public"."parts_order_lines"
type: run_sql

View File

@@ -0,0 +1,24 @@
- args:
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
sql: "CREATE TABLE \"public\".\"parts_order_lines\"(\"id\" uuid NOT NULL DEFAULT
gen_random_uuid(), \"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\"
timestamptz NOT NULL DEFAULT now(), \"orderid\" uuid NOT NULL, \"job_line_id\"
uuid, \"line_desc\" text NOT NULL, \"oem_partno\" text, \"db_price\" numeric,
\"act_price\" numeric, \"status\" text NOT NULL DEFAULT 'Ordered', \"line_remarks\"
text, PRIMARY KEY (\"id\") , FOREIGN KEY (\"orderid\") REFERENCES \"public\".\"parts_order\"(\"id\")
ON UPDATE cascade ON DELETE cascade, FOREIGN KEY (\"job_line_id\") REFERENCES
\"public\".\"joblines\"(\"id\") ON UPDATE restrict ON DELETE set null);\nCREATE
OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS
TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\"
= NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_parts_order_lines_updated_at\"\nBEFORE
UPDATE ON \"public\".\"parts_order_lines\"\nFOR EACH ROW\nEXECUTE PROCEDURE
\"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT ON TRIGGER \"set_public_parts_order_lines_updated_at\"
ON \"public\".\"parts_order_lines\" \nIS 'trigger to set value of column \"updated_at\"
to current timestamp on row update';\n"
type: run_sql
- args:
name: parts_order_lines
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,24 @@
- args:
relationship: parts_order_lines
table:
name: joblines
schema: public
type: drop_relationship
- args:
relationship: parts_order_lines
table:
name: parts_order
schema: public
type: drop_relationship
- args:
relationship: jobline
table:
name: parts_order_lines
schema: public
type: drop_relationship
- args:
relationship: parts_order
table:
name: parts_order_lines
schema: public
type: drop_relationship

View File

@@ -0,0 +1,40 @@
- args:
name: parts_order_lines
table:
name: joblines
schema: public
using:
foreign_key_constraint_on:
column: job_line_id
table:
name: parts_order_lines
schema: public
type: create_array_relationship
- args:
name: parts_order_lines
table:
name: parts_order
schema: public
using:
foreign_key_constraint_on:
column: orderid
table:
name: parts_order_lines
schema: public
type: create_array_relationship
- args:
name: jobline
table:
name: parts_order_lines
schema: public
using:
foreign_key_constraint_on: job_line_id
type: create_object_relationship
- args:
name: parts_order
table:
name: parts_order_lines
schema: public
using:
foreign_key_constraint_on: orderid
type: create_object_relationship

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: parts_order_lines
schema: public
type: drop_insert_permission

View File

@@ -0,0 +1,35 @@
- args:
permission:
allow_upsert: true
check:
parts_order:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- orderid
- job_line_id
- line_desc
- oem_partno
- db_price
- act_price
- status
- line_remarks
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: parts_order_lines
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: parts_order_lines
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,32 @@
- args:
permission:
allow_aggregations: false
columns:
- act_price
- db_price
- line_desc
- line_remarks
- oem_partno
- status
- created_at
- updated_at
- id
- job_line_id
- orderid
filter:
parts_order:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: parts_order_lines
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: parts_order_lines
schema: public
type: drop_update_permission

View File

@@ -0,0 +1,34 @@
- args:
permission:
columns:
- act_price
- db_price
- line_desc
- line_remarks
- oem_partno
- status
- created_at
- updated_at
- id
- job_line_id
- orderid
filter:
parts_order:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: parts_order_lines
schema: public
type: create_update_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: parts_order_lines
schema: public
type: drop_delete_permission

View File

@@ -0,0 +1,18 @@
- args:
permission:
filter:
parts_order:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: parts_order_lines
schema: public
type: create_delete_permission