update tax configuration before creating vouchers (#2939)

This commit is contained in:
Karolina Rakoczy 2023-01-25 13:32:30 +01:00 committed by GitHub
parent ee00b27795
commit d413c8e852
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 144 additions and 168 deletions

View file

@ -142,7 +142,7 @@ async function getTestsStatusAndId(dashboardUrl) {
buildNumber: dashboardUrl.match(getRunRegex)[1], 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"); throw new Error("Run have still running status, after all tests executed");
}, 1200000); }, 1200000);
@ -166,7 +166,7 @@ async function waitForTestsToFinish(requestVariables) {
) )
.then(response => { .then(response => {
if (response.runByBuildNumber.status === "RUNNING") { if (response.runByBuildNumber.status === "RUNNING") {
setTimeout(async function() { setTimeout(async function () {
resolve(await waitForTestsToFinish(requestVariables)); resolve(await waitForTestsToFinish(requestVariables));
}, 10000); }, 10000);
} else { } else {

View file

@ -30,11 +30,11 @@ describe("As an admin I want to use attributes in variant selection", () => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();
deleteProductsStartsWith(startsWith); deleteProductsStartsWith(startsWith);
getDefaultChannel().then(defaultChannel => (channel = defaultChannel)); getDefaultChannel().then(defaultChannel => (channel = defaultChannel));
createCategory({ name: startsWith }).then( createCategory({ name: startsWith }).then(categoryResp => {
categoryResp => (category = categoryResp), category = categoryResp;
);
cy.checkIfDataAreNotNull({ channel, category }); cy.checkIfDataAreNotNull({ channel, category });
}); });
});
beforeEach(() => { beforeEach(() => {
cy.clearSessionData().loginUserViaRequest(); cy.clearSessionData().loginUserViaRequest();

View file

@ -53,6 +53,15 @@ describe("As an admin I want to create voucher", () => {
shippingMethodName: shippingMethodResp.name, shippingMethodName: shippingMethodResp.name,
auth: "token", auth: "token",
}; };
updateTaxConfigurationForChannel({
channelSlug: defaultChannel.slug,
});
cy.checkIfDataAreNotNull({
createdChannel,
dataForCheckout,
defaultChannel,
});
}, },
); );
cy.checkIfDataAreNotNull({ cy.checkIfDataAreNotNull({
@ -162,9 +171,7 @@ describe("As an admin I want to create voucher", () => {
() => { () => {
const voucherCode = `${startsWith}${faker.datatype.number()}`; const voucherCode = `${startsWith}${faker.datatype.number()}`;
cy.clearSessionData() cy.clearSessionData().loginUserViaRequest().visit(urlList.vouchers);
.loginUserViaRequest()
.visit(urlList.vouchers);
cy.expectSkeletonIsVisible(); cy.expectSkeletonIsVisible();
createChannel({ name }).then(channel => { createChannel({ name }).then(channel => {
createdChannel = channel; createdChannel = channel;

View file

@ -52,8 +52,8 @@ describe("As an admin I want to update vouchers", () => {
auth: "token", auth: "token",
}; };
}, },
cy.checkIfDataAreNotNull({ dataForCheckout, defaultChannel, product }),
); );
cy.checkIfDataAreNotNull({ dataForCheckout, defaultChannel, product });
}); });
beforeEach(() => { beforeEach(() => {

View file

@ -174,9 +174,7 @@ describe("Creating variants", () => {
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
const prices = { sellingPrice: 10, costPrice: 6 }; const prices = { sellingPrice: 10, costPrice: 6 };
cy.visit(urlList.products) cy.visit(urlList.products).get(PRODUCTS_LIST.createProductBtn).click();
.get(PRODUCTS_LIST.createProductBtn)
.click();
fillUpProductTypeDialog({ productType: simpleProductType.name }); fillUpProductTypeDialog({ productType: simpleProductType.name });
cy.get(BUTTON_SELECTORS.submit) cy.get(BUTTON_SELECTORS.submit)
.click() .click()

View file

@ -201,9 +201,7 @@ describe("Staff members", () => {
.get(SHARED_ELEMENTS.searchInput) .get(SHARED_ELEMENTS.searchInput)
.type(`${email} {enter}`); .type(`${email} {enter}`);
cy.waitForProgressBarToNotExist(); cy.waitForProgressBarToNotExist();
cy.get(STAFF_MEMBERS_LIST.staffAvatar) cy.get(STAFF_MEMBERS_LIST.staffAvatar).first().should("be.visible");
.first()
.should("be.visible");
cy.waitForProgressBarToNotExist() cy.waitForProgressBarToNotExist()
.get(STAFF_MEMBERS_LIST.staffStatusText) .get(STAFF_MEMBERS_LIST.staffStatusText)
.first() .first()
@ -245,19 +243,11 @@ describe("Staff members", () => {
password: Cypress.env("USER_PASSWORD"), password: Cypress.env("USER_PASSWORD"),
}); });
cy.visit(urlList.staffMembers) cy.visit(urlList.staffMembers).get(LOGIN_SELECTORS.userMenu).click();
.get(LOGIN_SELECTORS.userMenu)
.click();
cy.get(LOGIN_SELECTORS.accountSettings).click(); cy.get(LOGIN_SELECTORS.accountSettings).click();
cy.get(STAFF_MEMBER_DETAILS.staffFirstName) cy.get(STAFF_MEMBER_DETAILS.staffFirstName).clear().type("สมชาย");
.clear() cy.get(STAFF_MEMBER_DETAILS.staffLastName).clear().type(newLastName);
.type("สมชาย"); cy.get(STAFF_MEMBER_DETAILS.staffEmail).clear().type(changedEmail);
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 // Test blocked from this point by https://github.com/saleor/saleor-dashboard/issues/2847
cy.get(BUTTON_SELECTORS.confirm).confirmationMessageShouldAppear(); cy.get(BUTTON_SELECTORS.confirm).confirmationMessageShouldAppear();
@ -295,9 +285,7 @@ describe("Staff members", () => {
password: Cypress.env("USER_PASSWORD"), password: Cypress.env("USER_PASSWORD"),
}); });
cy.visit(urlList.staffMembers) cy.visit(urlList.staffMembers).get(LOGIN_SELECTORS.userMenu).click();
.get(LOGIN_SELECTORS.userMenu)
.click();
cy.get(LOGIN_SELECTORS.accountSettings).click(); cy.get(LOGIN_SELECTORS.accountSettings).click();
cy.get(STAFF_MEMBER_DETAILS.changePasswordBtn).click(); cy.get(STAFF_MEMBER_DETAILS.changePasswordBtn).click();
cy.get(STAFF_MEMBER_DETAILS.changePasswordModal.oldPassword).type( cy.get(STAFF_MEMBER_DETAILS.changePasswordModal.oldPassword).type(
@ -306,9 +294,7 @@ describe("Staff members", () => {
cy.get(STAFF_MEMBER_DETAILS.changePasswordModal.newPassword).type( cy.get(STAFF_MEMBER_DETAILS.changePasswordModal.newPassword).type(
newPass, newPass,
); );
cy.get(BUTTON_SELECTORS.submit) cy.get(BUTTON_SELECTORS.submit).click().confirmationMessageShouldAppear();
.click()
.confirmationMessageShouldAppear();
cy.clearSessionData().loginUserViaRequest("auth", { cy.clearSessionData().loginUserViaRequest("auth", {
email: newEmail, email: newEmail,

View file

@ -6,7 +6,7 @@ import {
export function updateTaxConfigurationForChannel({ export function updateTaxConfigurationForChannel({
channelSlug = "default-channel", channelSlug = "default-channel",
chargeTaxes = true, chargeTaxes = false,
taxCalculationStrategy = "FLAT_RATES", taxCalculationStrategy = "FLAT_RATES",
pricesEnteredWithTax = "false", pricesEnteredWithTax = "false",
}) { }) {

View file

@ -33,12 +33,8 @@ const AppLayout: React.FC<AppLayoutProps> = ({
const [appState] = useAppState(); const [appState] = useAppState();
const [isNavigatorVisible, setNavigatorVisibility] = React.useState(false); const [isNavigatorVisible, setNavigatorVisibility] = React.useState(false);
const { const { availableChannels, channel, isPickerActive, setChannel } =
availableChannels, useAppChannel(false);
channel,
isPickerActive,
setChannel,
} = useAppChannel(false);
const toggleTheme = () => setTheme(isDarkTheme(themeType) ? "light" : "dark"); const toggleTheme = () => setTheme(isDarkTheme(themeType) ? "light" : "dark");

View file

@ -20,9 +20,9 @@ export interface CustomAppWebhookDetailsProps {
id: string; id: string;
} }
export const CustomAppWebhookDetails: React.FC<CustomAppWebhookDetailsProps> = ({ export const CustomAppWebhookDetails: React.FC<
id, CustomAppWebhookDetailsProps
}) => { > = ({ id }) => {
const notify = useNotifier(); const notify = useNotifier();
const intl = useIntl(); const intl = useIntl();

View file

@ -246,7 +246,7 @@ type InferPromiseResult<T> = T extends Promise<infer V> ? V : never;
export const extractMutationErrors = async < export const extractMutationErrors = async <
TData extends InferPromiseResult<TPromise>, TData extends InferPromiseResult<TPromise>,
TPromise extends Promise<FetchResult<TData>>, TPromise extends Promise<FetchResult<TData>>,
TErrors extends ReturnType<typeof getMutationErrors> TErrors extends ReturnType<typeof getMutationErrors>,
>( >(
submitPromise: TPromise, submitPromise: TPromise,
): Promise<TErrors> => { ): Promise<TErrors> => {
@ -269,7 +269,7 @@ export const hasMutationErrors = (result: FetchResult): boolean => {
export const getMutationErrors = < export const getMutationErrors = <
T extends FetchResult<any>, T extends FetchResult<any>,
TData extends T["data"], TData extends T["data"],
TErrors extends TData[keyof TData]["errors"] TErrors extends TData[keyof TData]["errors"],
>( >(
result: T, result: T,
): TErrors[] => { ): TErrors[] => {
@ -283,7 +283,7 @@ export const getMutationErrors = <
}; };
export function getMutationStatus< export function getMutationStatus<
TData extends Record<string, SaleorMutationResult | any> TData extends Record<string, SaleorMutationResult | any>,
>(opts: MutationResult<TData>): ConfirmButtonTransitionState { >(opts: MutationResult<TData>): ConfirmButtonTransitionState {
const errors = getMutationErrors(opts); const errors = getMutationErrors(opts);
@ -389,9 +389,7 @@ export function splitDateTime(dateTime: string) {
}; };
} }
// Default html input format YYYY-MM-DD HH:mm // Default html input format YYYY-MM-DD HH:mm
const splitDateTime = moment(dateTime) const splitDateTime = moment(dateTime).format("YYYY-MM-DD HH:mm").split(" ");
.format("YYYY-MM-DD HH:mm")
.split(" ");
return { return {
date: splitDateTime[0], date: splitDateTime[0],
time: splitDateTime[1], time: splitDateTime[1],
@ -430,7 +428,7 @@ export function findValueInEnum<TEnum extends {}>(
throw new Error(`Value ${needle} not found in enum`); 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 { export function parseBoolean(a: string, defaultValue: boolean): boolean {
@ -521,10 +519,7 @@ export function PromiseQueue() {
function add<T>(operation: (value: T | void) => PromiseLike<T>) { function add<T>(operation: (value: T | void) => PromiseLike<T>) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
queue = queue queue = queue.then(operation).then(resolve).catch(reject);
.then(operation)
.then(resolve)
.catch(reject);
}); });
} }
@ -545,9 +540,9 @@ export const getBySlug = (slugToCompare: string) => (obj: SlugNode) =>
export const getById = (idToCompare: string) => (obj: Node) => export const getById = (idToCompare: string) => (obj: Node) =>
obj.id === idToCompare; obj.id === idToCompare;
export const getByUnmatchingId = (idToCompare: string) => (obj: { export const getByUnmatchingId =
id: string; (idToCompare: string) => (obj: { id: string }) =>
}) => obj.id !== idToCompare; obj.id !== idToCompare;
export const findById = <T extends Node>(id: string, list?: T[]) => export const findById = <T extends Node>(id: string, list?: T[]) =>
list?.find(getById(id)); list?.find(getById(id));

View file

@ -49,7 +49,8 @@ export const AppListPage: React.FC<AppListPageProps> = props => {
appsInstallations, appsInstallations,
installableMarketplaceApps, installableMarketplaceApps,
); );
const verifiedInstallableMarketplaceApps = getVerifiedInstallableMarketplaceApps( const verifiedInstallableMarketplaceApps =
getVerifiedInstallableMarketplaceApps(
installedApps, installedApps,
installableMarketplaceApps, installableMarketplaceApps,
); );

View file

@ -341,7 +341,8 @@ describe("App List verified installable marketplace apps util", () => {
]; ];
// Act // Act
const verifiedInstallableMarketplaceApps = getVerifiedInstallableMarketplaceApps( const verifiedInstallableMarketplaceApps =
getVerifiedInstallableMarketplaceApps(
installedApps, installedApps,
installableMarketplaceApps, installableMarketplaceApps,
); );

View file

@ -68,10 +68,8 @@ function useActiveAppsInstallations({
const handleAppInstallRetry = (id: string) => const handleAppInstallRetry = (id: string) =>
retryInstallApp({ variables: { id } }); retryInstallApp({ variables: { id } });
const [ const [deleteInProgressApp, deleteInProgressAppOpts] =
deleteInProgressApp, useAppDeleteFailedInstallationMutation({
deleteInProgressAppOpts,
] = useAppDeleteFailedInstallationMutation({
onCompleted: data => { onCompleted: data => {
if (!data?.appDeleteFailedInstallation?.errors?.length) { if (!data?.appDeleteFailedInstallation?.errors?.length) {
removeInProgressAppNotify(); removeInProgressAppNotify();

View file

@ -56,9 +56,8 @@ export const getMarketplaceAppsLists = (
} }
return { return {
installableMarketplaceApps: getInstallableMarketplaceApps( installableMarketplaceApps:
marketplaceAppList, getInstallableMarketplaceApps(marketplaceAppList),
),
comingSoonMarketplaceApps: getComingSoonMarketplaceApps(marketplaceAppList), comingSoonMarketplaceApps: getComingSoonMarketplaceApps(marketplaceAppList),
}; };
}; };

View file

@ -86,10 +86,8 @@ export const AppsList: React.FC<AppsListProps> = ({ params }) => {
paginationState, paginationState,
); );
const { const { data: appsInProgressData, refetch: appsInProgressRefetch } =
data: appsInProgressData, useAppsInstallationsQuery({
refetch: appsInProgressRefetch,
} = useAppsInstallationsQuery({
displayLoader: false, displayLoader: false,
}); });
@ -149,13 +147,8 @@ export const AppsList: React.FC<AppsListProps> = ({ params }) => {
AppsConfig.marketplaceApiUri, AppsConfig.marketplaceApiUri,
); );
const { const { installableMarketplaceApps, comingSoonMarketplaceApps } =
installableMarketplaceApps, getMarketplaceAppsLists(!!AppsConfig.marketplaceApiUri, marketplaceAppList);
comingSoonMarketplaceApps,
} = getMarketplaceAppsLists(
!!AppsConfig.marketplaceApiUri,
marketplaceAppList,
);
const appsInstallations = appsInProgressData?.appsInstallations; const appsInstallations = appsInProgressData?.appsInstallations;
const installedApps = mapEdgesToItems(installedAppsData?.apps); const installedApps = mapEdgesToItems(installedAppsData?.apps);

View file

@ -91,10 +91,8 @@ export const StaffDetails: React.FC<OrderListProps> = ({ id, params }) => {
skip: !hasManageStaffPermission, skip: !hasManageStaffPermission,
}); });
const [ const [updateStaffMember, updateStaffMemberOpts] =
updateStaffMember, useStaffMemberUpdateMutation({
updateStaffMemberOpts,
] = useStaffMemberUpdateMutation({
onCompleted: data => { onCompleted: data => {
if (!maybe(() => data.staffUpdate.errors.length !== 0)) { if (!maybe(() => data.staffUpdate.errors.length !== 0)) {
notify({ notify({

View file

@ -109,9 +109,11 @@ export const TaxClassesPage: React.FC<TaxClassesPageProps> = props => {
rate => rate.label.search(new RegExp(parseQuery(query), "i")) >= 0, rate => rate.label.search(new RegExp(parseQuery(query), "i")) >= 0,
); );
const { data: paginatedRates, hasNextPage, hasPreviousPage } = paginate( const {
filteredRates, data: paginatedRates,
); hasNextPage,
hasPreviousPage,
} = paginate(filteredRates);
const formErrors = getFormErrors(["name"], validationErrors); const formErrors = getFormErrors(["name"], validationErrors);

View file

@ -22,7 +22,8 @@ export const CommonErrorCode = {
REQUIRED: "REQUIRED", REQUIRED: "REQUIRED",
} as const; } as const;
export type CommonErrorCode = typeof CommonErrorCode[keyof typeof CommonErrorCode]; export type CommonErrorCode =
(typeof CommonErrorCode)[keyof typeof CommonErrorCode];
export interface CommonError<ErrorCode> { export interface CommonError<ErrorCode> {
code: ErrorCode | CommonErrorCode; code: ErrorCode | CommonErrorCode;

View file

@ -9,7 +9,7 @@ export function getFieldError<T extends UserError>(
export type FormErrors< export type FormErrors<
TField extends string, TField extends string,
TError extends UserError TError extends UserError,
> = Record<TField, TError | undefined>; > = Record<TField, TError | undefined>;
export function getFormErrors<TField extends string, TError extends UserError>( export function getFormErrors<TField extends string, TError extends UserError>(
@ -19,7 +19,7 @@ export function getFormErrors<TField extends string, TError extends UserError>(
return fields.reduce((errs, field) => { return fields.reduce((errs, field) => {
errs[field] = getFieldError(errors, field); errs[field] = getFieldError(errors, field);
return errs; return errs;
}, ({} as unknown) as Record<TField, TError | undefined>); }, {} as unknown as Record<TField, TError | undefined>);
} }
export interface ChannelError { export interface ChannelError {
@ -36,7 +36,7 @@ export function getFieldChannelError<T extends ChannelError>(
export function getFormChannelErrors< export function getFormChannelErrors<
TField extends string, TField extends string,
TError extends ChannelError TError extends ChannelError,
>(fields: TField[], errors: TError[]) { >(fields: TField[], errors: TError[]) {
return fields.reduce((errs, field) => { return fields.reduce((errs, field) => {
errs[field] = [ errs[field] = [

View file

@ -10,7 +10,7 @@ import isArray from "lodash/isArray";
function createFilterUtils< function createFilterUtils<
TQueryParams extends {}, TQueryParams extends {},
TFilters extends {} TFilters extends {},
>(filters: {}) { >(filters: {}) {
function getActiveFilters(params: TQueryParams): TFilters { function getActiveFilters(params: TQueryParams): TFilters {
return Object.keys(params) return Object.keys(params)
@ -30,7 +30,7 @@ function createFilterUtils<
tabs: unknown[], tabs: unknown[],
) { ) {
return params.activeTab === undefined return params.activeTab === undefined
? areFiltersApplied((params as unknown) as TQueryParams) ? areFiltersApplied(params as unknown as TQueryParams)
? tabs.length + 1 ? tabs.length + 1
: 0 : 0
: parseInt(params.activeTab, 10); : parseInt(params.activeTab, 10);
@ -53,11 +53,11 @@ export function dedupeFilter<T>(array: T[]): T[] {
export type GetFilterQueryParam< export type GetFilterQueryParam<
TFilterKeys extends string, TFilterKeys extends string,
TFilters extends {} TFilters extends {},
> = (filter: FilterElement<TFilterKeys>, params?: {}) => TFilters; > = (filter: FilterElement<TFilterKeys>, params?: {}) => TFilters;
export function getFilterQueryParams< export function getFilterQueryParams<
TFilterKeys extends string, TFilterKeys extends string,
TUrlFilters extends {} TUrlFilters extends {},
>( >(
filters: IFilter<TFilterKeys>, filters: IFilter<TFilterKeys>,
getFilterQueryParam: GetFilterQueryParam<TFilterKeys, TUrlFilters>, getFilterQueryParam: GetFilterQueryParam<TFilterKeys, TUrlFilters>,
@ -87,7 +87,7 @@ export function getGteLteVariables<T>(variables: GteLte<T>): GteLte<T> | null {
export function getSingleValueQueryParam< export function getSingleValueQueryParam<
TKey extends string, TKey extends string,
TUrlKey extends string TUrlKey extends string,
>(param: FilterElement<TKey>, key: TUrlKey) { >(param: FilterElement<TKey>, key: TUrlKey) {
const { active, value } = param; const { active, value } = param;
@ -105,7 +105,7 @@ export function getSingleValueQueryParam<
export function getSingleEnumValueQueryParam< export function getSingleEnumValueQueryParam<
TKey extends string, TKey extends string,
TUrlKey extends string, TUrlKey extends string,
TEnum extends {} TEnum extends {},
>(param: FilterElementRegular<TKey>, key: TUrlKey, haystack: TEnum) { >(param: FilterElementRegular<TKey>, key: TUrlKey, haystack: TEnum) {
const { active, value } = param; const { active, value } = param;
@ -123,7 +123,7 @@ export function getSingleEnumValueQueryParam<
export function getMultipleEnumValueQueryParam< export function getMultipleEnumValueQueryParam<
TKey extends string, TKey extends string,
TUrlKey extends string, TUrlKey extends string,
TEnum extends {} TEnum extends {},
>(param: FilterElementRegular<TKey>, key: TUrlKey, haystack: TEnum) { >(param: FilterElementRegular<TKey>, key: TUrlKey, haystack: TEnum) {
const { active, value } = param; const { active, value } = param;
@ -140,7 +140,7 @@ export function getMultipleEnumValueQueryParam<
export function getMultipleValueQueryParam< export function getMultipleValueQueryParam<
TKey extends string, TKey extends string,
TUrlKey extends string TUrlKey extends string,
>(param: FilterElement<TKey>, key: TUrlKey) { >(param: FilterElement<TKey>, key: TUrlKey) {
const { active, value } = param; const { active, value } = param;
@ -157,7 +157,7 @@ export function getMultipleValueQueryParam<
export function getMinMaxQueryParam< export function getMinMaxQueryParam<
TKey extends string, TKey extends string,
TUrlKey extends string TUrlKey extends string,
>(param: FilterElement<TKey>, keyFrom: TUrlKey, keyTo: TUrlKey) { >(param: FilterElement<TKey>, keyFrom: TUrlKey, keyTo: TUrlKey) {
const { active, multiple, value } = param; const { active, multiple, value } = param;
@ -183,7 +183,7 @@ export function getMinMaxQueryParam<
export function getKeyValueQueryParam< export function getKeyValueQueryParam<
TKey extends string, TKey extends string,
TUrlKey extends string TUrlKey extends string,
>(param: FilterElementKeyValue<TKey>, key: TUrlKey) { >(param: FilterElementKeyValue<TKey>, key: TUrlKey) {
const { active, value } = param; const { active, value } = param;

View file

@ -14,7 +14,7 @@ type CreateFilterHandlers<TFilterKeys extends string> = [
function createFilterHandlers< function createFilterHandlers<
TFilterKeys extends string, TFilterKeys extends string,
TFilters extends {} TFilters extends {},
>(opts: { >(opts: {
getFilterQueryParam: GetFilterQueryParam<TFilterKeys, TFilters>; getFilterQueryParam: GetFilterQueryParam<TFilterKeys, TFilters>;
navigate: UseNavigatorResult; navigate: UseNavigatorResult;

View file

@ -56,7 +56,7 @@ export function mapNodeToChoice<T extends ExtendedNode>(
): Array<SingleAutocompleteChoiceType<string>>; ): Array<SingleAutocompleteChoiceType<string>>;
export function mapNodeToChoice< export function mapNodeToChoice<
T extends ExtendedNode | Node, T extends ExtendedNode | Node,
K extends ChoiceValue K extends ChoiceValue,
>(nodes: T[], getterFn: (node: T) => K): Array<SingleAutocompleteChoiceType<K>>; >(nodes: T[], getterFn: (node: T) => K): Array<SingleAutocompleteChoiceType<K>>;
export function mapNodeToChoice<T extends ExtendedNode>( export function mapNodeToChoice<T extends ExtendedNode>(

View file

@ -58,9 +58,8 @@ export function getMenuItemByValue<TMenuData = {}, TValue = string>(
value: TValue, value: TValue,
): IMenuItem<TMenuData, TValue> { ): IMenuItem<TMenuData, TValue> {
const flatMenu = toFlat(menu); const flatMenu = toFlat(menu);
const flatMenuItem: const flatMenuItem: IFlatMenuItem<TMenuData, TValue> | undefined =
| IFlatMenuItem<TMenuData, TValue> flatMenu.find(menuItem => menuItem.value === value);
| undefined = flatMenu.find(menuItem => menuItem.value === value);
if (flatMenuItem === undefined) { if (flatMenuItem === undefined) {
throw new Error(`Value ${value} does not exist in menu`); throw new Error(`Value ${value} does not exist in menu`);
@ -117,7 +116,8 @@ export function walkToRoot<TMenuData = {}, TValue = string>(
throw new Error(`Value ${value} does not exist in menu`); throw new Error(`Value ${value} does not exist in menu`);
} }
return (menuItem.parent === null return (
menuItem.parent === null
? [menuItem] ? [menuItem]
: [menuItem, ..._walkToRoot(flatMenu, menuItem.parent)] : [menuItem, ..._walkToRoot(flatMenu, menuItem.parent)]
).map(flatMenuItem => _fromFlat(flatMenu, flatMenuItem)); ).map(flatMenuItem => _fromFlat(flatMenu, flatMenuItem));

View file

@ -32,7 +32,7 @@ export function getArrowDirection(asc: boolean): TableCellHeaderArrowDirection {
// Extracts Sort object from the querystring // Extracts Sort object from the querystring
export function getSortParams< export function getSortParams<
TParams extends Sort<TFields>, TParams extends Sort<TFields>,
TFields extends string TFields extends string,
>(params: TParams): Sort<TFields> { >(params: TParams): Sort<TFields> {
return { return {
asc: params.asc, asc: params.asc,
@ -43,7 +43,7 @@ export function getSortParams<
// Appends Sort object to the querystring params // Appends Sort object to the querystring params
export function asSortParams< export function asSortParams<
TParams extends Record<any, string>, TParams extends Record<any, string>,
TFields extends Record<any, string> TFields extends Record<any, string>,
>( >(
params: TParams, params: TParams,
fields: TFields, fields: TFields,
@ -71,12 +71,12 @@ type GetSortQueryField<TUrlField extends string, TSortField extends string> = (
) => TSortField; ) => TSortField;
type GetSortQueryVariables< type GetSortQueryVariables<
TSortField extends string, TSortField extends string,
TParams extends Record<any, any> TParams extends Record<any, any>,
> = (params: TParams) => SortingInput<TSortField> | undefined; > = (params: TParams) => SortingInput<TSortField> | undefined;
export function createGetSortQueryVariables< export function createGetSortQueryVariables<
TUrlField extends string, TUrlField extends string,
TSortField extends string, TSortField extends string,
TParams extends Record<any, any> TParams extends Record<any, any>,
>( >(
getSortQueryField: GetSortQueryField<TUrlField, TSortField>, getSortQueryField: GetSortQueryField<TUrlField, TSortField>,
): GetSortQueryVariables<TSortField, TParams> { ): GetSortQueryVariables<TSortField, TParams> {

View file

@ -27,7 +27,8 @@ storiesOf("Warehouses / Create warehouse", module)
.add("form errors", () => ( .add("form errors", () => (
<WarehouseCreatePage <WarehouseCreatePage
{...props} {...props}
errors={([ errors={(
[
"name", "name",
"city", "city",
"cityArea", "cityArea",
@ -38,7 +39,8 @@ storiesOf("Warehouses / Create warehouse", module)
"postalCode", "postalCode",
"streetAddress1", "streetAddress1",
"streetAddress2", "streetAddress2",
] as Array<keyof WarehouseCreatePageFormData>).map(field => ({ ] as Array<keyof WarehouseCreatePageFormData>
).map(field => ({
__typename: "WarehouseError", __typename: "WarehouseError",
code: WarehouseErrorCode.INVALID, code: WarehouseErrorCode.INVALID,
field, field,

View file

@ -32,7 +32,8 @@ storiesOf("Warehouses / Warehouse details", module)
.add("form errors", () => ( .add("form errors", () => (
<WarehouseDetailsPage <WarehouseDetailsPage
{...props} {...props}
errors={([ errors={(
[
"name", "name",
"city", "city",
"cityArea", "cityArea",
@ -43,7 +44,8 @@ storiesOf("Warehouses / Warehouse details", module)
"postalCode", "postalCode",
"streetAddress1", "streetAddress1",
"streetAddress2", "streetAddress2",
] as Array<keyof WarehouseDetailsPageFormData>).map(field => ({ ] as Array<keyof WarehouseDetailsPageFormData>
).map(field => ({
__typename: "WarehouseError", __typename: "WarehouseError",
code: WarehouseErrorCode.INVALID, code: WarehouseErrorCode.INVALID,
field, field,

View file

@ -60,10 +60,8 @@ const WarehouseDetailsPage: React.FC<WarehouseDetailsPageProps> = ({
warehouse?.address?.country.country || "", warehouse?.address?.country.country || "",
); );
const { const { errors: validationErrors, submit: handleSubmit } =
errors: validationErrors, useAddressValidation(onSubmit);
submit: handleSubmit,
} = useAddressValidation(onSubmit);
const initialForm: WarehouseDetailsPageFormData = { const initialForm: WarehouseDetailsPageFormData = {
city: warehouse?.address.city ?? "", city: warehouse?.address.city ?? "",

View file

@ -13,6 +13,5 @@ export function getSortQueryField(
} }
} }
export const getSortQueryVariables = createGetSortQueryVariables( export const getSortQueryVariables =
getSortQueryField, createGetSortQueryVariables(getSortQueryField);
);

View file

@ -1,3 +1,3 @@
module.exports = async function() { module.exports = async function () {
process.env.TZ = "UTC"; process.env.TZ = "UTC";
}; };