Theme change & layout updates. Removed template editor.

This commit is contained in:
Patrick Fic
2021-02-24 09:18:02 -08:00
parent 46014261d6
commit 57600a1e5a
7 changed files with 7117 additions and 8806 deletions

15502
client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -142,15 +142,13 @@ export default function GlobalSearch() {
if (error) return <AlertComponent message={error.message} type="error" />;
return (
<div>
<AutoComplete
dropdownMatchSelectWidth={false}
style={{ width: 200 }}
options={options}
onSearch={handleSearch}
>
<Input.Search loading={loading} />
</AutoComplete>
</div>
<AutoComplete
dropdownMatchSelectWidth={false}
style={{ flex: 2 }}
options={options}
onSearch={handleSearch}
>
<Input.Search loading={loading} />
</AutoComplete>
);
}

View File

@@ -67,12 +67,11 @@ function Header({
const { t } = useTranslation();
return (
<div style={{ display: "flex" }}>
<div style={{ display: "flex", alignItems: "center" }}>
<Menu
mode="horizontal"
theme="dark"
style={{ flex: 1 }}
className="header-main-menu"
// theme="dark"
style={{ flex: 5 }}
selectedKeys={[selectedHeader]}
onClick={handleMenuClick}
subMenuCloseDelay={0.3}
@@ -271,11 +270,13 @@ function Header({
{t("menus.header.temporarydocs")}
</Link>
</Menu.Item>
<Menu.Item key="shop-templates">
<Link to="/manage/shop/templates">
{t("menus.header.shop_templates")}
</Link>
</Menu.Item>
{
// <Menu.Item key="shop-templates">
// <Link to="/manage/shop/templates">
// {t("menus.header.shop_templates")}
// </Link>
// </Menu.Item>
}
<Menu.Item
key="reportcenter"
onClick={() => {
@@ -300,8 +301,8 @@ function Header({
<GlobalSearch />
<Menu
mode="horizontal"
theme="dark"
className="header-main-menu"
// theme="dark"
selectedKeys={[selectedHeader]}
onClick={handleMenuClick}
>

View File

@@ -1,94 +1,94 @@
// import "codemirror-graphql/hint";
// import "codemirror-graphql/lint";
// import "codemirror-graphql/mode";
// import "codemirror/addon/hint/show-hint";
// import "codemirror/addon/lint/lint";
// import "codemirror/lib/codemirror.css";
// import "codemirror/theme/material.css";
import React, { useEffect, useRef, useState } from "react";
import ShopTemplateEditorSaveButton from "../shop-template-editor-save-button/shop-template-editor-save-button.component";
import ShopTemplateTestRender from "../shop-template-test-render/shop-template-test-render.component";
// // import "codemirror-graphql/hint";
// // import "codemirror-graphql/lint";
// // import "codemirror-graphql/mode";
// // import "codemirror/addon/hint/show-hint";
// // import "codemirror/addon/lint/lint";
// // import "codemirror/lib/codemirror.css";
// // import "codemirror/theme/material.css";
// import React, { useEffect, useRef, useState } from "react";
// import ShopTemplateEditorSaveButton from "../shop-template-editor-save-button/shop-template-editor-save-button.component";
// import ShopTemplateTestRender from "../shop-template-test-render/shop-template-test-render.component";
export default function ShopTemplateEditorComponent({
templateId,
html,
gql,
json,
editorState,
}) {
const [editorContent, seteditorContent] = editorState;
const [editorLoaded, setEditorLoaded] = useState(false);
const emailEditorRef = useRef(null);
// export default function ShopTemplateEditorComponent({
// templateId,
// html,
// gql,
// json,
// editorState,
// }) {
// const [editorContent, seteditorContent] = editorState;
// const [editorLoaded, setEditorLoaded] = useState(false);
// const emailEditorRef = useRef(null);
useEffect(() => {
if (json && Object.keys(json).length > 0 && editorLoaded) {
console.log(emailEditorRef.current, !!emailEditorRef.current.loadDesign);
emailEditorRef.current.loadDesign(json);
}
}, [json, emailEditorRef, editorLoaded]);
// useEffect(() => {
// if (json && Object.keys(json).length > 0 && editorLoaded) {
// console.log(emailEditorRef.current, !!emailEditorRef.current.loadDesign);
// emailEditorRef.current.loadDesign(json);
// }
// }, [json, emailEditorRef, editorLoaded]);
useEffect(() => {
seteditorContent((prevstate) => {
return { ...prevstate, gql: gql };
});
}, [gql, seteditorContent]);
// useEffect(() => {
// seteditorContent((prevstate) => {
// return { ...prevstate, gql: gql };
// });
// }, [gql, seteditorContent]);
return (
<div>
{
// <EmailEditor
// style={{ width: "100%" }}
// ref={emailEditorRef}
// minHeight="700px"
// onLoad={() => setEditorLoaded(true)}
// options={{
// // customCSS: [
// // window.location.protocol +
// // "//" +
// // window.location.host +
// // "/render-styles.css",
// // ],
// customJS: [
// window.location.protocol +
// "//" +
// window.location.host +
// "/editor.js",
// ],
// }}
// />
}
// return (
// <div>
// {
// // <EmailEditor
// // style={{ width: "100%" }}
// // ref={emailEditorRef}
// // minHeight="700px"
// // onLoad={() => setEditorLoaded(true)}
// // options={{
// // // customCSS: [
// // // window.location.protocol +
// // // "//" +
// // // window.location.host +
// // // "/render-styles.css",
// // // ],
// // customJS: [
// // window.location.protocol +
// // "//" +
// // window.location.host +
// // "/editor.js",
// // ],
// // }}
// // />
// }
<div style={{ display: "flex", width: "90vw", margin: "2rem" }}>
{
// <CmEditor
// style={{ flex: 1 }}
// value={editorContent.gql}
// options={{
// mode: "graphql",
// lint: {
// schema: GqlSchema,
// },
// hintOptions: {
// schema: GqlSchema,
// },
// lineNumbers: true,
// }}
// onBeforeChange={(editor, data, value) => {
// seteditorContent({ ...editorContent, gql: value });
// }}
// />
}
<ShopTemplateTestRender
style={{ flex: 1 }}
query={editorContent.gql}
emailEditorRef={emailEditorRef}
/>
<ShopTemplateEditorSaveButton
templateId={templateId}
gql={editorContent.gql}
emailEditorRef={emailEditorRef}
/>
</div>
</div>
);
}
// <div style={{ display: "flex", width: "90vw", margin: "2rem" }}>
// {
// // <CmEditor
// // style={{ flex: 1 }}
// // value={editorContent.gql}
// // options={{
// // mode: "graphql",
// // lint: {
// // schema: GqlSchema,
// // },
// // hintOptions: {
// // schema: GqlSchema,
// // },
// // lineNumbers: true,
// // }}
// // onBeforeChange={(editor, data, value) => {
// // seteditorContent({ ...editorContent, gql: value });
// // }}
// // />
// }
// <ShopTemplateTestRender
// style={{ flex: 1 }}
// query={editorContent.gql}
// emailEditorRef={emailEditorRef}
// />
// <ShopTemplateEditorSaveButton
// templateId={templateId}
// gql={editorContent.gql}
// emailEditorRef={emailEditorRef}
// />
// </div>
// </div>
// );
// }

View File

@@ -1,41 +1,41 @@
import { useQuery } from "@apollo/client";
import queryString from "query-string";
import React, { useState } from "react";
import { useLocation } from "react-router-dom";
import { QUERY_TEMPLATE_BY_PK } from "../../graphql/templates.queries";
import AlertComponent from "../alert/alert.component";
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
import ShopTemplateEditorComponent from "./shop-template-editor.component";
// import { useQuery } from "@apollo/client";
// import queryString from "query-string";
// import React, { useState } from "react";
// import { useLocation } from "react-router-dom";
// import { QUERY_TEMPLATE_BY_PK } from "../../graphql/templates.queries";
// import AlertComponent from "../alert/alert.component";
// import LoadingSpinner from "../loading-spinner/loading-spinner.component";
// import ShopTemplateEditorComponent from "./shop-template-editor.component";
export default function ShopTemplateEditorContainer() {
const search = queryString.parse(useLocation().search);
const editorState = useState({ html: "", gql: "" });
// export default function ShopTemplateEditorContainer() {
// const search = queryString.parse(useLocation().search);
// const editorState = useState({ html: "", gql: "" });
const { loading, error, data } = useQuery(QUERY_TEMPLATE_BY_PK, {
variables: {
templateId: search.customTemplateId,
},
skip: !!!search.customTemplateId,
});
// const { loading, error, data } = useQuery(QUERY_TEMPLATE_BY_PK, {
// variables: {
// templateId: search.customTemplateId,
// },
// skip: !!!search.customTemplateId,
// });
if (!!!search.customTemplateId) return <span>No selection.</span>;
if (error) return <AlertComponent message={error.message} type="error" />;
// if (!!!search.customTemplateId) return <span>No selection.</span>;
// if (error) return <AlertComponent message={error.message} type="error" />;
return (
<div>
{loading ? (
<LoadingSpinner />
) : (
<ShopTemplateEditorComponent
templateId={search.customTemplateId}
json={
data && data.templates_by_pk && data.templates_by_pk.jsontemplate
}
gql={data && data.templates_by_pk ? data.templates_by_pk.query : ""}
editorState={editorState}
/>
)}
{data && data.templates_by_pk ? data.templates_by_pk.name : ""}
</div>
);
}
// return (
// <div>
// {loading ? (
// <LoadingSpinner />
// ) : (
// <ShopTemplateEditorComponent
// templateId={search.customTemplateId}
// json={
// data && data.templates_by_pk && data.templates_by_pk.jsontemplate
// }
// gql={data && data.templates_by_pk ? data.templates_by_pk.query : ""}
// editorState={editorState}
// />
// )}
// {data && data.templates_by_pk ? data.templates_by_pk.name : ""}
// </div>
// );
// }

View File

@@ -1,6 +1,7 @@
import { Elements } from "@stripe/react-stripe-js";
import { loadStripe } from "@stripe/stripe-js";
import { BackTop, Layout } from "antd";
import preval from "preval.macro";
import React, { lazy, Suspense, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
@@ -11,7 +12,6 @@ import ChatAffixContainer from "../../components/chat-affix/chat-affix.container
import ConflictComponent from "../../components/conflict/conflict.component";
import ErrorBoundary from "../../components/error-boundary/error-boundary.component";
import FcmNotification from "../../components/fcm-notification/fcm-notification.component";
import preval from "preval.macro";
//import FooterComponent from "../../components/footer/footer.component";
//Component Imports
import HeaderContainer from "../../components/header/header.container";
@@ -100,9 +100,9 @@ const ProductionListPage = lazy(() =>
const ProductionBoardPage = lazy(() =>
import("../production-board/production-board.container")
);
const ShopTemplates = lazy(() =>
import("../shop-templates/shop-templates.container")
);
// const ShopTemplates = lazy(() =>
// import("../shop-templates/shop-templates.container")
// );
const JobIntake = lazy(() =>
import("../jobs-intake/jobs-intake.page.container")
);
@@ -177,7 +177,7 @@ export function Manage({ match, conflict }) {
return (
<Layout className="layout-container">
<Header>
<Header style={{ backgroundColor: "#fff" }}>
<HeaderContainer />
</Header>
<Content className="content-container">
@@ -342,11 +342,15 @@ export function Manage({ match, conflict }) {
component={JobsAvailablePage}
/>
<Route exact path={`${match.path}/shop/`} component={ShopPage} />
<Route
exact
path={`${match.path}/shop/templates`}
component={ShopTemplates}
/>
{
// <Route
// exact
// path={`${match.path}/shop/templates`}
// component={ShopTemplates}
// />
}
<Route
exact
path={`${match.path}/shop/vendors`}

View File

@@ -1,56 +1,56 @@
import { Button } from "antd";
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
import ShopTemplateEditor from "../../components/shop-template-editor/shop-template-editor.container";
import ShopTemplatesListContainer from "../../components/shop-templates-list/shop-templates-list.container";
import {
setBreadcrumbs,
setSelectedHeader,
} from "../../redux/application/application.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
// import { Button } from "antd";
// import React, { useEffect, useState } from "react";
// import { useTranslation } from "react-i18next";
// import { connect } from "react-redux";
// import { createStructuredSelector } from "reselect";
// import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
// import ShopTemplateEditor from "../../components/shop-template-editor/shop-template-editor.container";
// import ShopTemplatesListContainer from "../../components/shop-templates-list/shop-templates-list.container";
// import {
// setBreadcrumbs,
// setSelectedHeader,
// } from "../../redux/application/application.actions";
// import { selectBodyshop } from "../../redux/user/user.selectors";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
setSelectedHeader: (key) => dispatch(setSelectedHeader(key)),
});
// const mapStateToProps = createStructuredSelector({
// bodyshop: selectBodyshop,
// });
// const mapDispatchToProps = (dispatch) => ({
// setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
// setSelectedHeader: (key) => dispatch(setSelectedHeader(key)),
// });
export function ShopTemplatesContainer({
setBreadcrumbs,
bodyshop,
setSelectedHeader,
}) {
const { t } = useTranslation();
const drawerVisibility = useState(false);
useEffect(() => {
document.title = t("titles.shop-templates");
setSelectedHeader("shop-templates");
setBreadcrumbs([
{
link: "/manage/shop",
label: t("titles.bc.shop", { shopname: bodyshop.shopname }),
},
{ link: "/manage/shop/templates", label: t("titles.bc.shop-templates") },
]);
}, [t, setBreadcrumbs, bodyshop.shopname, setSelectedHeader]);
// export function ShopTemplatesContainer({
// setBreadcrumbs,
// bodyshop,
// setSelectedHeader,
// }) {
// const { t } = useTranslation();
// const drawerVisibility = useState(false);
// useEffect(() => {
// document.title = t("titles.shop-templates");
// setSelectedHeader("shop-templates");
// setBreadcrumbs([
// {
// link: "/manage/shop",
// label: t("titles.bc.shop", { shopname: bodyshop.shopname }),
// },
// { link: "/manage/shop/templates", label: t("titles.bc.shop-templates") },
// ]);
// }, [t, setBreadcrumbs, bodyshop.shopname, setSelectedHeader]);
return (
<RbacWrapper action="shop:templates">
<div>
<ShopTemplatesListContainer visibleState={drawerVisibility} />
<Button onClick={() => drawerVisibility[1](true)}>Show List</Button>
<ShopTemplateEditor />
</div>
</RbacWrapper>
);
}
// return (
// <RbacWrapper action="shop:templates">
// <div>
// <ShopTemplatesListContainer visibleState={drawerVisibility} />
// <Button onClick={() => drawerVisibility[1](true)}>Show List</Button>
// <ShopTemplateEditor />
// </div>
// </RbacWrapper>
// );
// }
export default connect(
mapStateToProps,
mapDispatchToProps
)(ShopTemplatesContainer);
// export default connect(
// mapStateToProps,
// mapDispatchToProps
// )(ShopTemplatesContainer);