ja_iy
ja_iy
TTCTheo's Typesafe Cult
Created by ja_iy on 6/21/2023 in #questions
How to implement different not-found pages for diffrent routes in next js app dir
ty will let you know if I find anything >_<, like you said currently just using a catchall page [...not-found]/page.tsx, but it's not optimal.
3 replies
TTCTheo's Typesafe Cult
Created by ja_iy on 5/23/2023 in #questions
Link won't navigate to app/not-found.tsx in app dir
Never mind seems to just be an issue with local development i tried deploying the same project on vercel and it works fine xd
5 replies
TTCTheo's Typesafe Cult
Created by SnehPr on 5/22/2023 in #questions
Can somebody help recommend how to use 'npx prisma db push'.
Hi what does the package.json currenlty look like
7 replies
TTCTheo's Typesafe Cult
Created by ja_iy on 5/23/2023 in #questions
Link won't navigate to app/not-found.tsx in app dir
Also it seems code sandbox sometimes does a full reload of the page when navigating so it might work sometimes, but it's not actually working, the result can be seen more clearly in local dev/build >_<
5 replies
TTCTheo's Typesafe Cult
Created by kinsyu on 5/12/2023 in #questions
Refresh a single React Server Componetns
Ah makes sense then only real advantage of api seems to be responsive to client state & less compute used on serv. Ye seems like would be cool to have selective component refreshes from the server. Np ty for info
12 replies
TTCTheo's Typesafe Cult
Created by kinsyu on 5/12/2023 in #questions
Refresh a single React Server Componetns
12 replies
TTCTheo's Typesafe Cult
Created by janusqa on 5/12/2023 in #questions
Is it possible to pass a zod schema as a prop?
np : D
8 replies
TTCTheo's Typesafe Cult
Created by janusqa on 5/12/2023 in #questions
Is it possible to pass a zod schema as a prop?
owo7 if you want to accept any zod schema then you could do something like
import type { ZodSchema } from "zod"

type ComponentProps<TSchema extends ZodSchema> = {
schema: TSchema,
children: React.ReactNode
}
function Component<TSchema extends ZodSchema>({schema, children}:ComponentProps<TSchema>){
return <>{children}</>
}
import type { ZodSchema } from "zod"

type ComponentProps<TSchema extends ZodSchema> = {
schema: TSchema,
children: React.ReactNode
}
function Component<TSchema extends ZodSchema>({schema, children}:ComponentProps<TSchema>){
return <>{children}</>
}
But if want to accept a specific schema
const schemaIn = z.object({
foo: z.literal('bar')
})

type ComponentProps = {
schema: typeof schemaIn,
children: React.ReactNode
}
function Component({schema, children}:ComponentProps){
return <>{children}</>
}
const schemaIn = z.object({
foo: z.literal('bar')
})

