Update types

This commit is contained in:
dominik-zeglen 2020-04-20 13:11:07 +02:00
parent ffced45d55
commit 1ede1a33b1
28 changed files with 510 additions and 461 deletions

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,7 @@ export interface SetPassword_setPassword_errors {
}
export interface SetPassword_setPassword_user_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}
@ -37,7 +37,7 @@ export interface SetPassword_setPassword_user {
export interface SetPassword_setPassword {
__typename: "SetPassword";
errors: SetPassword_setPassword_errors[] | null;
errors: SetPassword_setPassword_errors[];
token: string | null;
user: SetPassword_setPassword_user | null;
}

View file

@ -15,7 +15,7 @@ export interface TokenAuth_tokenCreate_errors {
}
export interface TokenAuth_tokenCreate_user_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}
@ -38,7 +38,7 @@ export interface TokenAuth_tokenCreate_user {
export interface TokenAuth_tokenCreate {
__typename: "CreateToken";
token: string | null;
errors: (TokenAuth_tokenCreate_errors | null)[];
errors: TokenAuth_tokenCreate_errors[];
user: TokenAuth_tokenCreate_user | null;
}

View file

@ -9,7 +9,7 @@ import { PermissionEnum } from "./../../types/globalTypes";
// ====================================================
export interface User_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}

View file

@ -9,7 +9,7 @@ import { PermissionEnum } from "./../../types/globalTypes";
// ====================================================
export interface VerifyToken_tokenVerify_user_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}

View file

@ -33,7 +33,7 @@ export interface ShopInfo_shop_languages {
}
export interface ShopInfo_shop_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}

View file

@ -373,7 +373,7 @@ export const permissions: ShopInfo_shop_permissions[] = [
name: "Manage webhooks."
}
].map(perm => ({
__typename: "PermissionDisplay" as "PermissionDisplay",
__typename: "Permission" as "Permission",
...perm
}));

View file

@ -29,6 +29,7 @@ export interface ProductFragment {
name: string;
thumbnail: ProductFragment_thumbnail | null;
isAvailable: boolean | null;
isPublished: boolean;
basePrice: ProductFragment_basePrice | null;
productType: ProductFragment_productType;
}

View file

@ -48,7 +48,7 @@ export interface ProductList_products_edges_node {
name: string;
thumbnail: ProductList_products_edges_node_thumbnail | null;
isAvailable: boolean | null;
isPublished: boolean | null;
isPublished: boolean;
basePrice: ProductList_products_edges_node_basePrice | null;
productType: ProductList_products_edges_node_productType;
attributes: ProductList_products_edges_node_attributes[];

View file

@ -30,7 +30,7 @@ export const service: ServiceDetails_serviceAccount = {
name: "Magento Importer",
permissions: [
{
__typename: "PermissionDisplay" as "PermissionDisplay",
__typename: "Permission" as "Permission",
code: PermissionEnum.MANAGE_PRODUCTS,
name: "Manage products."
}

View file

@ -9,7 +9,7 @@ import { PermissionEnum } from "./../../types/globalTypes";
// ====================================================
export interface ServiceDetails_serviceAccount_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}

View file

@ -9,7 +9,7 @@ import { PermissionEnum } from "./../../types/globalTypes";
// ====================================================
export interface ServiceDetailsFragment_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}

View file

@ -15,7 +15,7 @@ export interface ServiceUpdate_serviceAccountUpdate_errors {
}
export interface ServiceUpdate_serviceAccountUpdate_serviceAccount_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}

View file

