Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Connect components to API
dominik-zeglened6117eff895
diff --git a/saleor/static/dashboard-next/customers/components/CustomerList/CustomerList.tsx b/saleor/static/dashboard-next/customers/components/CustomerList/CustomerList.tsxindex 3e4d72869a..db7c2e49aa 100644--- a/saleor/static/dashboard-next/customers/components/CustomerList/CustomerList.tsx+++ b/saleor/static/dashboard-next/customers/components/CustomerList/CustomerList.tsx@@ -11,7 +11,7 @@ import * as React from "react";import Skeleton from "../../../components/Skeleton";import TablePagination from "../../../components/TablePagination";import i18n from "../../../i18n";-import { maybe, renderCollection } from "../../../misc";+import { getUserName, maybe, renderCollection } from "../../../misc";import { ListProps } from "../../../types";import { ListCustomers_customers_edges_node } from "../../types/ListCustomers";@@ -83,10 +83,7 @@ const CustomerList = withStyles(styles, { name: "CustomerList" })(<TableCellonClick={customer ? onRowClick(customer.id) : undefined}>- {maybe<React.ReactNode>(- () => `${customer.firstName} ${customer.lastName}`,- <Skeleton />- )}+ {getUserName(customer)}</TableCell><TableCell>{maybe<React.ReactNode>(() => customer.email, <Skeleton />)}diff --git a/saleor/static/dashboard-next/customers/queries.ts b/saleor/static/dashboard-next/customers/queries.tsindex 5d90b2a48e..237128b464 100644--- a/saleor/static/dashboard-next/customers/queries.ts+++ b/saleor/static/dashboard-next/customers/queries.ts@@ -13,6 +13,8 @@ export const customerFragment = gql`fragment CustomerFragment on User {id+ firstName+ lastName}`;diff --git a/saleor/static/dashboard-next/customers/types/CustomerDetails.ts b/saleor/static/dashboard-next/customers/types/CustomerDetails.tsindex 0bf1777ecf..907bdfb0dc 100644--- a/saleor/static/dashboard-next/customers/types/CustomerDetails.ts+++ b/saleor/static/dashboard-next/customers/types/CustomerDetails.ts@@ -99,10 +99,10 @@ export interface CustomerDetails_user_lastPlacedOrder {export interface CustomerDetails_user {__typename: "User";- firstName: string;- lastName: string;id: string;email: string;+ firstName: string;+ lastName: string;dateJoined: any;lastLogin: any | null;defaultShippingAddress: CustomerDetails_user_defaultShippingAddress | null;diff --git a/saleor/static/dashboard-next/customers/types/CustomerDetailsFragment.ts b/saleor/static/dashboard-next/customers/types/CustomerDetailsFragment.tsindex 4dfdb25e70..2baa7ad0a4 100644--- a/saleor/static/dashboard-next/customers/types/CustomerDetailsFragment.ts+++ b/saleor/static/dashboard-next/customers/types/CustomerDetailsFragment.ts@@ -53,6 +53,8 @@ export interface CustomerDetailsFragment {__typename: "User";id: string;email: string;+ firstName: string;+ lastName: string;dateJoined: any;lastLogin: any | null;defaultShippingAddress: CustomerDetailsFragment_defaultShippingAddress | null;diff --git a/saleor/static/dashboard-next/customers/types/CustomerFragment.ts b/saleor/static/dashboard-next/customers/types/CustomerFragment.tsindex 68ed59e640..cfc130290b 100644--- a/saleor/static/dashboard-next/customers/types/CustomerFragment.ts+++ b/saleor/static/dashboard-next/customers/types/CustomerFragment.ts@@ -9,4 +9,6 @@ export interface CustomerFragment {__typename: "User";id: string;email: string;+ firstName: string;+ lastName: string;}diff --git a/saleor/static/dashboard-next/customers/types/ListCustomers.ts b/saleor/static/dashboard-next/customers/types/ListCustomers.tsindex 2f361ca5af..51e8c8618f 100644--- a/saleor/static/dashboard-next/customers/types/ListCustomers.ts+++ b/saleor/static/dashboard-next/customers/types/ListCustomers.ts@@ -13,8 +13,8 @@ export interface ListCustomers_customers_edges_node_orders {export interface ListCustomers_customers_edges_node {__typename: "User";id: string;- firstName: string;email: string;+ firstName: string;lastName: string;orders: ListCustomers_customers_edges_node_orders | null;}diff --git a/saleor/static/dashboard-next/customers/types/UpdateCustomer.ts b/saleor/static/dashboard-next/customers/types/UpdateCustomer.tsindex 8e0bd370ea..1344dfc6cf 100644--- a/saleor/static/dashboard-next/customers/types/UpdateCustomer.ts+++ b/saleor/static/dashboard-next/customers/types/UpdateCustomer.ts@@ -61,6 +61,8 @@ export interface UpdateCustomer_customerUpdate_user {__typename: "User";id: string;email: string;+ firstName: string;+ lastName: string;dateJoined: any;lastLogin: any | null;defaultShippingAddress: UpdateCustomer_customerUpdate_user_defaultShippingAddress | null;diff --git a/saleor/static/dashboard-next/customers/views/CustomerDetails.tsx b/saleor/static/dashboard-next/customers/views/CustomerDetails.tsxindex 19e5ce7963..13f8aab47b 100644--- a/saleor/static/dashboard-next/customers/views/CustomerDetails.tsx+++ b/saleor/static/dashboard-next/customers/views/CustomerDetails.tsx@@ -115,7 +115,9 @@ export const CustomerDetailsView: React.StatelessComponent<id,input: {email: formData.email,+ firstName: formData.firstName,isActive: formData.isActive,+ lastName: formData.lastName,note: formData.note}}diff --git a/saleor/static/dashboard-next/misc.ts b/saleor/static/dashboard-next/misc.tsindex 5cf1cb7a8c..f93bc968fd 100644--- a/saleor/static/dashboard-next/misc.ts+++ b/saleor/static/dashboard-next/misc.ts@@ -170,3 +170,26 @@ export function getMutationProviderData<TData, TVariables>(opts};}++interface User {+ email: string;+ firstName?: string;+ lastName?: string;+}++export function getUserName(user?: User) {+ return user && (user.email || (user.firstName && user.lastName))+ ? user.firstName && user.lastName+ ? [user.firstName, user.lastName].join(" ")+ : user.email.split("@")[0]+ : null;+}++export function getUserInitials(user?: User) {+ return user && (user.email || (user.firstName && user.lastName))+ ? (user.firstName && user.lastName+ ? user.firstName + user.lastName+ : user.email.slice(0, 2)+ ).toUpperCase()+ : null;+}diff --git a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsxindex 119b846e38..594ff1d8d2 100644--- a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx+++ b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx@@ -11,7 +11,7 @@ import Container from "../../../components/Container";import Form from "../../../components/Form";import PageHeader from "../../../components/PageHeader";import SaveButtonBar from "../../../components/SaveButtonBar";-import { maybe } from "../../../misc";+import { getUserName, maybe } from "../../../misc";import { PermissionEnum } from "../../../types/globalTypes";import {StaffMemberDetails_shop_permissions,@@ -80,12 +80,7 @@ const StaffDetailsPage = withStyles(styles, { name: "StaffDetailsPage" })(<Form initial={initialForm} onSubmit={onSubmit} confirmLeave>{({ data, change, hasChanged, submit }) => (<Container width="md">- <PageHeader- title={maybe(- () => `${staffMember.firstName} ${staffMember.lastName}`- )}- onBack={onBack}- />+ <PageHeader title={getUserName(staffMember)} onBack={onBack} /><div className={classes.root}><div><StaffPropertiesdiff --git a/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsx b/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsxindex 3a5ac86959..811ea93afe 100644--- a/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsx+++ b/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsx@@ -18,7 +18,12 @@ import * as React from "react";import Skeleton from "../../../components/Skeleton";import TablePagination from "../../../components/TablePagination";import i18n from "../../../i18n";-import { maybe, renderCollection } from "../../../misc";+import {+ getUserInitials,+ getUserName,+ maybe,+ renderCollection+} from "../../../misc";import { ListProps } from "../../../types";import { StaffList_staffUsers_edges_node } from "../../types/StaffList";@@ -105,40 +110,30 @@ const StaffList = withStyles(styles, { name: "StaffList" })(key={staffMember ? staffMember.id : "skeleton"}><TableCell>- {staffMember &&- staffMember.firstName &&- staffMember.lastName !== undefined ? (- <>- <div className={classes.avatar}>- <Typography className={classes.avatarText}>- {maybe(- () =>- `${staffMember.firstName[0].toUpperCase()}${staffMember.lastName[0].toUpperCase()}`- ) || ""}- </Typography>- </div>- <Typography>- {`${staffMember.firstName} ${staffMember.lastName}`}- </Typography>- <Typography- variant={"caption"}- className={classes.statusText}- >- {staffMember.isActive+ <div className={classes.avatar}>+ <Typography className={classes.avatarText}>+ {getUserInitials(staffMember)}+ </Typography>+ </div>+ <Typography>+ {getUserName(staffMember) || <Skeleton />}+ </Typography>+ <Typography+ variant={"caption"}+ className={classes.statusText}+ >+ {maybe<React.ReactNode>(+ () =>+ staffMember.isActive? i18n.t("Active", { context: "status" })- : i18n.t("Inactive", { context: "status" })}- </Typography>- </>- ) : (- <Skeleton style={{ width: "10em" }} />- )}+ : i18n.t("Inactive", { context: "status" }),+ <Skeleton />+ )}+ </Typography></TableCell><TableCell>- {staffMember ? (- <span onClick={onRowClick(staffMember.id)}>- {staffMember.email}- </span>- ) : (+ {maybe<React.ReactNode>(+ () => staffMember.email,<Skeleton />)}</TableCell>diff --git a/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx b/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsxindex fd78812240..9bcb60bb4a 100644--- a/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx+++ b/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx@@ -12,7 +12,7 @@ import * as React from "react";import CardTitle from "../../../components/CardTitle";import Skeleton from "../../../components/Skeleton";import i18n from "../../../i18n";-import { maybe } from "../../../misc";+import { getUserInitials, maybe } from "../../../misc";import { StaffMemberDetails_user } from "../../types/StaffMemberDetails";const styles = (theme: Theme) =>@@ -63,10 +63,7 @@ const StaffProperties = withStyles(styles, { name: "StaffProperties" })(<div><div className={classes.avatar}><Typography className={classes.avatarText}>- {maybe(- () =>- `${staffMember.firstName[0].toUpperCase()}${staffMember.lastName[0].toUpperCase()}`- ) || ""}+ {getUserInitials(staffMember)}</Typography></div></div>@@ -74,18 +71,30 @@ const StaffProperties = withStyles(styles, { name: "StaffProperties" })(<div className={classes.propGrid}><div className={classes.prop}><Typography variant="body2">{i18n.t("First Name")}</Typography>- {maybe(() => staffMember.firstName) === undefined ? (+ {maybe<React.ReactNode>(+ () =>+ staffMember.firstName ? (+ <Typography>{staffMember.firstName}</Typography>+ ) : (+ <Typography color="textSecondary">+ {i18n.t("No info")}+ </Typography>+ ),<Skeleton />- ) : (- <Typography>{staffMember.firstName}</Typography>)}</div><div className={classes.prop}><Typography variant="body2">{i18n.t("Last Name")}</Typography>- {maybe(() => staffMember.lastName) === undefined ? (+ {maybe<React.ReactNode>(+ () =>+ staffMember.lastName ? (+ <Typography>{staffMember.lastName}</Typography>+ ) : (+ <Typography color="textSecondary">+ {i18n.t("No info")}+ </Typography>+ ),<Skeleton />- ) : (- <Typography>{staffMember.lastName}</Typography>)}</div><div className={classes.prop}>diff --git a/saleor/static/dashboard-next/staff/queries.ts b/saleor/static/dashboard-next/staff/queries.tsindex de7f6183e7..c5c650e229 100644--- a/saleor/static/dashboard-next/staff/queries.ts+++ b/saleor/static/dashboard-next/staff/queries.ts@@ -10,7 +10,9 @@ export const staffMemberFragment = gql`fragment StaffMemberFragment on User {id+ firstNameisActive+ lastName}`;export const staffMemberDetailsFragment = gql`diff --git a/saleor/static/dashboard-next/staff/types/StaffList.ts b/saleor/static/dashboard-next/staff/types/StaffList.tsindex dc5defbf79..968002bc05 100644--- a/saleor/static/dashboard-next/staff/types/StaffList.ts+++ b/saleor/static/dashboard-next/staff/types/StaffList.ts@@ -11,8 +11,8 @@ export interface StaffList_staffUsers_edges_node {__typename: "User";id: string;email: string;- isActive: boolean;firstName: string;+ isActive: boolean;lastName: string;}diff --git a/saleor/static/dashboard-next/staff/types/StaffMemberAdd.ts b/saleor/static/dashboard-next/staff/types/StaffMemberAdd.tsindex fe118d35e7..0f1c074fb7 100644--- a/saleor/static/dashboard-next/staff/types/StaffMemberAdd.ts+++ b/saleor/static/dashboard-next/staff/types/StaffMemberAdd.ts@@ -23,7 +23,9 @@ export interface StaffMemberAdd_staffCreate_user {__typename: "User";id: string;email: string;+ firstName: string;isActive: boolean;+ lastName: string;permissions: (StaffMemberAdd_staffCreate_user_permissions | null)[] | null;}diff --git a/saleor/static/dashboard-next/staff/types/StaffMemberDetails.ts b/saleor/static/dashboard-next/staff/types/StaffMemberDetails.tsindex 62bbb1e297..e5acca3ea9 100644--- a/saleor/static/dashboard-next/staff/types/StaffMemberDetails.ts+++ b/saleor/static/dashboard-next/staff/types/StaffMemberDetails.ts@@ -17,10 +17,10 @@ export interface StaffMemberDetails_user {__typename: "User";id: string;email: string;- isActive: boolean;- permissions: (StaffMemberDetails_user_permissions | null)[] | null;firstName: string;+ isActive: boolean;lastName: string;+ permissions: (StaffMemberDetails_user_permissions | null)[] | null;}export interface StaffMemberDetails_shop_permissions {diff --git a/saleor/static/dashboard-next/staff/types/StaffMemberDetailsFragment.ts b/saleor/static/dashboard-next/staff/types/StaffMemberDetailsFragment.tsindex 3d42140160..2041622ff4 100644--- a/saleor/static/dashboard-next/staff/types/StaffMemberDetailsFragment.ts+++ b/saleor/static/dashboard-next/staff/types/StaffMemberDetailsFragment.ts@@ -17,6 +17,8 @@ export interface StaffMemberDetailsFragment {__typename: "User";id: string;email: string;+ firstName: string;isActive: boolean;+ lastName: string;permissions: (StaffMemberDetailsFragment_permissions | null)[] | null;}diff --git a/saleor/static/dashboard-next/staff/types/StaffMemberFragment.ts b/saleor/static/dashboard-next/staff/types/StaffMemberFragment.tsindex 1a9a9b30a4..651b2ce9f3 100644--- a/saleor/static/dashboard-next/staff/types/StaffMemberFragment.ts+++ b/saleor/static/dashboard-next/staff/types/StaffMemberFragment.ts@@ -9,5 +9,7 @@ export interface StaffMemberFragment {__typename: "User";id: string;email: string;+ firstName: string;isActive: boolean;+ lastName: string;}diff --git a/saleor/static/dashboard-next/staff/types/StaffMemberUpdate.ts b/saleor/static/dashboard-next/staff/types/StaffMemberUpdate.tsindex 1368141eb7..72a6b252f6 100644--- a/saleor/static/dashboard-next/staff/types/StaffMemberUpdate.ts+++ b/saleor/static/dashboard-next/staff/types/StaffMemberUpdate.ts@@ -23,7 +23,9 @@ export interface StaffMemberUpdate_staffUpdate_user {__typename: "User";id: string;email: string;+ firstName: string;isActive: boolean;+ lastName: string;permissions: (StaffMemberUpdate_staffUpdate_user_permissions | null)[] | null;}