Skip to content

Commit 879be04

Browse files
authored
#635 Fix two minor bugs (saleor#639)
- [x] (intermediate value)(intermediate value)(intermediate value) is not iterable - [x] Cannot destructure property 'errors' of 's' as it is null. Fixes #635
1 parent ebec4be commit 879be04

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/checkout-storefront/src/lib/utils/url.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ export const getRawQueryParams = () =>
4343
export const getQueryParams = (): QueryParams => {
4444
const params = getRawQueryParams();
4545

46-
if (typeof params.locale !== "string") {
46+
const locale = params.locale || defaultParams.locale;
47+
48+
if (locale !== params.locale) {
4749
replaceUrl({ query: { locale: DEFAULT_LOCALE } });
4850
}
4951

50-
return Object.entries(params).reduce((result, entry) => {
52+
return Object.entries({ ...params, locale }).reduce((result, entry) => {
5153
const [paramName, paramValue] = entry as [UnmappedQueryParam, ParamBasicValue];
5254
const mappedParamName = queryParamsMap[paramName];
5355
const mappedParamValue = paramValue || defaultParams[paramName];

packages/checkout-storefront/src/lib/utils/utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export const extractMutationErrors = <TData extends FormDataBase, TVars extends
3333
result: OperationResult<TData, TVars> | any // any to cover apollo client
3434
// mutations, to be removed once we remove apollo client from sdk
3535
): [boolean, ApiErrors<TData>] => {
36-
const urqlErrors = result.error ? [result.error] : [];
36+
const urqlErrors = result?.error ? [result.error] : [];
3737

3838
const graphqlErrors = reduce(
39-
result.data as object,
40-
(result, { errors }) => {
39+
(result?.data || {}) as object,
40+
(result, { errors = [] }) => {
4141
return [...result, ...errors];
4242
},
4343
[]

0 commit comments

Comments
 (0)