type ComponentProps = {
schema: typeof schemaIn,
children: React.ReactNode
}
function Component({schema, children}:ComponentProps){
return <>{children}</>
}
8 replies
TTCTheo's Typesafe Cult
Created by celeroncoder on 5/12/2023 in #questions
Can I use tRPC with Next.Js App Router
just add it to your root layout where appropriate
9 replies
TTCTheo's Typesafe Cult
Created by celeroncoder on 5/12/2023 in #questions
Can I use tRPC with Next.Js App Router
I'm trying using it using this approach https://github.com/trpc/next-13/blob/3992fb41ec4b1134d596d94007fdea51453445dd/client/trpcClient.tsx, seems to be working fine
9 replies
TTCTheo's Typesafe Cult
Created by kinsyu on 5/12/2023 in #questions
Refresh a single React Server Componetns
Also for this pattern it might be worth considering just fetching the data on the client via trpc/an api endpoint
12 replies
TTCTheo's Typesafe Cult
Created by ja_iy on 5/10/2023 in #questions
Next font sever/client mismatch in app dir
ty that's how I have it setup except for the className on the body, after switching it to the html the brief flash was even shorter : D was also reading this https://www.lydiahallie.io/blog/optimizing-webfonts-in-nextjs-13 and it seems that a brief flash is inevitable as long as the page loads before the font does, which is probably the case if I'm building and running locally, & reloading the page without the cache
8 replies
TTCTheo's Typesafe Cult
Created by ja_iy on 5/10/2023 in #questions
Next font sever/client mismatch in app dir
never mind <body className={${font_p.variable}}> is performing the same functionality I'm implementing by setting the css var it seems, but the flashing of the font still remains T~T
8 replies
TTCTheo's Typesafe Cult
Created by ja_iy on 5/10/2023 in #questions
Next font sever/client mismatch in app dir
ty the encoding was the issue : D I'm using tailwind & my tailwind config references the css var, so when the app loads it briefly flashes the font as the var is undefined, so have to set it in the html wrote this to fix the error
const filter_chars = (str:string) => str.replace(/['|,]/g, "");

export function RootCssVars({vars}:{vars:[name:string, value:string][]}) {

const var_style = vars
.map(([name, value]) => `--${name}: ${filter_chars(value)};`)
.join('\n')

return <style>{`
:root {
${var_style}
}
`}</style>
}
const filter_chars = (str:string) => str.replace(/['|,]/g, "");

export function RootCssVars({vars}:{vars:[name:string, value:string][]}) {

const var_style = vars
.map(([name, value]) => `--${name}: ${filter_chars(value)};`)
.join('\n')

return <style>{`
:root {
${var_style}
}
`}</style>
}
thanks again OwO
8 replies
TTCTheo's Typesafe Cult
Created by Biggie on 4/20/2023 in #questions
Good way to do many to many relationship Prisma
OwO7 from what i know there are 2 main ways to define many to many relations in prisma Implicit relation table (prisma will create the relation table for you)
model Subcategory {
id String @id @default(cuid())
name String
xyzs Xyz[] //@relation("CustomRelationTableName")
kvas Kva[]
}

model Xyz {
id String @id @default(cuid())
questionPrompt String @db.Text
subcategories Subcategory[] //@relation("CustomRelationTableName")
}

model Kva {
id String @id @default(cuid())
questionPrompt String @db.Text
subcategories Subcategory[]
}
model Subcategory {
id String @id @default(cuid())
name String
xyzs Xyz[] //@relation("CustomRelationTableName")
kvas Kva[]
}

model Xyz {
id String @id @default(cuid())
questionPrompt String @db.Text
subcategories Subcategory[] //@relation("CustomRelationTableName")
}

model Kva {
id String @id @default(cuid())
questionPrompt String @db.Text
subcategories Subcategory[]
}
Explicit relation table (you define the relation table, allows for custom fields on relation)
model Subcategory {
id String @id @default(cuid())
name String
xyzs Subcategory_Xyz_Rel[]
kvas Subcategory_Kva_Rel[]
}

model Xyz {
id String @id @default(cuid())
questionPrompt String @db.Text
subcategories Subcategory_Xyz_Rel[]
}

model Kva {
id String @id @default(cuid())
questionPrompt String @db.Text
subcategories Subcategory_Kva_Rel[]
}

model Subcategory_Xyz_Rel {
id String @id @default(cuid())
subcategoryId String
xyzId String
subcategory Subcategory @relation(fields: [subcategoryId], references: [id], onDelete: Cascade)
xyz Xyz @relation(fields: [xyzId], references: [id], onDelete: Cascade)
// add custom relation fields here
}

model Subcategory_Kva_Rel {
id String @id @default(cuid())
subcategoryId String
subcategory Subcategory @relation(fields: [subcategoryId], references: [id], onDelete: Cascade)
Kva Kva? @relation(fields: [kvaId], references: [id])
kvaId String?
// add custom relation fields here
}
model Subcategory {
id String @id @default(cuid())
name String
xyzs Subcategory_Xyz_Rel[]
kvas Subcategory_Kva_Rel[]
}

model Xyz {
id String @id @default(cuid())
questionPrompt String @db.Text
subcategories Subcategory_Xyz_Rel[]
}

model Kva {
id String @id @default(cuid())
questionPrompt String @db.Text
subcategories Subcategory_Kva_Rel[]
}

model Subcategory_Xyz_Rel {
id String @id @default(cuid())
subcategoryId String
xyzId String
subcategory Subcategory @relation(fields: [subcategoryId], references: [id], onDelete: Cascade)
xyz Xyz @relation(fields: [xyzId], references: [id], onDelete: Cascade)
// add custom relation fields here
}

model Subcategory_Kva_Rel {
id String @id @default(cuid())
subcategoryId String
subcategory Subcategory @relation(fields: [subcategoryId], references: [id], onDelete: Cascade)
Kva Kva? @relation(fields: [kvaId], references: [id])
kvaId String?
// add custom relation fields here
}
4 replies
TTCTheo's Typesafe Cult
Created by tilman0902 on 4/13/2023 in #questions
looking for a e2e typed CMS ideally with tRPC and directly integrated in Next.js
In my custom sol the admin frontend is built from scratch but it's pretty minimal. It gets auto generated from the cms schema we define but is also customizable. Can I dm further details because I don't want to crowd this thread incase people have more good recs OwO.
15 replies
TTCTheo's Typesafe Cult
Created by tilman0902 on 4/13/2023 in #questions
looking for a e2e typed CMS ideally with tRPC and directly integrated in Next.js
rip I wanted to try keystone after fin with current project O_O payload seems pretty cool, its mongo though T~T, but I guess its fine if we can have a separate sql db for app and mongo for cms.
15 replies
TTCTheo's Typesafe Cult
Created by tilman0902 on 4/13/2023 in #questions
looking for a e2e typed CMS ideally with tRPC and directly integrated in Next.js
owo7 from what I've seen keystone 6 might be what your looking for https://keystonejs.com/ some others to checkout are sanity and strapi, I'm currently building a minimal cms that integrates into t3 stack with prisma mostly for learning , if it turns out any good ill send a link if want >_<
15 replies
TTCTheo's Typesafe Cult
Created by Paweł on 4/3/2023 in #questions
Error of object possibly undefined
nevermind that shouldn't be the case because of the ? check srry
9 replies
TTCTheo's Typesafe Cult
Created by Paweł on 4/3/2023 in #questions
Error of object possibly undefined
Error might be arising from typescript not knowing if fieldErrors[item] exists hence possibly being undefined, thus fieldErrors[item][0] could possibly evaluate to undefined[0]
9 replies