diff --git a/bun.lockb b/bun.lockb index f577256..2574444 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 64c7379..ec66efd 100644 --- a/package.json +++ b/package.json @@ -16,14 +16,20 @@ "dependencies": { "@heroicons/react": "^2.1.5", "@hookform/resolvers": "^3.9.0", + "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-icons": "^1.3.0", + "@radix-ui/react-popover": "^1.1.1", "@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-slot": "^1.1.0", + "@radix-ui/react-tooltip": "^1.1.2", + "@tabler/icons-react": "^3.17.0", "@types/canvas-confetti": "^1.6.4", "canvas-confetti": "^1.9.3", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", + "cmdk": "1.0.0", "framer-motion": "^11.5.4", + "lossless-json": "^4.0.2", "lucide-react": "^0.441.0", "next": "14.2.8", "next-client-cookies": "^1.1.1", diff --git a/src/lib/api.ts b/src/lib/api.ts index ba81ddf..0102bf2 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -1,5 +1,6 @@ import { Session } from "@/app/types/user/session"; import { ApiError } from "@/app/types/api-error"; +import { parseJson } from "@/lib/json"; type ApiRequestProps = { /** @@ -59,9 +60,9 @@ export const apiRequest = async ({ }, } ); - const data: T = await response.json(); + const json: any = parseJson(await response.text()); // Parse the Json response from the API if (response.status !== 200) { - return { data: undefined, error: data as ApiError }; + return { data: undefined, error: json as ApiError }; } - return { data: data as T, error: undefined }; + return { data: json as T, error: undefined }; }; diff --git a/src/lib/json.ts b/src/lib/json.ts new file mode 100644 index 0000000..00d91d5 --- /dev/null +++ b/src/lib/json.ts @@ -0,0 +1,11 @@ +import { isInteger, parse } from "lossless-json"; + +/** + * Parse the given input as JSON. + * + * @param input the input to parse + */ +export const parseJson = (input: string): any => + parse(input, null, (value: string): string | number => + isInteger(value) ? String(value) : parseInt(value) + );