Skip to content

Commit

Permalink
fix: delete post usage
Browse files Browse the repository at this point in the history
  • Loading branch information
JowiAoun committed Aug 10, 2024
1 parent 583163f commit 6449827
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 70 deletions.
55 changes: 0 additions & 55 deletions src/app/_components/post.tsx

This file was deleted.

4 changes: 1 addition & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import Link from 'next/link'

import { UserProfile } from '~/app/_components/userProfile/UserProfile'
import { getServerAuthSession } from '~/server/auth'
import { HydrateClient, api } from '~/trpc/server'
import { HydrateClient } from '~/trpc/server'

export default async function Home() {
const session = await getServerAuthSession()

void api.post.getLatest.prefetch()

if (!session) {
return (
<div>
Expand Down
30 changes: 18 additions & 12 deletions src/server/api/routers/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,29 @@ export const postRouter = createTRPCRouter({

create: protectedProcedure
.input(z.object({ name: z.string().min(1) }))
.mutation(async ({ ctx, input }) => {
.mutation(async (
// { ctx, input },
) => {
// simulate a slow db call
await new Promise(resolve => setTimeout(resolve, 1000))

return ctx.db.post.create({
data: {
name: input.name,
createdBy: { connect: { id: ctx.session.user.id } },
},
})
// return ctx.db.post.create({
// data: {
// name: input.name,
// createdBy: { connect: { id: ctx.session.user.id } },
// },
// })
}),

getLatest: protectedProcedure.query(({ ctx }) => {
return ctx.db.post.findFirst({
orderBy: { createdAt: 'desc' },
where: { createdBy: { id: ctx.session.user.id } },
})
getLatest: protectedProcedure.query((
// { ctx },
) => {
// return ctx.db.post.findFirst({
// orderBy: { createdAt: 'desc' },
// where: { createdBy: { id: ctx.session.user.id } },
// })

return -1
}),

getSecretMessage: protectedProcedure.query(() => {
Expand Down

0 comments on commit 6449827

Please sign in to comment.