diff --git a/.github/workflows/approveAndMergeReleasePR.js b/.github/workflows/approveAndMergeReleasePR.js index 09c524a41..80cd804d0 100644 --- a/.github/workflows/approveAndMergeReleasePR.js +++ b/.github/workflows/approveAndMergeReleasePR.js @@ -142,7 +142,7 @@ async function getTestsStatusAndId(dashboardUrl) { buildNumber: dashboardUrl.match(getRunRegex)[1], }; - const throwErrorAfterTimeout = setTimeout(function() { + const throwErrorAfterTimeout = setTimeout(function () { throw new Error("Run have still running status, after all tests executed"); }, 1200000); @@ -166,7 +166,7 @@ async function waitForTestsToFinish(requestVariables) { ) .then(response => { if (response.runByBuildNumber.status === "RUNNING") { - setTimeout(async function() { + setTimeout(async function () { resolve(await waitForTestsToFinish(requestVariables)); }, 10000); } else { diff --git a/cypress/e2e/configuration/attributes/attributeVariantSelection.js b/cypress/e2e/configuration/attributes/attributeVariantSelection.js index b83d05088..42190c65f 100644 --- a/cypress/e2e/configuration/attributes/attributeVariantSelection.js +++ b/cypress/e2e/configuration/attributes/attributeVariantSelection.js @@ -30,10 +30,10 @@ describe("As an admin I want to use attributes in variant selection", () => { cy.clearSessionData().loginUserViaRequest(); deleteProductsStartsWith(startsWith); getDefaultChannel().then(defaultChannel => (channel = defaultChannel)); - createCategory({ name: startsWith }).then( - categoryResp => (category = categoryResp), - ); - cy.checkIfDataAreNotNull({ channel, category }); + createCategory({ name: startsWith }).then(categoryResp => { + category = categoryResp; + cy.checkIfDataAreNotNull({ channel, category }); + }); }); beforeEach(() => { diff --git a/cypress/e2e/discounts/vouchers/createVouchers.js b/cypress/e2e/discounts/vouchers/createVouchers.js index 5e1c5de22..52860a592 100644 --- a/cypress/e2e/discounts/vouchers/createVouchers.js +++ b/cypress/e2e/discounts/vouchers/createVouchers.js @@ -53,6 +53,15 @@ describe("As an admin I want to create voucher", () => { shippingMethodName: shippingMethodResp.name, auth: "token", }; + + updateTaxConfigurationForChannel({ + channelSlug: defaultChannel.slug, + }); + cy.checkIfDataAreNotNull({ + createdChannel, + dataForCheckout, + defaultChannel, + }); }, ); cy.checkIfDataAreNotNull({ @@ -162,9 +171,7 @@ describe("As an admin I want to create voucher", () => { () => { const voucherCode = `${startsWith}${faker.datatype.number()}`; - cy.clearSessionData() - .loginUserViaRequest() - .visit(urlList.vouchers); + cy.clearSessionData().loginUserViaRequest().visit(urlList.vouchers); cy.expectSkeletonIsVisible(); createChannel({ name }).then(channel => { createdChannel = channel; diff --git a/cypress/e2e/discounts/vouchers/updateVouchers.js b/cypress/e2e/discounts/vouchers/updateVouchers.js index c3ede2a93..7c60ed1d9 100644 --- a/cypress/e2e/discounts/vouchers/updateVouchers.js +++ b/cypress/e2e/discounts/vouchers/updateVouchers.js @@ -52,8 +52,8 @@ describe("As an admin I want to update vouchers", () => { auth: "token", }; }, + cy.checkIfDataAreNotNull({ dataForCheckout, defaultChannel, product }), ); - cy.checkIfDataAreNotNull({ dataForCheckout, defaultChannel, product }); }); beforeEach(() => { diff --git a/cypress/e2e/products/productsWithoutSku/createProductWithoutSku.js b/cypress/e2e/products/productsWithoutSku/createProductWithoutSku.js index d57f81623..1ed19ca16 100644 --- a/cypress/e2e/products/productsWithoutSku/createProductWithoutSku.js +++ b/cypress/e2e/products/productsWithoutSku/createProductWithoutSku.js @@ -174,9 +174,7 @@ describe("Creating variants", () => { const name = `${startsWith}${faker.datatype.number()}`; const prices = { sellingPrice: 10, costPrice: 6 }; - cy.visit(urlList.products) - .get(PRODUCTS_LIST.createProductBtn) - .click(); + cy.visit(urlList.products).get(PRODUCTS_LIST.createProductBtn).click(); fillUpProductTypeDialog({ productType: simpleProductType.name }); cy.get(BUTTON_SELECTORS.submit) .click() diff --git a/cypress/e2e/staffMembers.js b/cypress/e2e/staffMembers.js index e072d42ab..ac8a0e02d 100644 --- a/cypress/e2e/staffMembers.js +++ b/cypress/e2e/staffMembers.js @@ -201,9 +201,7 @@ describe("Staff members", () => { .get(SHARED_ELEMENTS.searchInput) .type(`${email} {enter}`); cy.waitForProgressBarToNotExist(); - cy.get(STAFF_MEMBERS_LIST.staffAvatar) - .first() - .should("be.visible"); + cy.get(STAFF_MEMBERS_LIST.staffAvatar).first().should("be.visible"); cy.waitForProgressBarToNotExist() .get(STAFF_MEMBERS_LIST.staffStatusText) .first() @@ -245,19 +243,11 @@ describe("Staff members", () => { password: Cypress.env("USER_PASSWORD"), }); - cy.visit(urlList.staffMembers) - .get(LOGIN_SELECTORS.userMenu) - .click(); + cy.visit(urlList.staffMembers).get(LOGIN_SELECTORS.userMenu).click(); cy.get(LOGIN_SELECTORS.accountSettings).click(); - cy.get(STAFF_MEMBER_DETAILS.staffFirstName) - .clear() - .type("สมชาย"); - cy.get(STAFF_MEMBER_DETAILS.staffLastName) - .clear() - .type(newLastName); - cy.get(STAFF_MEMBER_DETAILS.staffEmail) - .clear() - .type(changedEmail); + cy.get(STAFF_MEMBER_DETAILS.staffFirstName).clear().type("สมชาย"); + cy.get(STAFF_MEMBER_DETAILS.staffLastName).clear().type(newLastName); + cy.get(STAFF_MEMBER_DETAILS.staffEmail).clear().type(changedEmail); // Test blocked from this point by https://github.com/saleor/saleor-dashboard/issues/2847 cy.get(BUTTON_SELECTORS.confirm).confirmationMessageShouldAppear(); @@ -295,9 +285,7 @@ describe("Staff members", () => { password: Cypress.env("USER_PASSWORD"), }); - cy.visit(urlList.staffMembers) - .get(LOGIN_SELECTORS.userMenu) - .click(); + cy.visit(urlList.staffMembers).get(LOGIN_SELECTORS.userMenu).click(); cy.get(LOGIN_SELECTORS.accountSettings).click(); cy.get(STAFF_MEMBER_DETAILS.changePasswordBtn).click(); cy.get(STAFF_MEMBER_DETAILS.changePasswordModal.oldPassword).type( @@ -306,9 +294,7 @@ describe("Staff members", () => { cy.get(STAFF_MEMBER_DETAILS.changePasswordModal.newPassword).type( newPass, ); - cy.get(BUTTON_SELECTORS.submit) - .click() - .confirmationMessageShouldAppear(); + cy.get(BUTTON_SELECTORS.submit).click().confirmationMessageShouldAppear(); cy.clearSessionData().loginUserViaRequest("auth", { email: newEmail, diff --git a/cypress/support/api/utils/taxesUtils.js b/cypress/support/api/utils/taxesUtils.js index 2f991ae8c..c49247475 100644 --- a/cypress/support/api/utils/taxesUtils.js +++ b/cypress/support/api/utils/taxesUtils.js @@ -6,7 +6,7 @@ import { export function updateTaxConfigurationForChannel({ channelSlug = "default-channel", - chargeTaxes = true, + chargeTaxes = false, taxCalculationStrategy = "FLAT_RATES", pricesEnteredWithTax = "false", }) { diff --git a/src/components/AppLayout/AppLayout.tsx b/src/components/AppLayout/AppLayout.tsx index 32a54efaf..99a333fd6 100644 --- a/src/components/AppLayout/AppLayout.tsx +++ b/src/components/AppLayout/AppLayout.tsx @@ -33,12 +33,8 @@ const AppLayout: React.FC = ({ const [appState] = useAppState(); const [isNavigatorVisible, setNavigatorVisibility] = React.useState(false); - const { - availableChannels, - channel, - isPickerActive, - setChannel, - } = useAppChannel(false); + const { availableChannels, channel, isPickerActive, setChannel } = + useAppChannel(false); const toggleTheme = () => setTheme(isDarkTheme(themeType) ? "light" : "dark"); diff --git a/src/custom-apps/views/CustomAppWebhookDetails.tsx b/src/custom-apps/views/CustomAppWebhookDetails.tsx index 8d57f96b8..67f1e68d8 100644 --- a/src/custom-apps/views/CustomAppWebhookDetails.tsx +++ b/src/custom-apps/views/CustomAppWebhookDetails.tsx @@ -20,9 +20,9 @@ export interface CustomAppWebhookDetailsProps { id: string; } -export const CustomAppWebhookDetails: React.FC = ({ - id, -}) => { +export const CustomAppWebhookDetails: React.FC< + CustomAppWebhookDetailsProps +> = ({ id }) => { const notify = useNotifier(); const intl = useIntl(); diff --git a/src/misc.ts b/src/misc.ts index decc1f82a..b61df2193 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -246,7 +246,7 @@ type InferPromiseResult = T extends Promise ? V : never; export const extractMutationErrors = async < TData extends InferPromiseResult, TPromise extends Promise>, - TErrors extends ReturnType + TErrors extends ReturnType, >( submitPromise: TPromise, ): Promise => { @@ -269,7 +269,7 @@ export const hasMutationErrors = (result: FetchResult): boolean => { export const getMutationErrors = < T extends FetchResult, TData extends T["data"], - TErrors extends TData[keyof TData]["errors"] + TErrors extends TData[keyof TData]["errors"], >( result: T, ): TErrors[] => { @@ -283,7 +283,7 @@ export const getMutationErrors = < }; export function getMutationStatus< - TData extends Record + TData extends Record, >(opts: MutationResult): ConfirmButtonTransitionState { const errors = getMutationErrors(opts); @@ -389,9 +389,7 @@ export function splitDateTime(dateTime: string) { }; } // Default html input format YYYY-MM-DD HH:mm - const splitDateTime = moment(dateTime) - .format("YYYY-MM-DD HH:mm") - .split(" "); + const splitDateTime = moment(dateTime).format("YYYY-MM-DD HH:mm").split(" "); return { date: splitDateTime[0], time: splitDateTime[1], @@ -430,7 +428,7 @@ export function findValueInEnum( throw new Error(`Value ${needle} not found in enum`); } - return (needle as unknown) as TEnum[keyof TEnum]; + return needle as unknown as TEnum[keyof TEnum]; } export function parseBoolean(a: string, defaultValue: boolean): boolean { @@ -521,10 +519,7 @@ export function PromiseQueue() { function add(operation: (value: T | void) => PromiseLike) { return new Promise((resolve, reject) => { - queue = queue - .then(operation) - .then(resolve) - .catch(reject); + queue = queue.then(operation).then(resolve).catch(reject); }); } @@ -545,9 +540,9 @@ export const getBySlug = (slugToCompare: string) => (obj: SlugNode) => export const getById = (idToCompare: string) => (obj: Node) => obj.id === idToCompare; -export const getByUnmatchingId = (idToCompare: string) => (obj: { - id: string; -}) => obj.id !== idToCompare; +export const getByUnmatchingId = + (idToCompare: string) => (obj: { id: string }) => + obj.id !== idToCompare; export const findById = (id: string, list?: T[]) => list?.find(getById(id)); diff --git a/src/new-apps/components/AppListPage/AppListPage.tsx b/src/new-apps/components/AppListPage/AppListPage.tsx index 046d30723..ee0d506eb 100644 --- a/src/new-apps/components/AppListPage/AppListPage.tsx +++ b/src/new-apps/components/AppListPage/AppListPage.tsx @@ -49,10 +49,11 @@ export const AppListPage: React.FC = props => { appsInstallations, installableMarketplaceApps, ); - const verifiedInstallableMarketplaceApps = getVerifiedInstallableMarketplaceApps( - installedApps, - installableMarketplaceApps, - ); + const verifiedInstallableMarketplaceApps = + getVerifiedInstallableMarketplaceApps( + installedApps, + installableMarketplaceApps, + ); const sectionsAvailability = resolveSectionsAvailability({ ...props, installableMarketplaceApps: verifiedInstallableMarketplaceApps, diff --git a/src/new-apps/components/AppListPage/utils.test.ts b/src/new-apps/components/AppListPage/utils.test.ts index b6629b644..2a0a06fca 100644 --- a/src/new-apps/components/AppListPage/utils.test.ts +++ b/src/new-apps/components/AppListPage/utils.test.ts @@ -341,10 +341,11 @@ describe("App List verified installable marketplace apps util", () => { ]; // Act - const verifiedInstallableMarketplaceApps = getVerifiedInstallableMarketplaceApps( - installedApps, - installableMarketplaceApps, - ); + const verifiedInstallableMarketplaceApps = + getVerifiedInstallableMarketplaceApps( + installedApps, + installableMarketplaceApps, + ); // Assert const expectedVerifiedInstallableMarketplaceApps = [ diff --git a/src/new-apps/hooks/useActiveAppsInstallations.ts b/src/new-apps/hooks/useActiveAppsInstallations.ts index 818e54598..35cf49a96 100644 --- a/src/new-apps/hooks/useActiveAppsInstallations.ts +++ b/src/new-apps/hooks/useActiveAppsInstallations.ts @@ -68,18 +68,16 @@ function useActiveAppsInstallations({ const handleAppInstallRetry = (id: string) => retryInstallApp({ variables: { id } }); - const [ - deleteInProgressApp, - deleteInProgressAppOpts, - ] = useAppDeleteFailedInstallationMutation({ - onCompleted: data => { - if (!data?.appDeleteFailedInstallation?.errors?.length) { - removeInProgressAppNotify(); - appsInProgressRefetch(); - onRemoveInProgressAppSuccess(); - } - }, - }); + const [deleteInProgressApp, deleteInProgressAppOpts] = + useAppDeleteFailedInstallationMutation({ + onCompleted: data => { + if (!data?.appDeleteFailedInstallation?.errors?.length) { + removeInProgressAppNotify(); + appsInProgressRefetch(); + onRemoveInProgressAppSuccess(); + } + }, + }); const handleRemoveInProgress = (id: string) => deleteInProgressApp({ diff --git a/src/new-apps/utils.ts b/src/new-apps/utils.ts index cdeecd967..46134c8c9 100644 --- a/src/new-apps/utils.ts +++ b/src/new-apps/utils.ts @@ -56,9 +56,8 @@ export const getMarketplaceAppsLists = ( } return { - installableMarketplaceApps: getInstallableMarketplaceApps( - marketplaceAppList, - ), + installableMarketplaceApps: + getInstallableMarketplaceApps(marketplaceAppList), comingSoonMarketplaceApps: getComingSoonMarketplaceApps(marketplaceAppList), }; }; diff --git a/src/new-apps/views/AppList/AppList.tsx b/src/new-apps/views/AppList/AppList.tsx index e92cd8437..93978b450 100644 --- a/src/new-apps/views/AppList/AppList.tsx +++ b/src/new-apps/views/AppList/AppList.tsx @@ -86,12 +86,10 @@ export const AppsList: React.FC = ({ params }) => { paginationState, ); - const { - data: appsInProgressData, - refetch: appsInProgressRefetch, - } = useAppsInstallationsQuery({ - displayLoader: false, - }); + const { data: appsInProgressData, refetch: appsInProgressRefetch } = + useAppsInstallationsQuery({ + displayLoader: false, + }); const installedAppNotify = (name: string) => { notify({ @@ -149,13 +147,8 @@ export const AppsList: React.FC = ({ params }) => { AppsConfig.marketplaceApiUri, ); - const { - installableMarketplaceApps, - comingSoonMarketplaceApps, - } = getMarketplaceAppsLists( - !!AppsConfig.marketplaceApiUri, - marketplaceAppList, - ); + const { installableMarketplaceApps, comingSoonMarketplaceApps } = + getMarketplaceAppsLists(!!AppsConfig.marketplaceApiUri, marketplaceAppList); const appsInstallations = appsInProgressData?.appsInstallations; const installedApps = mapEdgesToItems(installedAppsData?.apps); diff --git a/src/staff/views/StaffDetails.tsx b/src/staff/views/StaffDetails.tsx index 7062b8f8d..56bc0ee2f 100644 --- a/src/staff/views/StaffDetails.tsx +++ b/src/staff/views/StaffDetails.tsx @@ -91,19 +91,17 @@ export const StaffDetails: React.FC = ({ id, params }) => { skip: !hasManageStaffPermission, }); - const [ - updateStaffMember, - updateStaffMemberOpts, - ] = useStaffMemberUpdateMutation({ - onCompleted: data => { - if (!maybe(() => data.staffUpdate.errors.length !== 0)) { - notify({ - status: "success", - text: intl.formatMessage(commonMessages.savedChanges), - }); - } - }, - }); + const [updateStaffMember, updateStaffMemberOpts] = + useStaffMemberUpdateMutation({ + onCompleted: data => { + if (!maybe(() => data.staffUpdate.errors.length !== 0)) { + notify({ + status: "success", + text: intl.formatMessage(commonMessages.savedChanges), + }); + } + }, + }); const [deleteStaffMember, deleteResult] = useStaffMemberDeleteMutation({ onCompleted: data => { diff --git a/src/taxes/pages/TaxClassesPage/TaxClassesPage.tsx b/src/taxes/pages/TaxClassesPage/TaxClassesPage.tsx index b64620819..8e4cdd2be 100644 --- a/src/taxes/pages/TaxClassesPage/TaxClassesPage.tsx +++ b/src/taxes/pages/TaxClassesPage/TaxClassesPage.tsx @@ -109,9 +109,11 @@ export const TaxClassesPage: React.FC = props => { rate => rate.label.search(new RegExp(parseQuery(query), "i")) >= 0, ); - const { data: paginatedRates, hasNextPage, hasPreviousPage } = paginate( - filteredRates, - ); + const { + data: paginatedRates, + hasNextPage, + hasPreviousPage, + } = paginate(filteredRates); const formErrors = getFormErrors(["name"], validationErrors); diff --git a/src/utils/errors/common.ts b/src/utils/errors/common.ts index b257a741a..5ce1d7ba0 100644 --- a/src/utils/errors/common.ts +++ b/src/utils/errors/common.ts @@ -22,7 +22,8 @@ export const CommonErrorCode = { REQUIRED: "REQUIRED", } as const; -export type CommonErrorCode = typeof CommonErrorCode[keyof typeof CommonErrorCode]; +export type CommonErrorCode = + (typeof CommonErrorCode)[keyof typeof CommonErrorCode]; export interface CommonError { code: ErrorCode | CommonErrorCode; diff --git a/src/utils/errors/index.ts b/src/utils/errors/index.ts index 5cfaa7886..d6b6c34dc 100644 --- a/src/utils/errors/index.ts +++ b/src/utils/errors/index.ts @@ -9,7 +9,7 @@ export function getFieldError( export type FormErrors< TField extends string, - TError extends UserError + TError extends UserError, > = Record; export function getFormErrors( @@ -19,7 +19,7 @@ export function getFormErrors( return fields.reduce((errs, field) => { errs[field] = getFieldError(errors, field); return errs; - }, ({} as unknown) as Record); + }, {} as unknown as Record); } export interface ChannelError { @@ -36,7 +36,7 @@ export function getFieldChannelError( export function getFormChannelErrors< TField extends string, - TError extends ChannelError + TError extends ChannelError, >(fields: TField[], errors: TError[]) { return fields.reduce((errs, field) => { errs[field] = [ diff --git a/src/utils/filters/filters.ts b/src/utils/filters/filters.ts index 9a2216a8f..e923479c1 100644 --- a/src/utils/filters/filters.ts +++ b/src/utils/filters/filters.ts @@ -10,7 +10,7 @@ import isArray from "lodash/isArray"; function createFilterUtils< TQueryParams extends {}, - TFilters extends {} + TFilters extends {}, >(filters: {}) { function getActiveFilters(params: TQueryParams): TFilters { return Object.keys(params) @@ -30,7 +30,7 @@ function createFilterUtils< tabs: unknown[], ) { return params.activeTab === undefined - ? areFiltersApplied((params as unknown) as TQueryParams) + ? areFiltersApplied(params as unknown as TQueryParams) ? tabs.length + 1 : 0 : parseInt(params.activeTab, 10); @@ -53,11 +53,11 @@ export function dedupeFilter(array: T[]): T[] { export type GetFilterQueryParam< TFilterKeys extends string, - TFilters extends {} + TFilters extends {}, > = (filter: FilterElement, params?: {}) => TFilters; export function getFilterQueryParams< TFilterKeys extends string, - TUrlFilters extends {} + TUrlFilters extends {}, >( filters: IFilter, getFilterQueryParam: GetFilterQueryParam, @@ -87,7 +87,7 @@ export function getGteLteVariables(variables: GteLte): GteLte | null { export function getSingleValueQueryParam< TKey extends string, - TUrlKey extends string + TUrlKey extends string, >(param: FilterElement, key: TUrlKey) { const { active, value } = param; @@ -105,7 +105,7 @@ export function getSingleValueQueryParam< export function getSingleEnumValueQueryParam< TKey extends string, TUrlKey extends string, - TEnum extends {} + TEnum extends {}, >(param: FilterElementRegular, key: TUrlKey, haystack: TEnum) { const { active, value } = param; @@ -123,7 +123,7 @@ export function getSingleEnumValueQueryParam< export function getMultipleEnumValueQueryParam< TKey extends string, TUrlKey extends string, - TEnum extends {} + TEnum extends {}, >(param: FilterElementRegular, key: TUrlKey, haystack: TEnum) { const { active, value } = param; @@ -140,7 +140,7 @@ export function getMultipleEnumValueQueryParam< export function getMultipleValueQueryParam< TKey extends string, - TUrlKey extends string + TUrlKey extends string, >(param: FilterElement, key: TUrlKey) { const { active, value } = param; @@ -157,7 +157,7 @@ export function getMultipleValueQueryParam< export function getMinMaxQueryParam< TKey extends string, - TUrlKey extends string + TUrlKey extends string, >(param: FilterElement, keyFrom: TUrlKey, keyTo: TUrlKey) { const { active, multiple, value } = param; @@ -183,7 +183,7 @@ export function getMinMaxQueryParam< export function getKeyValueQueryParam< TKey extends string, - TUrlKey extends string + TUrlKey extends string, >(param: FilterElementKeyValue, key: TUrlKey) { const { active, value } = param; diff --git a/src/utils/handlers/filterHandlers.ts b/src/utils/handlers/filterHandlers.ts index 0ba1cb8d0..28858608a 100644 --- a/src/utils/handlers/filterHandlers.ts +++ b/src/utils/handlers/filterHandlers.ts @@ -14,7 +14,7 @@ type CreateFilterHandlers = [ function createFilterHandlers< TFilterKeys extends string, - TFilters extends {} + TFilters extends {}, >(opts: { getFilterQueryParam: GetFilterQueryParam; navigate: UseNavigatorResult; diff --git a/src/utils/maps.ts b/src/utils/maps.ts index 5c729096b..85949e2d5 100644 --- a/src/utils/maps.ts +++ b/src/utils/maps.ts @@ -56,7 +56,7 @@ export function mapNodeToChoice( ): Array>; export function mapNodeToChoice< T extends ExtendedNode | Node, - K extends ChoiceValue + K extends ChoiceValue, >(nodes: T[], getterFn: (node: T) => K): Array>; export function mapNodeToChoice( diff --git a/src/utils/menu/menu.ts b/src/utils/menu/menu.ts index f0435291b..56839fb61 100644 --- a/src/utils/menu/menu.ts +++ b/src/utils/menu/menu.ts @@ -58,9 +58,8 @@ export function getMenuItemByValue( value: TValue, ): IMenuItem { const flatMenu = toFlat(menu); - const flatMenuItem: - | IFlatMenuItem - | undefined = flatMenu.find(menuItem => menuItem.value === value); + const flatMenuItem: IFlatMenuItem | undefined = + flatMenu.find(menuItem => menuItem.value === value); if (flatMenuItem === undefined) { throw new Error(`Value ${value} does not exist in menu`); @@ -117,9 +116,10 @@ export function walkToRoot( throw new Error(`Value ${value} does not exist in menu`); } - return (menuItem.parent === null - ? [menuItem] - : [menuItem, ..._walkToRoot(flatMenu, menuItem.parent)] + return ( + menuItem.parent === null + ? [menuItem] + : [menuItem, ..._walkToRoot(flatMenu, menuItem.parent)] ).map(flatMenuItem => _fromFlat(flatMenu, flatMenuItem)); } diff --git a/src/utils/sort.ts b/src/utils/sort.ts index 05fef6c65..9423199f0 100644 --- a/src/utils/sort.ts +++ b/src/utils/sort.ts @@ -32,7 +32,7 @@ export function getArrowDirection(asc: boolean): TableCellHeaderArrowDirection { // Extracts Sort object from the querystring export function getSortParams< TParams extends Sort, - TFields extends string + TFields extends string, >(params: TParams): Sort { return { asc: params.asc, @@ -43,7 +43,7 @@ export function getSortParams< // Appends Sort object to the querystring params export function asSortParams< TParams extends Record, - TFields extends Record + TFields extends Record, >( params: TParams, fields: TFields, @@ -71,12 +71,12 @@ type GetSortQueryField = ( ) => TSortField; type GetSortQueryVariables< TSortField extends string, - TParams extends Record + TParams extends Record, > = (params: TParams) => SortingInput | undefined; export function createGetSortQueryVariables< TUrlField extends string, TSortField extends string, - TParams extends Record + TParams extends Record, >( getSortQueryField: GetSortQueryField, ): GetSortQueryVariables { diff --git a/src/warehouses/components/WarehouseCreatePage/WarehouseCreatePage.stories.tsx b/src/warehouses/components/WarehouseCreatePage/WarehouseCreatePage.stories.tsx index 6e0185459..d18bc5afd 100644 --- a/src/warehouses/components/WarehouseCreatePage/WarehouseCreatePage.stories.tsx +++ b/src/warehouses/components/WarehouseCreatePage/WarehouseCreatePage.stories.tsx @@ -27,18 +27,20 @@ storiesOf("Warehouses / Create warehouse", module) .add("form errors", () => ( ).map(field => ({ + errors={( + [ + "name", + "city", + "cityArea", + "companyName", + "country", + "countryArea", + "phone", + "postalCode", + "streetAddress1", + "streetAddress2", + ] as Array + ).map(field => ({ __typename: "WarehouseError", code: WarehouseErrorCode.INVALID, field, diff --git a/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.stories.tsx b/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.stories.tsx index 942014a11..966618fc6 100644 --- a/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.stories.tsx +++ b/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.stories.tsx @@ -32,18 +32,20 @@ storiesOf("Warehouses / Warehouse details", module) .add("form errors", () => ( ).map(field => ({ + errors={( + [ + "name", + "city", + "cityArea", + "companyName", + "country", + "countryArea", + "phone", + "postalCode", + "streetAddress1", + "streetAddress2", + ] as Array + ).map(field => ({ __typename: "WarehouseError", code: WarehouseErrorCode.INVALID, field, diff --git a/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.tsx b/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.tsx index aecebc79a..0c68a4ea3 100644 --- a/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.tsx +++ b/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.tsx @@ -60,10 +60,8 @@ const WarehouseDetailsPage: React.FC = ({ warehouse?.address?.country.country || "", ); - const { - errors: validationErrors, - submit: handleSubmit, - } = useAddressValidation(onSubmit); + const { errors: validationErrors, submit: handleSubmit } = + useAddressValidation(onSubmit); const initialForm: WarehouseDetailsPageFormData = { city: warehouse?.address.city ?? "", diff --git a/src/warehouses/views/WarehouseList/sort.ts b/src/warehouses/views/WarehouseList/sort.ts index 65d857d23..0c3217a4f 100644 --- a/src/warehouses/views/WarehouseList/sort.ts +++ b/src/warehouses/views/WarehouseList/sort.ts @@ -13,6 +13,5 @@ export function getSortQueryField( } } -export const getSortQueryVariables = createGetSortQueryVariables( - getSortQueryField, -); +export const getSortQueryVariables = + createGetSortQueryVariables(getSortQueryField); diff --git a/testUtils/globalSetup.ts b/testUtils/globalSetup.ts index 02bed55a2..7027d24e0 100644 --- a/testUtils/globalSetup.ts +++ b/testUtils/globalSetup.ts @@ -1,3 +1,3 @@ -module.exports = async function() { +module.exports = async function () { process.env.TZ = "UTC"; };