mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
handling bigint errors
This commit is contained in:
parent
abad7ad893
commit
e0161d1b5f
8 changed files with 14 additions and 12 deletions
|
|
@ -10,7 +10,7 @@ import { db } from "@/app/db/db";
|
|||
import { z } from "zod";
|
||||
|
||||
const createPortfolioSchema = z.object({
|
||||
userId: z.number(),
|
||||
userId: z.bigint(),
|
||||
portfolioName: z.string(),
|
||||
budget: z.number().optional(),
|
||||
goal: z.enum(PortfolioGoal),
|
||||
|
|
@ -52,7 +52,11 @@ export async function POST(request: NextRequest) {
|
|||
|
||||
const response = await db
|
||||
.insert(portfolioUsers)
|
||||
.values({ userId: userId, portfolioId: newPortfolioId, role: role })
|
||||
.values({
|
||||
userId: userId,
|
||||
portfolioId: newPortfolioId,
|
||||
role: role,
|
||||
})
|
||||
.returning();
|
||||
|
||||
if (response.length !== 1) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const styles = {
|
|||
};
|
||||
|
||||
interface CardProps {
|
||||
id: number;
|
||||
id: bigint;
|
||||
title: string;
|
||||
image: string;
|
||||
budget: number | null;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export default function CardTiles({
|
|||
const image_idx = index % 5;
|
||||
return (
|
||||
<Card
|
||||
key={portfolio.id}
|
||||
key={portfolio.id.toString()}
|
||||
id={portfolio.id}
|
||||
title={portfolio.name}
|
||||
image={`house-icon-${image_idx}.svg`}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
import { useSession } from "next-auth/react";
|
||||
|
||||
type CreatePortfolioArgs = {
|
||||
userId: number;
|
||||
userId: bigint;
|
||||
portfolioName: string;
|
||||
budget: number | undefined;
|
||||
goal: (typeof PortfolioGoal)[number];
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ export type Property = InferModel<typeof property, "select">;
|
|||
// This type is used for the getProperties function in src/app/portfolio/[slug]/utils.ts
|
||||
export interface PropertyWithTarget {
|
||||
status: string | null;
|
||||
id: number;
|
||||
id: bigint;
|
||||
portfolioId: number;
|
||||
creationStatus: string;
|
||||
address: string | null;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
import { portfolioUsers, PortfolioUsers } from "./../db/schema/portfolio";
|
||||
import { portfolioUsers } from "./../db/schema/portfolio";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { user } from "@/app/db/schema/users";
|
||||
import { db } from "@/app/db/db";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { portfolio } from "@/app/db/schema/portfolio";
|
||||
import type { Portfolio } from "@/app/db/schema/portfolio";
|
||||
|
||||
export async function getPortfolios(userId: number): Promise<Portfolio[]> {
|
||||
export async function getPortfolios(userId: bigint): Promise<Portfolio[]> {
|
||||
const userPortfolios = await db
|
||||
.select()
|
||||
.from(portfolio)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export async function getPortfolio(portfolioId: number): Promise<Portfolio> {
|
|||
const data = await db
|
||||
.select()
|
||||
.from(portfolio)
|
||||
.where(eq(portfolio.id, portfolioId));
|
||||
.where(eq(portfolio.id, BigInt(portfolioId)));
|
||||
|
||||
if (data.length === 0) {
|
||||
throw new Error("Portfolio not found");
|
||||
|
|
|
|||
2
src/types/next-auth.d.ts
vendored
2
src/types/next-auth.d.ts
vendored
|
|
@ -9,6 +9,6 @@ declare module "next-auth" {
|
|||
} & DefaultSession["user"];
|
||||
}
|
||||
interface User {
|
||||
dbId: number;
|
||||
dbId: bigint;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue