Skip to content

Saleor Core: the high performance, composable, headless commerce API.

wip

dominik-zeglenc055c93e9c29
diff --git a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx
new file mode 100644
index 0000000000..c1f69a2ab2
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx
@@ -0,0 +1,63 @@
+import { withStyles } from "@material-ui/core/styles";
+import * as React from "react";
+import Container from "../../../components/Container";
+import Form from "../../../components/Form";
+import PageHeader from "../../../components/PageHeader";
+import { maybe } from "../../../misc";
+import { StaffMemberDetails_user } from "../../types/StaffMemberDetails";
+import StaffProperties from "../StaffProperties/StaffProperties";
+
+interface FormData {
+ hasFullAccess: boolean;
+ isActive: boolean;
+ permissions: string[];
+}
+
+export interface StaffDetailsPageProps {
+ disabled: boolean;
+ staffMember: StaffMemberDetails_user;
+ onBack: () => void;
+ onDelete: () => void;
+ onSubmit: (data: FormData) => void;
+}
+
+const decorate = withStyles(theme => ({
+ card: {
+ marginBottom: theme.spacing.unit * 2
+ },
+ root: {
+ display: "grid" as "grid",
+ gridColumnGap: theme.spacing.unit * 2,
+ gridTemplateColumns: "9fr 4fr"
+ }
+}));
+const StaffDetailsPage = decorate<StaffDetailsPageProps>(
+ ({ classes, staffMember, onBack }) => {
+ const initialForm: FormData = {
+ hasFullAccess
+ };
+ return (
+ <Form initial={initialForm}>
+ {({ change, data, hasChanged }) => (
+ <Container width="md">
+ <PageHeader
+ title={maybe(() => staffMember.email)}
+ onBack={onBack}
+ />
+ <div className={classes.root}>
+ <div>
+ <StaffProperties
+ className={classes.card}
+ staffMember={staffMember}
+ />
+ </div>
+ <div />
+ </div>
+ </Container>
+ )}
+ </Form>
+ );
+ }
+);
+StaffDetailsPage.displayName = "StaffDetailsPage";
+export default StaffDetailsPage;
diff --git a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/index.ts b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/index.ts
new file mode 100644
index 0000000000..310f38a215
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./StaffDetailsPage";
+export * from "./StaffDetailsPage";
diff --git a/saleor/static/dashboard-next/staff/components/StaffPermissions/StaffPermissions.tsx b/saleor/static/dashboard-next/staff/components/StaffPermissions/StaffPermissions.tsx
new file mode 100644
index 0000000000..06a40420f2
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffPermissions/StaffPermissions.tsx
@@ -0,0 +1,9 @@
+import { withStyles } from "@material-ui/core/styles";
+import * as React from "react";
+
+interface StaffPermissionsProps {}
+
+const decorate = withStyles(theme => ({ root: {} }));
+const StaffPermissions = decorate<StaffPermissionsProps>(({ classes }) => <div />);
+StaffPermissions.displayName = "StaffPermissions";
+export default StaffPermissions;
diff --git a/saleor/static/dashboard-next/staff/components/StaffPermissions/index.ts b/saleor/static/dashboard-next/staff/components/StaffPermissions/index.ts
new file mode 100644
index 0000000000..82993ead19
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffPermissions/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./StaffPermissions";
+export * from "./StaffPermissions";
diff --git a/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx b/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx
new file mode 100644
index 0000000000..0512b5f772
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx
@@ -0,0 +1,81 @@
+import Card from "@material-ui/core/Card";
+import CardContent from "@material-ui/core/CardContent";
+import { withStyles } from "@material-ui/core/styles";
+import Typography from "@material-ui/core/Typography";
+import * as React from "react";
+
+import CardTitle from "../../../components/CardTitle";
+import Skeleton from "../../../components/Skeleton";
+import i18n from "../../../i18n";
+import { maybe } from "../../../misc";
+import { StaffMemberDetails_user } from "../../types/StaffMemberDetails";
+
+interface StaffPropertiesProps {
+ className?: string;
+ staffMember: StaffMemberDetails_user;
+}
+
+const decorate = withStyles(theme => ({
+ avatar: {
+ alignItems: "center" as "center",
+ backgroundColor: theme.palette.primary.main,
+ borderRadius: "100%",
+ display: "grid" as "grid",
+ height: 120,
+ justifyContent: "center" as "center",
+ width: 120
+ },
+ avatarText: {
+ color: "#ffffff",
+ fontSize: 64,
+ pointerEvents: "none" as "none"
+ },
+ prop: {
+ marginBottom: theme.spacing.unit * 0
+ },
+ propGrid: {
+ display: "grid" as "grid",
+ gridColumnGap: theme.spacing.unit * 2 + "px",
+ gridTemplateColumns: "1fr 1fr"
+ },
+ root: {
+ display: "grid" as "grid",
+ gridColumnGap: theme.spacing.unit * 4 + "px",
+ gridTemplateColumns: "120px 1fr"
+ }
+}));
+const StaffProperties = decorate<StaffPropertiesProps>(
+ ({ classes, className, staffMember }) => (
+ <Card className={className}>
+ <CardTitle title={i18n.t("Staff Member Information")} />
+ <CardContent>
+ <div className={classes.root}>
+ <div>
+ <div className={classes.avatar}>
+ <Typography className={classes.avatarText}>
+ {maybe(() => staffMember.email.slice(0, 2).toUpperCase()) || ""}
+ </Typography>
+ </div>
+ </div>
+ <div>
+ <div className={classes.propGrid}>
+ <div>
+ <div className={classes.prop}>
+ <Typography variant="body2">{i18n.t("E-mail")}</Typography>
+ {maybe(() => staffMember.email) === undefined ? (
+ <Skeleton />
+ ) : (
+ <Typography>{staffMember.email}</Typography>
+ )}
+ </div>
+ <div />
+ </div>
+ </div>
+ </div>
+ </div>
+ </CardContent>
+ </Card>
+ )
+);
+StaffProperties.displayName = "StaffProperties";
+export default StaffProperties;
diff --git a/saleor/static/dashboard-next/staff/components/StaffProperties/index.ts b/saleor/static/dashboard-next/staff/components/StaffProperties/index.ts
new file mode 100644
index 0000000000..eadc2b079a
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffProperties/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./StaffProperties";
+export * from "./StaffProperties";
diff --git a/saleor/static/dashboard-next/staff/components/StaffStatus/StaffStatus.tsx b/saleor/static/dashboard-next/staff/components/StaffStatus/StaffStatus.tsx
new file mode 100644
index 0000000000..5e6ca13ca2
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffStatus/StaffStatus.tsx
@@ -0,0 +1,9 @@
+import { withStyles } from "@material-ui/core/styles";
+import * as React from "react";
+
+interface StaffStatusProps {}
+
+const decorate = withStyles(theme => ({ root: {} }));
+const StaffStatus = decorate<StaffStatusProps>(({ classes }) => <div />);
+StaffStatus.displayName = "StaffStatus";
+export default StaffStatus;
diff --git a/saleor/static/dashboard-next/staff/components/StaffStatus/index.ts b/saleor/static/dashboard-next/staff/components/StaffStatus/index.ts
new file mode 100644
index 0000000000..2372b443b2
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffStatus/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./StaffStatus";
+export * from "./StaffStatus";
diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.js
index 0eae91a701..60bea66615 100644
--- a/saleor/static/dashboard-next/storybook/config.js
+++ b/saleor/static/dashboard-next/storybook/config.js
@@ -54,6 +54,7 @@ function loadStories() {
// Staff
require("./stories/staff/StaffListPage")
+ require("./stories/staff/StaffDetailsPage")
// Pages
require("./stories/pages/PageContent");
diff --git a/saleor/static/dashboard-next/storybook/stories/staff/StaffDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/staff/StaffDetailsPage.tsx
new file mode 100644
index 0000000000..80c516b0d9
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/staff/StaffDetailsPage.tsx
@@ -0,0 +1,23 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import StaffDetailsPage, {
+ StaffDetailsPageProps
+} from "../../../staff/components/StaffDetailsPage";
+import { staffMember } from "../../../staff/fixtures";
+import Decorator from "../../Decorator";
+
+const props: StaffDetailsPageProps = {
+ disabled: false,
+ onBack: () => undefined,
+ onDelete: () => undefined,
+ onSubmit: () => undefined,
+ staffMember
+};
+
+storiesOf("Views / Staff / Staff member details", module)
+ .addDecorator(Decorator)
+ .add("default", () => <StaffDetailsPage {...props} />)
+ .add("loading", () => (
+ <StaffDetailsPage {...props} disabled={true} staffMember={undefined} />
+ ));