Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add staff details to router
dominik-zeglen556c4c755253
diff --git a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsxindex 3a219ac508..873d66e6f5 100644--- a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx+++ b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx@@ -65,7 +65,11 @@ const StaffDetailsPage = decorate<StaffDetailsPageProps>()};return (- <Form initial={initialForm} onSubmit={onSubmit}>+ <Form+ initial={initialForm}+ onSubmit={onSubmit}+ key={JSON.stringify({ staffMember, permissions })}+ >{({ data, change, submit }) => (<Container width="md"><PageHeaderdiff --git a/saleor/static/dashboard-next/staff/index.tsx b/saleor/static/dashboard-next/staff/index.tsxindex 13b49618f8..bfd7e004b1 100644--- a/saleor/static/dashboard-next/staff/index.tsx+++ b/saleor/static/dashboard-next/staff/index.tsx@@ -2,6 +2,7 @@ import { parse as parseQs } from "qs";import * as React from "react";import { Route, RouteComponentProps, Switch } from "react-router-dom";+import StaffDetailsComponent from "./views/StaffDetails";import StaffListComponent from "./views/StaffList";const StaffList: React.StatelessComponent<RouteComponentProps<{}>> = ({@@ -15,14 +16,21 @@ const StaffList: React.StatelessComponent<RouteComponentProps<{}>> = ({return <StaffListComponent params={params} />;};+interface StaffDetailsRouteProps {+ id: string;+}+const StaffDetails: React.StatelessComponent<+ RouteComponentProps<StaffDetailsRouteProps>+> = ({ match }) => <StaffDetailsComponent id={match.params.id} />;+const Component = ({ match }) => (<Switch><Route exact path={match.url} component={StaffList} />+ <Route exact path={`${match.url}/:id/`} component={StaffDetails} /></Switch>);export const staffListUrl = "/staff/";-export const staffMemberDetailsUrl = (id: string) => {return `/staff/${id}/`;};diff --git a/saleor/static/dashboard-next/staff/mutations.ts b/saleor/static/dashboard-next/staff/mutations.tsindex b061e10a33..48261de3dd 100644--- a/saleor/static/dashboard-next/staff/mutations.ts+++ b/saleor/static/dashboard-next/staff/mutations.ts@@ -6,6 +6,10 @@ import {StaffMemberAdd,StaffMemberAddVariables} from "./types/StaffMemberAdd";+import {+ StaffMemberUpdate,+ StaffMemberUpdateVariables+} from "./types/StaffMemberUpdate";const staffMemberAddMutation = gql`${staffMemberDetailsFragment}@@ -25,3 +29,22 @@ export const TypedStaffMemberAddMutation = TypedMutation<StaffMemberAdd,StaffMemberAddVariables>(staffMemberAddMutation);++const staffMemberUpdateMutation = gql`+ ${staffMemberDetailsFragment}+ mutation StaffMemberUpdate($id: ID!, $input: StaffInput!) {+ staffUpdate(id: $id, input: $input) {+ errors {+ field+ message+ }+ user {+ ...StaffMemberDetailsFragment+ }+ }+ }+`;+export const TypedStaffMemberUpdateMutation = TypedMutation<+ StaffMemberUpdate,+ StaffMemberUpdateVariables+>(staffMemberUpdateMutation);diff --git a/saleor/static/dashboard-next/staff/queries.ts b/saleor/static/dashboard-next/staff/queries.tsindex 45adcd2577..de7f6183e7 100644--- a/saleor/static/dashboard-next/staff/queries.ts+++ b/saleor/static/dashboard-next/staff/queries.ts@@ -40,6 +40,12 @@ const staffList = gql`endCursor}}+ shop {+ permissions {+ code+ name+ }+ }}`;export const TypedStaffListQuery = TypedQuery<StaffList, StaffListVariables>(@@ -60,7 +66,7 @@ export const staffMemberDetails = gql`}}`;-export const TypedOrderDetailsQuery = TypedQuery<+export const TypedStaffMemberDetailsQuery = TypedQuery<StaffMemberDetails,StaffMemberDetailsVariables>(staffMemberDetails);diff --git a/saleor/static/dashboard-next/staff/types/StaffList.ts b/saleor/static/dashboard-next/staff/types/StaffList.tsindex b4c68eab6a..26396d3b0b 100644--- a/saleor/static/dashboard-next/staff/types/StaffList.ts+++ b/saleor/static/dashboard-next/staff/types/StaffList.ts@@ -32,8 +32,20 @@ export interface StaffList_staffUsers {pageInfo: StaffList_staffUsers_pageInfo;}+export interface StaffList_shop_permissions {+ __typename: "PermissionDisplay";+ code: string;+ name: string;+}++export interface StaffList_shop {+ __typename: "Shop";+ permissions: (StaffList_shop_permissions | null)[];+}+export interface StaffList {staffUsers: StaffList_staffUsers | null;+ shop: StaffList_shop | null;}export interface StaffListVariables {diff --git a/saleor/static/dashboard-next/staff/types/StaffMemberUpdate.ts b/saleor/static/dashboard-next/staff/types/StaffMemberUpdate.tsnew file mode 100644index 0000000000..9883ad35c2--- /dev/null+++ b/saleor/static/dashboard-next/staff/types/StaffMemberUpdate.ts@@ -0,0 +1,43 @@+/* tslint:disable */+// This file was automatically generated and should not be edited.++import { StaffInput } from "./../../types/globalTypes";++// ====================================================+// GraphQL mutation operation: StaffMemberUpdate+// ====================================================++export interface StaffMemberUpdate_staffUpdate_errors {+ __typename: "Error";+ field: string | null;+ message: string | null;+}++export interface StaffMemberUpdate_staffUpdate_user_permissions {+ __typename: "PermissionDisplay";+ code: string;+ name: string;+}++export interface StaffMemberUpdate_staffUpdate_user {+ __typename: "User";+ id: string;+ email: string;+ isActive: boolean;+ permissions: (StaffMemberUpdate_staffUpdate_user_permissions | null)[] | null;+}++export interface StaffMemberUpdate_staffUpdate {+ __typename: "StaffUpdate";+ errors: (StaffMemberUpdate_staffUpdate_errors | null)[] | null;+ user: StaffMemberUpdate_staffUpdate_user | null;+}++export interface StaffMemberUpdate {+ staffUpdate: StaffMemberUpdate_staffUpdate | null;+}++export interface StaffMemberUpdateVariables {+ id: string;+ input: StaffInput;+}diff --git a/saleor/static/dashboard-next/staff/views/StaffDetails.tsx b/saleor/static/dashboard-next/staff/views/StaffDetails.tsxnew file mode 100644index 0000000000..0caf1ea543--- /dev/null+++ b/saleor/static/dashboard-next/staff/views/StaffDetails.tsx@@ -0,0 +1,41 @@+import * as React from "react";++import { staffListUrl } from "..";+import Messages from "../../components/messages";+import Navigator from "../../components/Navigator";+import { maybe } from "../../misc";+import StaffDetailsPage from "../components/StaffDetailsPage/StaffDetailsPage";+import { TypedStaffMemberDetailsQuery } from "../queries";++interface OrderListProps {+ id: string;+}++export const StaffDetails: React.StatelessComponent<OrderListProps> = ({+ id+}) => (+ <Navigator>+ {navigate => (+ <Messages>+ {_ => (+ <TypedStaffMemberDetailsQuery variables={{ id }}>+ {({ data, loading }) => {+ return (+ <StaffDetailsPage+ disabled={loading}+ onBack={() => navigate(staffListUrl)}+ onDelete={() => undefined}+ onSubmit={() => undefined}+ permissions={maybe(() => data.shop.permissions)}+ staffMember={maybe(() => data.user)}+ />+ );+ }}+ </TypedStaffMemberDetailsQuery>+ )}+ </Messages>+ )}+ </Navigator>+);++export default StaffDetails;diff --git a/saleor/static/dashboard-next/types/globalTypes.ts b/saleor/static/dashboard-next/types/globalTypes.tsindex ef2697282a..c57821f9c0 100644--- a/saleor/static/dashboard-next/types/globalTypes.ts+++ b/saleor/static/dashboard-next/types/globalTypes.ts@@ -414,6 +414,12 @@ export interface StaffCreateInput {sendPasswordEmail?: boolean | null;}+export interface StaffInput {+ email?: string | null;+ note?: string | null;+ permissions?: (string | null)[] | null;+}+//==============================================================// END Enums and Input Objects//==============================================================