@ -98,7 +98,7 @@ export const TypedUpdateDefaultWeightUnit = TypedMutation<
const createShippingZone = gql`
${countryFragment}
${shippingErrorFragment}
mutation CreateShippingZone($input: ShippingZoneInput!) {
mutation CreateShippingZone($input: ShippingZoneCreateInput!) {
shippingZoneCreate(input: $input) {
errors: shippingErrors {
...ShippingErrorFragment
@ -122,7 +122,7 @@ export const TypedCreateShippingZone = TypedMutation<
const updateShippingZone = gql`
${countryFragment}
${shippingErrorFragment}
mutation UpdateShippingZone($id: ID!, $input: ShippingZoneInput!) {
mutation UpdateShippingZone($id: ID!, $input: ShippingZoneUpdateInput!) {
shippingZoneUpdate(id: $id, input: $input) {
errors: shippingErrors {
...ShippingErrorFragment

View file

@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { ShippingZoneInput, ShippingErrorCode } from "./../../types/globalTypes";
import { ShippingZoneCreateInput, ShippingErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: CreateShippingZone
@ -39,5 +39,5 @@ export interface CreateShippingZone {
}
export interface CreateShippingZoneVariables {
input: ShippingZoneInput;
input: ShippingZoneCreateInput;
}

View file

@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { ShippingZoneInput, ShippingErrorCode } from "./../../types/globalTypes";
import { ShippingZoneUpdateInput, ShippingErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: UpdateShippingZone
@ -40,5 +40,5 @@ export interface UpdateShippingZone {
export interface UpdateShippingZoneVariables {
id: string;
input: ShippingZoneInput;
input: ShippingZoneUpdateInput;
}

View file

@ -5,21 +5,19 @@ import DialogContent from "@material-ui/core/DialogContent";
import DialogTitle from "@material-ui/core/DialogTitle";
import { makeStyles } from "@material-ui/core/styles";
import TextField from "@material-ui/core/TextField";
import Typography from "@material-ui/core/Typography";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import ConfirmButton, {
ConfirmButtonTransitionState
} from "@saleor/components/ConfirmButton";
import { ControlledCheckbox } from "@saleor/components/ControlledCheckbox";
import Form from "@saleor/components/Form";
import FormSpacer from "@saleor/components/FormSpacer";
import { buttonMessages, commonMessages } from "@saleor/intl";
import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors";
import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment";
import { getFormErrors } from "@saleor/utils/errors";
import getAccountErrorMessage from "@saleor/utils/errors/account";
import { StaffErrorFragment } from "@saleor/staff/types/StaffErrorFragment";
import getStaffErrorMessage from "@saleor/utils/errors/staff";
export interface FormData {
email: string;
@ -59,7 +57,7 @@ const useStyles = makeStyles(
interface StaffAddMemberDialogProps {
confirmButtonState: ConfirmButtonTransitionState;
errors: AccountErrorFragment[];
errors: StaffErrorFragment[];
open: boolean;
onClose: () => void;
onConfirm: (data: FormData) => void;
@ -92,10 +90,7 @@ const StaffAddMemberDialog: React.FC<StaffAddMemberDialogProps> = props => {
<div className={classes.textFieldGrid}>
<TextField
error={!!formErrors.firstName}
helperText={getAccountErrorMessage(
formErrors.firstName,
intl
)}
helperText={getStaffErrorMessage(formErrors.firstName, intl)}
label={intl.formatMessage(commonMessages.firstName)}
name="firstName"
type="text"
@ -104,7 +99,7 @@ const StaffAddMemberDialog: React.FC<StaffAddMemberDialogProps> = props => {
/>
<TextField
error={!!formErrors.lastName}
helperText={getAccountErrorMessage(formErrors.lastName, intl)}
helperText={getStaffErrorMessage(formErrors.lastName, intl)}
label={intl.formatMessage(commonMessages.lastName)}
name="lastName"
type="text"
@ -116,7 +111,7 @@ const StaffAddMemberDialog: React.FC<StaffAddMemberDialogProps> = props => {
<TextField
error={!!formErrors.email}
fullWidth
helperText={getAccountErrorMessage(formErrors.email, intl)}
helperText={getStaffErrorMessage(formErrors.email, intl)}
label={intl.formatMessage(commonMessages.email)}
name="email"
type="email"
@ -124,23 +119,6 @@ const StaffAddMemberDialog: React.FC<StaffAddMemberDialogProps> = props => {
onChange={change}
/>
</DialogContent>
<hr className={classes.hr} />
<DialogContent>
<Typography className={classes.sectionTitle}>
<FormattedMessage defaultMessage="Permissions" />
</Typography>
<Typography>
<FormattedMessage defaultMessage="Expand or restrict users permissions to access certain part of saleor system." />
</Typography>
<ControlledCheckbox
checked={data.fullAccess}
label={intl.formatMessage({
defaultMessage: "User has full access"
})}
name="fullAccess"
onChange={change}
/>
</DialogContent>
<DialogActions>
<Button onClick={onClose}>
<FormattedMessage {...buttonMessages.back} />

View file

@ -26,13 +26,19 @@ import {
ChangeStaffPasswordVariables
} from "./types/ChangeStaffPassword";
const staffErrorFragment = gql`
fragment StaffErrorFragment on StaffError {
code
field
}
`;
const staffMemberAddMutation = gql`
${accountFragmentError}
${staffErrorFragment}
${staffMemberDetailsFragment}
mutation StaffMemberAdd($input: StaffCreateInput!) {
staffCreate(input: $input) {
errors: accountErrors {
...AccountErrorFragment
errors: staffErrors {
...StaffErrorFragment
}
user {
...StaffMemberDetailsFragment
@ -48,10 +54,10 @@ export const TypedStaffMemberAddMutation = TypedMutation<
const staffMemberUpdateMutation = gql`
${accountFragmentError}
${staffMemberDetailsFragment}
mutation StaffMemberUpdate($id: ID!, $input: StaffInput!) {
mutation StaffMemberUpdate($id: ID!, $input: StaffUpdateInput!) {
staffUpdate(id: $id, input: $input) {
errors: accountErrors {
...AccountErrorFragment
errors: staffErrors {
...StaffErrorFragment
}
user {
...StaffMemberDetailsFragment
@ -65,11 +71,11 @@ export const TypedStaffMemberUpdateMutation = TypedMutation<
>(staffMemberUpdateMutation);
const staffMemberDeleteMutation = gql`
${accountFragmentError}
${staffErrorFragment}
mutation StaffMemberDelete($id: ID!) {
staffDelete(id: $id) {
errors: accountErrors {
...AccountErrorFragment
errors: staffErrors {
...StaffErrorFragment
}
}
}

View file

@ -0,0 +1,15 @@
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { AccountErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL fragment: StaffErrorFragment
// ====================================================
export interface StaffErrorFragment {
__typename: "StaffError";
code: AccountErrorCode;
field: string | null;
}

View file

@ -9,7 +9,7 @@ import { StaffCreateInput, AccountErrorCode, PermissionEnum } from "./../../type
// ====================================================
export interface StaffMemberAdd_staffCreate_errors {
__typename: "AccountError";
__typename: "StaffError";
code: AccountErrorCode;
field: string | null;
}
@ -20,7 +20,7 @@ export interface StaffMemberAdd_staffCreate_user_avatar {
}
export interface StaffMemberAdd_staffCreate_user_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}

View file

@ -9,7 +9,7 @@ import { AccountErrorCode } from "./../../types/globalTypes";
// ====================================================
export interface StaffMemberDelete_staffDelete_errors {
__typename: "AccountError";
__typename: "StaffError";
code: AccountErrorCode;
field: string | null;
}

View file

@ -14,7 +14,7 @@ export interface StaffMemberDetails_user_avatar {
}
export interface StaffMemberDetails_user_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}

View file

@ -14,7 +14,7 @@ export interface StaffMemberDetailsFragment_avatar {
}
export interface StaffMemberDetailsFragment_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}

View file

@ -2,14 +2,14 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { StaffInput, AccountErrorCode, PermissionEnum } from "./../../types/globalTypes";
import { StaffUpdateInput, AccountErrorCode, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: StaffMemberUpdate
// ====================================================
export interface StaffMemberUpdate_staffUpdate_errors {
__typename: "AccountError";
__typename: "StaffError";
code: AccountErrorCode;
field: string | null;
}
@ -20,7 +20,7 @@ export interface StaffMemberUpdate_staffUpdate_user_avatar {
}
export interface StaffMemberUpdate_staffUpdate_user_permissions {
__typename: "PermissionDisplay";
__typename: "Permission";
code: PermissionEnum;
name: string;
}
@ -48,5 +48,5 @@ export interface StaffMemberUpdate {
export interface StaffMemberUpdateVariables {
id: string;
input: StaffInput;
input: StaffUpdateInput;
}

View file

@ -161,8 +161,7 @@ export const StaffDetails: React.FC<OrderListProps> = ({ id, params }) => {
email: variables.email,
firstName: variables.firstName,
isActive: variables.isActive,
lastName: variables.lastName,
permissions: variables.permissions
lastName: variables.lastName
}
}
})

View file

@ -141,9 +141,6 @@ export const StaffList: React.FC<StaffListProps> = ({ params }) => {
email: variables.email,
firstName: variables.firstName,
lastName: variables.lastName,
permissions: variables.fullAccess
? maybe(() => shop.permissions.map(perm => perm.code))
: undefined,
redirectUrl: urlJoin(
window.location.origin,
APP_MOUNT_URI === "/" ? "" : APP_MOUNT_URI,

View file

@ -9,7 +9,7 @@
export enum AccountErrorCode {
ACTIVATE_OWN_ACCOUNT = "ACTIVATE_OWN_ACCOUNT",
ACTIVATE_SUPERUSER_ACCOUNT = "ACTIVATE_SUPERUSER_ACCOUNT",
ASSIGN_NON_STAFF_MEMBER = "ASSIGN_NON_STAFF_MEMBER",
CANNOT_ADD_AND_REMOVE = "CANNOT_ADD_AND_REMOVE",
DEACTIVATE_OWN_ACCOUNT = "DEACTIVATE_OWN_ACCOUNT",
DEACTIVATE_SUPERUSER_ACCOUNT = "DEACTIVATE_SUPERUSER_ACCOUNT",
DELETE_NON_STAFF_USER = "DELETE_NON_STAFF_USER",
@ -18,8 +18,13 @@ export enum AccountErrorCode {
DELETE_SUPERUSER_ACCOUNT = "DELETE_SUPERUSER_ACCOUNT",
GRAPHQL_ERROR = "GRAPHQL_ERROR",
INVALID = "INVALID",
INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
INVALID_PASSWORD = "INVALID_PASSWORD",
LEFT_NOT_MANAGEABLE_PERMISSION = "LEFT_NOT_MANAGEABLE_PERMISSION",
NOT_FOUND = "NOT_FOUND",
OUT_OF_SCOPE_GROUP = "OUT_OF_SCOPE_GROUP",
OUT_OF_SCOPE_PERMISSION = "OUT_OF_SCOPE_PERMISSION",
OUT_OF_SCOPE_USER = "OUT_OF_SCOPE_USER",
PASSWORD_ENTIRELY_NUMERIC = "PASSWORD_ENTIRELY_NUMERIC",
PASSWORD_TOO_COMMON = "PASSWORD_TOO_COMMON",
PASSWORD_TOO_SHORT = "PASSWORD_TOO_SHORT",
@ -348,6 +353,7 @@ export enum CountryCode {
export enum DiscountErrorCode {
ALREADY_EXISTS = "ALREADY_EXISTS",
GRAPHQL_ERROR = "GRAPHQL_ERROR",
INVALID = "INVALID",
NOT_FOUND = "NOT_FOUND",
REQUIRED = "REQUIRED",
@ -633,6 +639,7 @@ export enum ServiceAccountSortField {
export enum ShippingErrorCode {
ALREADY_EXISTS = "ALREADY_EXISTS",
CANNOT_ADD_AND_REMOVE = "CANNOT_ADD_AND_REMOVE",
GRAPHQL_ERROR = "GRAPHQL_ERROR",
INVALID = "INVALID",
MAX_LESS_THAN_MIN = "MAX_LESS_THAN_MIN",
@ -1247,10 +1254,19 @@ export interface ShippingPriceInput {
shippingZone?: string | null;
}
export interface ShippingZoneInput {
export interface ShippingZoneCreateInput {
name?: string | null;
countries?: (string | null)[] | null;
default?: boolean | null;
addWarehouses?: (string | null)[] | null;
}
export interface ShippingZoneUpdateInput {
name?: string | null;
countries?: (string | null)[] | null;
default?: boolean | null;
addWarehouses?: (string | null)[] | null;
removeWarehouses?: (string | null)[] | null;
}
export interface ShopSettingsInput {
@ -1280,17 +1296,18 @@ export interface StaffCreateInput {
email?: string | null;
isActive?: boolean | null;
note?: string | null;
permissions?: (PermissionEnum | null)[] | null;
addGroups?: string[] | null;
redirectUrl?: string | null;
}
export interface StaffInput {
export interface StaffUpdateInput {
firstName?: string | null;
lastName?: string | null;
email?: string | null;
isActive?: boolean | null;
note?: string | null;
permissions?: (PermissionEnum | null)[] | null;
addGroups?: string[] | null;
removeGroups?: string[] | null;
}
export interface StaffUserInput {

18
src/utils/errors/staff.ts Normal file
View file

@ -0,0 +1,18 @@
import { IntlShape } from "react-intl";
import { StaffErrorFragment } from "@saleor/staff/types/StaffErrorFragment";
import getAccountErrorMessage from "./account";
function getStaffErrorMessage(
err: StaffErrorFragment,
intl: IntlShape
): string {
return getAccountErrorMessage(
err && {
...err,
__typename: "AccountError"
},
intl
);
}
export default getStaffErrorMessage;