Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
Update paths helper lib
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofwolski committed Apr 4, 2022
1 parent 79f64aa commit 1fe56da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"plugin:@typescript-eslint/recommended",
"prettier" // prettier *has* to be the last one, to avoid conflicting rules
],
"ignorePatterns": ["saleor/api.tsx", "pnpm-lock.yaml", "graphql.schema.json"],
"ignorePatterns": ["saleor/api.tsx", "pnpm-lock.yaml", "graphql.schema.json", "lib/$path.ts"],
"plugins": ["simple-import-sort", "formatjs", "@typescript-eslint"],
"rules": {
"quotes": ["error", "double"],
Expand All @@ -31,7 +31,6 @@
"no-console": ["error", { "allow": ["warn", "error"] }],
"operator-linebreak": "off",
"max-len": "off",
// To be discussed
"array-callback-return": "off",
"implicit-arrow-linebreak": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
saleor/api.tsx
pnpm-lock.yaml
graphql.schema.json
lib/$path.ts
39 changes: 17 additions & 22 deletions lib/$path.ts
Original file line number Diff line number Diff line change
@@ -1,69 +1,65 @@
/* eslint-disable */
// prettier-ignore
import { OptionalQuery as OptionalQuery0 } from '../pages/[channel]/[locale]/account/login'
// prettier-ignore
import { OptionalQuery as OptionalQuery1 } from '../pages/[channel]/[locale]/products/[slug]'
import type { OptionalQuery as OptionalQuery0 } from '../pages/[channel]/[locale]/account/login'
import type { OptionalQuery as OptionalQuery1 } from '../pages/[channel]/[locale]/products/[slug]'

// prettier-ignore
export const pagesPath = {
$404: {
"$404": {
$url: (url?: { hash?: string }) => ({ pathname: '/404' as const, hash: url?.hash })
},
_channel: (channel: string | number) => ({
_locale: (locale: string | number) => ({
_sitemap: (sitemap: string | number) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/[sitemap]' as const, query: { channel, locale, sitemap }, hash: url?.hash })
}),
account: {
addressBook: {
"account": {
"addressBook": {
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/account/addressBook' as const, query: { channel, locale }, hash: url?.hash })
},
login: {
"login": {
$url: (url?: { query?: OptionalQuery0, hash?: string }) => ({ pathname: '/[channel]/[locale]/account/login' as const, query: { channel, locale, ...url?.query }, hash: url?.hash })
},
orders: {
"orders": {
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/account/orders' as const, query: { channel, locale }, hash: url?.hash }),
_token: (token: string | number) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/account/orders/[token]' as const, query: { channel, locale, token }, hash: url?.hash })
})
},
preferences: {
"preferences": {
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/account/preferences' as const, query: { channel, locale }, hash: url?.hash })
},
register: {
"register": {
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/account/register' as const, query: { channel, locale }, hash: url?.hash })
}
},
cart: {
"cart": {
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/cart' as const, query: { channel, locale }, hash: url?.hash })
},
category: {
"category": {
_slug: (slug: string | number) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/category/[slug]' as const, query: { channel, locale, slug }, hash: url?.hash })
})
},
checkout: {
"checkout": {
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/checkout' as const, query: { channel, locale }, hash: url?.hash })
},
collection: {
"collection": {
_slug: (slug: string | number) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/collection/[slug]' as const, query: { channel, locale, slug }, hash: url?.hash })
})
},
order: {
"order": {
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/order' as const, query: { channel, locale }, hash: url?.hash })
},
page: {
"page": {
_slug: (slug: string | number) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/page/[slug]' as const, query: { channel, locale, slug }, hash: url?.hash })
})
},
products: {
"products": {
_slug: (slug: string | number) => ({
$url: (url?: { query?: OptionalQuery1, hash?: string }) => ({ pathname: '/[channel]/[locale]/products/[slug]' as const, query: { channel, locale, slug, ...url?.query }, hash: url?.hash })
})
},
search: {
"search": {
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/search' as const, query: { channel, locale }, hash: url?.hash })
},
$url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]' as const, query: { channel, locale }, hash: url?.hash })
Expand All @@ -72,5 +68,4 @@ export const pagesPath = {
$url: (url?: { hash?: string }) => ({ pathname: '/' as const, hash: url?.hash })
}

// prettier-ignore
export type PagesPath = typeof pagesPath

0 comments on commit 1fe56da

Please sign in to comment.