In progress changes for Kanban Board and updated schema migrations. Performed some cleanup.

This commit is contained in:
Patrick Fic
2019-12-17 16:21:17 -08:00
parent 03d99a27c3
commit c5ae3224ba
27 changed files with 896 additions and 89 deletions

11
apollo.config.js Normal file
View File

@@ -0,0 +1,11 @@
module.exports = {
client: {
service: {
name: "Dev",
url: "https://bodyshop-dev-db.herokuapp.com/v1/graphql",
headers: {
"x-hasura-admin-secret": "Dev-BodyShopAppBySnaptSoftware!"
}
}
}
};

View File

@@ -15,6 +15,7 @@ import Unauthorized from "../pages/unauthorized/unauthorized.component";
import { auth } from "../firebase/firebase.utils";
import { UPSERT_USER } from "../graphql/user.queries";
import { GET_CURRENT_USER } from "../graphql/local.queries";
import { QUERY_BODYSHOP } from "../graphql/bodyshop.queries";
import LoadingSpinner from "../components/loading-spinner/loading-spinner.component";
import AlertComponent from "../components/alert/alert.component";
@@ -42,18 +43,6 @@ export default () => {
});
}
apolloClient.writeData({
data: {
currentUser: {
email: user.email,
displayName: user.displayName,
token,
uid: user.uid,
photoUrl: user.photoURL,
__typename: "currentUser"
}
}
});
//add the bearer token to the headers.
localStorage.setItem("token", token);
@@ -66,6 +55,36 @@ export default () => {
.catch(error => {
console.log("Upsert error!!!!", error);
});
apolloClient
.query({
query: QUERY_BODYSHOP,
fetchPolicy: "network-only"
})
.then(r => {
const bodyShopData = r.data.bodyshops[0];
apolloClient.writeData({
data: {
bodyShopData: { ...bodyShopData, __typename: "bodyShopData" }
}
});
})
.catch(error => {
console.log("Error getting bodyshop data.", error);
});
apolloClient.writeData({
data: {
currentUser: {
email: user.email,
displayName: user.displayName,
token,
uid: user.uid,
photoUrl: user.photoURL,
__typename: "currentUser"
}
}
});
} else {
apolloClient.writeData({ data: { currentUser: null } });
localStorage.removeItem("token");

View File

@@ -35,10 +35,11 @@ export default function JobLinesComponent({ loading, joblines }) {
setState({ ...state, filteredInfo: filters, sortedInfo: sorter });
};
const handleChange = event => {
const { value } = event.target;
setState({ ...state, filterinfo: { text: [value] } });
};
// const handleChange = event => {
// const { value } = event.target;
// setState({ ...state, filterinfo: { text: [value] } });
// };
console.log('joblines', joblines)
return (
<Table

View File

@@ -0,0 +1,22 @@
import React from "react";
import Board from "react-trello";
import WhiteBoardCard from "../white-board-card/white-board-card.component";
export default function WhiteBoardKanBan({ data, eventBus }) {
const setEventBus = handle => {
eventBus = handle;
};
return (
<Board
tagStyle={{ fontSize: "80%" }}
data={data}
draggable
eventBusHandle={setEventBus}
components={{ Card: WhiteBoardCard }}
onCardClick={(cardId, metadata) =>
alert(`Card with id:${cardId} clicked. Has metadata.id: ${metadata.id}`)
}
/>
);
}

View File

@@ -0,0 +1,57 @@
import React from "react";
import { useSubscription, useQuery } from "@apollo/react-hooks";
import { SUBSCRIPTION_JOBS_IN_PRODUCTION } from "../../graphql/jobs.queries";
import { GET_BODYSHOP } from "../../graphql/local.queries";
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
import Alert from "../../components/alert/alert.component";
import WhiteBoardKanBan from "./white-board-kanban.component";
export default function WhiteBoardKanBanContainer() {
// const HookBodyshopData = useQuery(GET_BODYSHOP);
const { loading, error, data } = useSubscription(
SUBSCRIPTION_JOBS_IN_PRODUCTION,
{
fetchPolicy: "network-only"
}
);
const static_data = {
lanes: [
{
id: "lane1",
title: "Planned Tasks",
label: "2/2",
cards: [
{
id: "Card1",
title: "Write Blog",
description: "Can AI make memes",
label: "30 mins"
},
{
id: "Card2",
title: "Pay Rent",
description: "Transfer via NEFT",
label: "5 mins",
metadata: { sha: "be312a1" }
}
]
},
{
id: "lane2",
title: "Completed",
label: "0/0",
cards: []
}
]
};
// if (HookBodyshopData.loading) return "Local query loading";
// if (HookBodyshopData.error) return "Local query error" + error.message;
// console.log("HookBodyshopData.data", HookBodyshopData.data);
if (loading) return <LoadingSpinner />;
if (error) return <Alert message={error.message} />;
let eventBus;
console.log("Sub data", data);
return <WhiteBoardKanBan eventBus={eventBus} data={static_data} />;
}

View File

@@ -1,20 +1,7 @@
import React from "react";
import { Query } from "react-apollo";
import WhiteBoardLeftSiderComponent from "./white-board-left-sider.component";
import Spin from "../loading-spinner/loading-spinner.component";
import { GET_WHITE_BOARD_LEFT_SIDER_VISIBLE } from "../../graphql/local.queries";
export default function WhiteBoardPageContainer() {
return (
<Query query={GET_WHITE_BOARD_LEFT_SIDER_VISIBLE}>
{({ loading, error, data: { whiteBoardLeftSiderVisible } }) => {
if (loading) return <Spin />;
if (error) return error.message;
return (
<WhiteBoardLeftSiderComponent visible={whiteBoardLeftSiderVisible} />
);
}}
</Query>
);
return <WhiteBoardLeftSiderComponent />;
}

View File

@@ -0,0 +1,24 @@
import { gql } from "apollo-boost";
export const QUERY_BODYSHOP = gql`
query QUERY_BODYSHOP {
bodyshops(where: { associations: { active: { _eq: true } } }) {
address1
address2
city
country
created_at
email
federal_tax_id
id
insurance_vendor_id
logo_img_path
md_ro_statuses
shopname
state
state_tax_id
updated_at
zip_post
}
}
`;

View File

@@ -3,5 +3,5 @@ export default {
currentUser: null,
selectedNavItem: "Home",
recentItems: [],
whiteBoardLeftSiderVisible: true
bodyShopData: null
};

View File

@@ -47,6 +47,54 @@ export const SUBSCRIPTION_ALL_OPEN_JOBS = gql`
}
`;
export const QUERY_JOBS_IN_PRODUCTION = gql`
query QUERY_JOBS_IN_PRODUCTION {
jobs {
id
updated_at
est_number
ro_number
status
scheduled_completion
scheduled_delivery
vehicle {
v_model_yr
v_make_desc
v_model_desc
plate_no
}
owner {
first_name
last_name
}
}
}
`;
export const SUBSCRIPTION_JOBS_IN_PRODUCTION = gql`
subscription SUBSCRIPTION_JOBS_IN_PRODUCTION {
jobs {
id
updated_at
est_number
ro_number
status
scheduled_completion
scheduled_delivery
vehicle {
v_model_yr
v_make_desc
v_model_desc
plate_no
}
owner {
first_name
last_name
}
}
}
`;
export const GET_JOB_BY_PK = gql`
query GET_JOB_BY_PK($id: uuid!) {
jobs_by_pk(id: $id) {

View File

@@ -31,3 +31,11 @@ export const GET_WHITE_BOARD_LEFT_SIDER_VISIBLE = gql`
whiteBoardLeftSiderVisible @client
}
`;
export const GET_BODYSHOP = gql`
query LOCAL_GET_BODY_SHOP {
bodyShopData @client {
shopname
}
}
`;

View File

@@ -1,11 +1,10 @@
import React from "react";
import { useSubscription } from "@apollo/react-hooks";
import AlertComponent from "../../components/alert/alert.component";
import { Col } from "antd";
import { SUBSCRIPTION_ALL_OPEN_JOBS } from "../../graphql/jobs.queries";
import JobsList from "../../components/jobs-list/jobs-list.component";
import Test from "./test";
export default function JobsPage() {
const { loading, error, data } = useSubscription(SUBSCRIPTION_ALL_OPEN_JOBS, {
@@ -15,9 +14,8 @@ export default function JobsPage() {
if (error) return <AlertComponent message={error.message} />;
return (
<div>
<Col span={22} offset={1}>
<JobsList loading={loading} jobs={data ? data.jobs : null} />
<Test />
</div>
</Col>
);
}

View File

@@ -8,7 +8,7 @@ import JobsDetailPage from "../jobs-detail/jobs-detail.page";
import HeaderContainer from "../../components/header/header.container";
import FooterComponent from "../../components/footer/footer.component";
import { Layout, BackTop, Col } from "antd";
import { Layout, BackTop } from "antd";
const { Header, Content, Footer } = Layout;
//This page will handle all routing for the entire application.
@@ -20,15 +20,10 @@ export default function Manage({ match }) {
</Header>
<Content>
<Col span={22} offset={1}>
<Route exact path={`${match.path}`} component={WhiteBoardPage} />
<Route exact path={`${match.path}`} component={WhiteBoardPage} />
<Route exact path={`${match.path}/jobs`} component={JobsPage} />
<Route
path={`${match.path}/jobs/:jobId`}
component={JobsDetailPage}
/>
</Col>
<Route exact path={`${match.path}/jobs`} component={JobsPage} />
<Route path={`${match.path}/jobs/:jobId`} component={JobsDetailPage} />
</Content>
<Footer>

View File

@@ -1,41 +1,10 @@
import React from "react";
import Board from "react-trello";
import WhiteBoardCard from "../../components/white-board-card/white-board-card.component";
import WhiteBoardLeftSiderContainer from "../../components/white-board-left-sider/white-board-left-sider.container";
import WhiteBoardKanBanContainer from "../../components/white-board-kanban/white-board-kanban.container";
import { Layout } from "antd";
export default function WhiteBoardPage({ whiteBoardLeftSiderVisible }) {
const data = {
lanes: [
{
id: "lane1",
title: "Planned Tasks",
label: "2/2",
cards: [
{
id: "Card1",
title: "Write Blog",
description: "Can AI make memes",
label: "30 mins"
},
{
id: "Card2",
title: "Pay Rent",
description: "Transfer via NEFT",
label: "5 mins",
metadata: { sha: "be312a1" }
}
]
},
{
id: "lane2",
title: "Completed",
label: "0/0",
cards: []
}
]
};
const { Sider, Content } = Layout;
return (
<Layout>
@@ -54,17 +23,7 @@ export default function WhiteBoardPage({ whiteBoardLeftSiderVisible }) {
</Sider>
<Content>
<Board
tagStyle={{ fontSize: "80%" }}
data={data}
draggable
components={{ Card: WhiteBoardCard }}
onCardClick={(cardId, metadata) =>
alert(
`Card with id:${cardId} clicked. Has metadata.id: ${metadata.id}`
)
}
/>
<WhiteBoardKanBanContainer />
</Content>
</Layout>
);

View File

@@ -0,0 +1,3 @@
- args:
sql: ALTER TABLE "public"."jobs" DROP COLUMN "inproduction";
type: run_sql

View File

@@ -0,0 +1,4 @@
- args:
sql: ALTER TABLE "public"."jobs" ADD COLUMN "inproduction" boolean NOT NULL DEFAULT
false;
type: run_sql

View File

@@ -0,0 +1,84 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_insert_permission
- args:
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- actual_completion
- actual_delivery
- actual_in
- claim_total
- created_at
- deductible
- est_addr1
- est_addr2
- est_city
- est_co_nm
- est_ct_fn
- est_ct_ln
- est_ctry
- est_ea
- est_number
- est_ph1
- est_st
- est_zip
- federal_tax_rate
- invoice_date
- labor_rate_desc
- labor_rate_id
- local_tax_rate
- ownerid
- rate_atp
- rate_la1
- rate_la2
- rate_la3
- rate_la4
- rate_lab
- rate_lad
- rate_lae
- rate_laf
- rate_lag
- rate_lam
- rate_lar
- rate_las
- rate_lau
- rate_ma2s
- rate_ma2t
- rate_ma3s
- rate_mabl
- rate_macs
- rate_mahw
- rate_mapa
- rate_mash
- rate_matd
- regie_number
- ro_number
- scheduled_completion
- scheduled_delivery
- scheduled_in
- shopid
- state_tax_rate
- status
- updated_at
- vehicleid
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: jobs
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,85 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_insert_permission
- args:
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- actual_completion
- actual_delivery
- actual_in
- claim_total
- created_at
- deductible
- est_addr1
- est_addr2
- est_city
- est_co_nm
- est_ct_fn
- est_ct_ln
- est_ctry
- est_ea
- est_number
- est_ph1
- est_st
- est_zip
- federal_tax_rate
- inproduction
- invoice_date
- labor_rate_desc
- labor_rate_id
- local_tax_rate
- ownerid
- rate_atp
- rate_la1
- rate_la2
- rate_la3
- rate_la4
- rate_lab
- rate_lad
- rate_lae
- rate_laf
- rate_lag
- rate_lam
- rate_lar
- rate_las
- rate_lau
- rate_ma2s
- rate_ma2t
- rate_ma3s
- rate_mabl
- rate_macs
- rate_mahw
- rate_mapa
- rate_mash
- rate_matd
- regie_number
- ro_number
- scheduled_completion
- scheduled_delivery
- scheduled_in
- shopid
- state_tax_rate
- status
- updated_at
- vehicleid
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: jobs
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,83 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- actual_completion
- actual_delivery
- actual_in
- claim_total
- created_at
- deductible
- est_addr1
- est_addr2
- est_city
- est_co_nm
- est_ct_fn
- est_ct_ln
- est_ctry
- est_ea
- est_number
- est_ph1
- est_st
- est_zip
- federal_tax_rate
- id
- invoice_date
- labor_rate_desc
- labor_rate_id
- local_tax_rate
- ownerid
- rate_atp
- rate_la1
- rate_la2
- rate_la3
- rate_la4
- rate_lab
- rate_lad
- rate_lae
- rate_laf
- rate_lag
- rate_lam
- rate_lar
- rate_las
- rate_lau
- rate_ma2s
- rate_ma2t
- rate_ma3s
- rate_mabl
- rate_macs
- rate_mahw
- rate_mapa
- rate_mash
- rate_matd
- regie_number
- ro_number
- scheduled_completion
- scheduled_delivery
- scheduled_in
- shopid
- state_tax_rate
- status
- updated_at
- vehicleid
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: jobs
schema: public
type: create_select_permission

View File

@@ -0,0 +1,84 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- actual_completion
- actual_delivery
- actual_in
- claim_total
- created_at
- deductible
- est_addr1
- est_addr2
- est_city
- est_co_nm
- est_ct_fn
- est_ct_ln
- est_ctry
- est_ea
- est_number
- est_ph1
- est_st
- est_zip
- federal_tax_rate
- id
- inproduction
- invoice_date
- labor_rate_desc
- labor_rate_id
- local_tax_rate
- ownerid
- rate_atp
- rate_la1
- rate_la2
- rate_la3
- rate_la4
- rate_lab
- rate_lad
- rate_lae
- rate_laf
- rate_lag
- rate_lam
- rate_lar
- rate_las
- rate_lau
- rate_ma2s
- rate_ma2t
- rate_ma3s
- rate_mabl
- rate_macs
- rate_mahw
- rate_mapa
- rate_mash
- rate_matd
- regie_number
- ro_number
- scheduled_completion
- scheduled_delivery
- scheduled_in
- shopid
- state_tax_rate
- status
- updated_at
- vehicleid
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: jobs
schema: public
type: create_select_permission

View File

@@ -0,0 +1,84 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_update_permission
- args:
permission:
columns:
- actual_completion
- actual_delivery
- actual_in
- claim_total
- created_at
- deductible
- est_addr1
- est_addr2
- est_city
- est_co_nm
- est_ct_fn
- est_ct_ln
- est_ctry
- est_ea
- est_number
- est_ph1
- est_st
- est_zip
- federal_tax_rate
- invoice_date
- labor_rate_desc
- labor_rate_id
- local_tax_rate
- ownerid
- rate_atp
- rate_la1
- rate_la2
- rate_la3
- rate_la4
- rate_lab
- rate_lad
- rate_lae
- rate_laf
- rate_lag
- rate_lam
- rate_lar
- rate_las
- rate_lau
- rate_ma2s
- rate_ma2t
- rate_ma3s
- rate_mabl
- rate_macs
- rate_mahw
- rate_mapa
- rate_mash
- rate_matd
- regie_number
- ro_number
- scheduled_completion
- scheduled_delivery
- scheduled_in
- shopid
- state_tax_rate
- status
- updated_at
- vehicleid
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: jobs
schema: public
type: create_update_permission

View File

@@ -0,0 +1,85 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_update_permission
- args:
permission:
columns:
- actual_completion
- actual_delivery
- actual_in
- claim_total
- created_at
- deductible
- est_addr1
- est_addr2
- est_city
- est_co_nm
- est_ct_fn
- est_ct_ln
- est_ctry
- est_ea
- est_number
- est_ph1
- est_st
- est_zip
- federal_tax_rate
- inproduction
- invoice_date
- labor_rate_desc
- labor_rate_id
- local_tax_rate
- ownerid
- rate_atp
- rate_la1
- rate_la2
- rate_la3
- rate_la4
- rate_lab
- rate_lad
- rate_lae
- rate_laf
- rate_lag
- rate_lam
- rate_lar
- rate_las
- rate_lau
- rate_ma2s
- rate_ma2t
- rate_ma3s
- rate_mabl
- rate_macs
- rate_mahw
- rate_mapa
- rate_mash
- rate_matd
- regie_number
- ro_number
- scheduled_completion
- scheduled_delivery
- scheduled_in
- shopid
- state_tax_rate
- status
- updated_at
- vehicleid
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: jobs
schema: public
type: create_update_permission

View File

@@ -0,0 +1,3 @@
- args:
sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "md_ro_statuses";
type: run_sql

View File

@@ -0,0 +1,3 @@
- args:
sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "md_ro_statuses" jsonb NULL;
type: run_sql

View File

@@ -0,0 +1,39 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- id
- shopname
- created_at
- updated_at
- address1
- address2
- city
- state
- zip_post
- country
- email
- federal_tax_id
- insurance_vendor_id
- state_tax_id
- logo_img_path
computed_fields: []
filter:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: bodyshops
schema: public
type: create_select_permission

View File

@@ -0,0 +1,40 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- address1
- address2
- city
- country
- created_at
- email
- federal_tax_id
- id
- insurance_vendor_id
- logo_img_path
- md_ro_statuses
- shopname
- state
- state_tax_id
- updated_at
- zip_post
computed_fields: []
filter:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: bodyshops
schema: public
type: create_select_permission

View File

@@ -0,0 +1,40 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_update_permission
- args:
permission:
columns:
- address1
- address2
- city
- country
- created_at
- email
- federal_tax_id
- insurance_vendor_id
- logo_img_path
- shopname
- state
- state_tax_id
- updated_at
- zip_post
filter:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: bodyshops
schema: public
type: create_update_permission

View File

@@ -0,0 +1,41 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_update_permission
- args:
permission:
columns:
- address1
- address2
- city
- country
- created_at
- email
- federal_tax_id
- insurance_vendor_id
- logo_img_path
- md_ro_statuses
- shopname
- state
- state_tax_id
- updated_at
- zip_post
filter:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: bodyshops
schema: public
type: create_update_permission