Viszy A
Viszy A
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Viszy A on 1/1/2024 in #questions
Nested query fails because query by id is different between nested relations
This is the schema for those 3 models
2 replies
TTCTheo's Typesafe Cult
Created by Viszy A on 12/30/2023 in #questions
Need help with creating a mutation that involves relations
yeah i solved it thanks
4 replies
TTCTheo's Typesafe Cult
Created by Viszy A on 12/30/2023 in #questions
Need help with creating a mutation that involves relations
the image is a similar attempt but still am running into errors
4 replies
TTCTheo's Typesafe Cult
Created by Viszy A on 11/15/2023 in #questions
How do I actually use tRPC without using a server component
I deleted some pieces of the code in form.tsx but that file runs fine its just I don't know how to use the api to mutate data without using a server component
4 replies
TTCTheo's Typesafe Cult
Created by Viszy A on 11/5/2023 in #questions
How do I fix this query, I was following a tutorial that doesn't use the t3 stack
And this is the procedure from which I am calling from:
export const authRouter = createTRPCRouter({
authCallback: publicProcedure.query(async () => {
const { getUser } = getKindeServerSession()
const user = await getUser()

if (!user.id || !user.email)
throw new TRPCError({ code: 'UNAUTHORIZED' })

// check if the user is in the database
const dbUser = await db.user.findFirst({
where: {
id: user.id,
},
})

if (!dbUser) {
// create user in db
await db.user.create({
data: {
id: user.id,
email: user.email,
},
})
}

return { success: true }
}),
})
export const authRouter = createTRPCRouter({
authCallback: publicProcedure.query(async () => {
const { getUser } = getKindeServerSession()
const user = await getUser()

if (!user.id || !user.email)
throw new TRPCError({ code: 'UNAUTHORIZED' })

// check if the user is in the database
const dbUser = await db.user.findFirst({
where: {
id: user.id,
},
})

if (!dbUser) {
// create user in db
await db.user.create({
data: {
id: user.id,
email: user.email,
},
})
}

return { success: true }
}),
})
5 replies
TTCTheo's Typesafe Cult
Created by Viszy A on 11/5/2023 in #questions
How do I fix this query, I was following a tutorial that doesn't use the t3 stack
I tried to replicate it into this query, but then nextjs gives me an error because i use "use client" in the
src/app/auth-callback/page.tsx
src/app/auth-callback/page.tsx
same place where I put the query in, and apparently nextjs does allow use Client in a parent function of a server component which is
server.ts
server.ts
and I don't know how to fix this either.
const router = useRouter()

const searchParams = useSearchParams()
const origin = searchParams.get('origin')

api.auth.authCallback.query().then(({ success }) => {
if (success) {
// user is synced to db
router.push(origin ? `/${origin}` : '/dashboard')
}
}).catch((error) => {
if (error.data?.code === 'UNAUTHORIZED') {
router.push('/sign-in')
}
})
const router = useRouter()

const searchParams = useSearchParams()
const origin = searchParams.get('origin')

api.auth.authCallback.query().then(({ success }) => {
if (success) {
// user is synced to db
router.push(origin ? `/${origin}` : '/dashboard')
}
}).catch((error) => {
if (error.data?.code === 'UNAUTHORIZED') {
router.push('/sign-in')
}
})
5 replies
TTCTheo's Typesafe Cult
Created by Viszy A on 2/13/2023 in #questions
Next Auth Google not working ('client_id is required')
I meant GOOGLE_CLIENT_SECRET btw
3 replies