Skip to content

Commit bc875c7

Browse files
code refactor
1 parent 510b1ce commit bc875c7

File tree

9 files changed

+23
-30
lines changed

9 files changed

+23
-30
lines changed

src/app/[locale]/[channel]/(auth)/_actions/sign-in.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import {
1111
setRefreshTokenCookie,
1212
} from "@/modules/account/utils/cookies";
1313
import {toValidationErrors} from "@/modules/account/utils/validation-errors";
14-
import {BasePathnameSchema} from "@/utils/base-pathname";
1514
import {isDefined} from "@/utils/is-defined";
16-
import {joinPathSegments} from "@/utils/pathname";
15+
import {BasePathnameSchema, joinPathSegments} from "@/utils/pathname";
1716

1817
const SigninMutation = graphql(`
1918
mutation Signin($email: String!, $password: String!) {

src/app/[locale]/[channel]/(auth)/_actions/sign-up.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import {getClient} from "@/graphql/apollo-client";
88
import {graphql} from "@/graphql/codegen";
99
import {localeToLanguageCode} from "@/i18n/utils/locale-to-language-code";
1010
import {toValidationErrors} from "@/modules/account/utils/validation-errors";
11-
import {BasePathnameSchema} from "@/utils/base-pathname";
12-
import {joinPathSegments} from "@/utils/pathname";
11+
import {BasePathnameSchema, joinPathSegments} from "@/utils/pathname";
1312

1413
import {signIn} from "./sign-in";
1514

src/app/[locale]/[channel]/(auth)/confirm-account/route.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import {Routes} from "@/consts/routes";
44
import {getClient} from "@/graphql/apollo-client";
55
import {graphql} from "@/graphql/codegen";
66
import type {ConfirmAccountMutationVariables} from "@/graphql/codegen/graphql";
7-
import {getBasePathname} from "@/utils/base-pathname";
87
import {isDefined} from "@/utils/is-defined";
9-
import {joinPathSegments} from "@/utils/pathname";
8+
import {getBasePathname, joinPathSegments} from "@/utils/pathname";
109

1110
const ConfirmAccountMutation = graphql(`
1211
mutation ConfirmAccount($email: String!, $token: String!) {

src/app/[locale]/[channel]/checkout/(steps)/_actions/update-billing.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import {graphql} from "@/graphql/codegen";
99
import {getCheckoutId} from "@/modules/checkout/utils/cookies";
1010
import {toValidationErrors} from "@/modules/checkout/utils/validation-errors";
1111
import {AddressSchema} from "@/utils/address";
12-
import {BasePathnameSchema} from "@/utils/base-pathname";
1312
import {isDefined} from "@/utils/is-defined";
14-
import {joinPathSegments} from "@/utils/pathname";
13+
import {BasePathnameSchema, joinPathSegments} from "@/utils/pathname";
1514

1615
const BillingAddressUpdateMutation = graphql(`
1716
mutation BillingAddressUpdate($id: ID!, $billingAddress: AddressInput!) {

src/app/[locale]/[channel]/checkout/(steps)/_actions/update-delivery.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import {getClient} from "@/graphql/apollo-client";
88
import {graphql} from "@/graphql/codegen";
99
import {getCheckoutId} from "@/modules/checkout/utils/cookies";
1010
import {toValidationErrors} from "@/modules/checkout/utils/validation-errors";
11-
import {BasePathnameSchema} from "@/utils/base-pathname";
1211
import {isDefined} from "@/utils/is-defined";
13-
import {joinPathSegments} from "@/utils/pathname";
12+
import {BasePathnameSchema, joinPathSegments} from "@/utils/pathname";
1413

1514
const DeliveryMethodUpdateMutation = graphql(`
1615
mutation DeliveryMethodUpdate($id: ID!, $deliveryMethodId: ID!) {

src/app/[locale]/[channel]/checkout/(steps)/_actions/update-information.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import type {
1414
import {getCheckoutId} from "@/modules/checkout/utils/cookies";
1515
import {toValidationErrors} from "@/modules/checkout/utils/validation-errors";
1616
import {AddressSchema} from "@/utils/address";
17-
import {BasePathnameSchema} from "@/utils/base-pathname";
1817
import {isDefined} from "@/utils/is-defined";
19-
import {joinPathSegments} from "@/utils/pathname";
18+
import {BasePathnameSchema, joinPathSegments} from "@/utils/pathname";
2019

2120
const EmailUpdateMutation = graphql(`
2221
mutation EmailUpdate($id: ID!, $email: String!) {

src/components/Heading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function SkeletonHeading(props: Pick<HeadingProps, "level">) {
5555
<div
5656
aria-hidden
5757
className={cn(
58-
"flex h-[1lh] w-full max-w-40 items-center",
58+
"flex h-[1lh] w-full max-w-38 items-center",
5959
heading(level === 1 || level === 2 ? {level} : {}),
6060
)}>
6161
<Skeleton className={cn("h-[1em] w-full")} />

src/utils/base-pathname.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/utils/pathname.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
import * as z from "zod";
2+
3+
import {DefaultLocale, Locales} from "@/i18n/consts";
4+
import {DefaultChannel} from "@/modules/channel/consts";
5+
6+
export const BasePathnameSchema = z.object({
7+
locale: z.enum(Locales),
8+
channel: z.string(),
9+
});
10+
11+
export function getBasePathname(pathname: string) {
12+
const [locale = DefaultLocale, channel = DefaultChannel] =
13+
splitPathSegments(pathname);
14+
return [locale, channel] as const;
15+
}
16+
117
export function joinPathSegments(...segments: string[]) {
218
function trimLeadingSlash(s: string) {
319
return s.startsWith("/") ? s.slice(1) : s;

0 commit comments

Comments
 (0)