-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
92 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
type NonFalsy<T> = T extends false | 0 | "" | null | undefined | 0n ? never : T; | ||
|
||
interface Array<T> { | ||
includes(searchElement: unknown, fromIndex?: number): searchElement is T; | ||
} | ||
|
||
interface ReadonlyArray<T> { | ||
includes(searchElement: unknown, fromIndex?: number): searchElement is T; | ||
} | ||
|
||
interface Body { | ||
json(): Promise<unknown>; | ||
} | ||
|
||
interface Array<T> { | ||
filter(predicate: BooleanConstructor, thisArg?: unknown): NonFalsy<T>[]; | ||
} | ||
|
||
interface ReadonlyArray<T> { | ||
filter(predicate: BooleanConstructor, thisArg?: unknown): NonFalsy<T>[]; | ||
} | ||
|
||
interface ArrayConstructor { | ||
isArray(arg: unknown): arg is unknown[]; | ||
} | ||
|
||
interface JSON { | ||
/** | ||
* Converts a JavaScript Object Notation (JSON) string into an object. | ||
* @param text A valid JSON string. | ||
* @param reviver A function that transforms the results. This function is called for each member of the object. | ||
* If a member contains nested objects, the nested objects are transformed before the parent object is. | ||
*/ | ||
parse(text: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): unknown; | ||
} | ||
|
||
interface Set<T> { | ||
has(value: unknown): value is T; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
query MenuGetBySlug($slug: String!) { | ||
menu(slug: $slug) { | ||
items { | ||
id | ||
category { | ||
id | ||
slug | ||
name | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { cookies } from "next/headers"; | ||
import { ShoppingBagIcon } from "lucide-react"; | ||
import Link from "next/link"; | ||
import * as Checkout from "@/lib/checkout"; | ||
|
||
export const CartNavItem = async () => { | ||
const checkoutId = cookies().get("checkoutId")?.value || ""; | ||
const checkout = await Checkout.find(checkoutId); | ||
|
||
const lineCount = checkout ? checkout.lines.reduce((result, line) => result + line.quantity, 0) : 0; | ||
|
||
return ( | ||
<Link href="/cart" className="flex w-12 items-center"> | ||
<ShoppingBagIcon className="h-6 w-6 flex-shrink-0 " aria-hidden="true" /> | ||
<span className="ml-2 min-w-[2ch] text-sm font-medium">{lineCount > 0 && lineCount}</span> | ||
<span className="sr-only">items in cart, view bag</span> | ||
</Link> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters