Skip to content

Commit

Permalink
Small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
typeofweb committed Nov 11, 2023
1 parent 89aeaa8 commit e793100
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 24 deletions.
14 changes: 0 additions & 14 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,3 @@
body {
overflow-x: hidden;
}

@media (min-width: theme(screens.lg)) {
.checkout-bg {
background: linear-gradient(
90deg,
theme(colors.white) 0%,
theme(colors.white) 50%,
theme(colors.neutral.200) calc(50%),
theme(colors.neutral.200) calc(50% + 1px),
theme(colors.neutral.50) calc(50% + 1px),
theme(colors.neutral.50) 100%
);
}
}
2 changes: 1 addition & 1 deletion src/checkout/components/ErrorContentWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type Props = {
export const ErrorContentWrapper = ({ children }: Props) => {
return (
<div className="mx-auto flex max-w-screen-sm flex-col items-center gap-y-4 bg-neutral-50 px-8 py-16 text-center">
<>{children}</>
{children}
</div>
);
};
14 changes: 8 additions & 6 deletions src/checkout/hooks/useSubmit/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ export const extractMutationErrors = <
result: MutationData<TMutationFn>,
extractCustomErrors?: (result: MutationData<TMutationFn>) => MightNotExist<any[]>,
): ExtractedMutationErrors<TData, TErrorCodes> => {
const data = result?.data as
| null
| undefined
| Record<string, null | undefined | { errors: ApiErrors<TData, TErrorCodes> }>;

This comment has been minimized.

Copy link
@typeofweb

typeofweb Nov 11, 2023

Author Contributor

Fixed a bug where the value was sometimes null

const graphqlErrors = result?.error ? [result.error] : [];

const apiErrors = result?.data
? Object.values(result.data as Record<string, { errors: ApiErrors<TData, TErrorCodes> }>).reduce(
(result, { errors }) => [...result, ...errors],
[] as ApiErrors<TData, TErrorCodes>,
)
: [];
const apiErrors = Object.values(data ?? {}).reduce<ApiErrors<TData, TErrorCodes>>(
(result, value) => [...result, ...(value?.errors ?? [])],
[],
);

const customErrors = extractCustomErrors?.(result) || [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const PaymentProcessingScreen: React.FC<PaymentProcessingScreenProps> = (
</div>
</div>
)}
<>{children}</>
{children}
</Provider>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/checkout/sections/Summary/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const Summary: FC<SummaryProps> = ({
return (
<div
className={clsx(
"z-0 flex h-fit w-full flex-col overflow-hidden rounded lg:overflow-visible",
"before:bottom-0 before:left-auto before:right-0 before:top-0 before:z-[-1] before:w-1/2 before:border-l before:border-neutral-200 before:bg-neutral-50 before:content-[''] before:lg:fixed",
"z-0 flex h-fit w-full flex-col",
"before:fixed before:bottom-0 before:left-1/2 before:top-0 before:-z-10 before:w-1/2 before:border-l before:border-neutral-200 before:bg-neutral-50 before:content-none before:lg:content-['']",
)}
>
<details open className="group">
Expand Down

0 comments on commit e793100

Please sign in to comment.