|
|
@ -12,6 +12,7 @@ export const questionsQuestionCommentRouter = createProtectedRouter()
|
|
|
|
questionId: z.string(),
|
|
|
|
questionId: z.string(),
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
|
|
|
|
const { questionId } = input;
|
|
|
|
const questionCommentsData =
|
|
|
|
const questionCommentsData =
|
|
|
|
await ctx.prisma.questionsQuestionComment.findMany({
|
|
|
|
await ctx.prisma.questionsQuestionComment.findMany({
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
@ -27,7 +28,7 @@ export const questionsQuestionCommentRouter = createProtectedRouter()
|
|
|
|
createdAt: 'desc',
|
|
|
|
createdAt: 'desc',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
|
...input,
|
|
|
|
questionId,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return questionCommentsData.map((data) => {
|
|
|
|
return questionCommentsData.map((data) => {
|
|
|
@ -68,9 +69,12 @@ export const questionsQuestionCommentRouter = createProtectedRouter()
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
const userId = ctx.session?.user?.id;
|
|
|
|
const userId = ctx.session?.user?.id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { content, questionId } = input;
|
|
|
|
|
|
|
|
|
|
|
|
return await ctx.prisma.questionsQuestionComment.create({
|
|
|
|
return await ctx.prisma.questionsQuestionComment.create({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
...input,
|
|
|
|
content,
|
|
|
|
|
|
|
|
questionId,
|
|
|
|
userId,
|
|
|
|
userId,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -84,6 +88,8 @@ export const questionsQuestionCommentRouter = createProtectedRouter()
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
const userId = ctx.session?.user?.id;
|
|
|
|
const userId = ctx.session?.user?.id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { content } = input;
|
|
|
|
|
|
|
|
|
|
|
|
const questionCommentToUpdate =
|
|
|
|
const questionCommentToUpdate =
|
|
|
|
await ctx.prisma.questionsQuestionComment.findUnique({
|
|
|
|
await ctx.prisma.questionsQuestionComment.findUnique({
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
@ -100,7 +106,7 @@ export const questionsQuestionCommentRouter = createProtectedRouter()
|
|
|
|
|
|
|
|
|
|
|
|
return await ctx.prisma.questionsQuestionComment.update({
|
|
|
|
return await ctx.prisma.questionsQuestionComment.update({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
...input,
|
|
|
|
content,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
|
id: input.id,
|
|
|
|
id: input.id,
|
|
|
@ -158,11 +164,13 @@ export const questionsQuestionCommentRouter = createProtectedRouter()
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
const userId = ctx.session?.user?.id;
|
|
|
|
const userId = ctx.session?.user?.id;
|
|
|
|
|
|
|
|
const { questionCommentId, vote } = input;
|
|
|
|
|
|
|
|
|
|
|
|
return await ctx.prisma.questionsQuestionCommentVote.create({
|
|
|
|
return await ctx.prisma.questionsQuestionCommentVote.create({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
...input,
|
|
|
|
questionCommentId,
|
|
|
|
userId,
|
|
|
|
userId,
|
|
|
|
|
|
|
|
vote,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|