Skip to content

Commit

Permalink
Added Public Route to display approved reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
piyushgarg-dev committed Oct 29, 2023
1 parent 7cbdf65 commit f3f0f30
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
3 changes: 1 addition & 2 deletions functions/graphql/form/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ const queries = {
{ input }: { input: GetFormResponsesByFormIdInput },
ctx: ServerContext
) => {
ensureAuthenticated(ctx)
return FormService.getFormResponsesByFormId(input.formId, ctx)
return FormService.getFormResponsesByFormId(input.formId)
},
getFormResponsesByProjectId: async (
_: any,
Expand Down
32 changes: 19 additions & 13 deletions services/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,27 @@ class FormService {
})
}

public static getFormResponsesByFormId(formId: string, ctx: ServerContext) {
if (!ctx.user?.id) throw new AccessDeniedError()

public static getFormResponsesByFormId(formId: string) {
return prismaClient.formResponse.findMany({
where: {
AND: [
{
form: {
id: formId,
project: {
ProjectAccessMapping: { every: { user: { id: ctx.user.id } } }, // TODO: Need to test more deeply
},
},
},
],
formId,
},
orderBy: {
updatedAt: 'desc',
},
select: {
approved: true,
company: true,
createdAt: true,
email: true,
imageURL: true,
id: true,
jobTitle: true,
rating: true,
testimonial: true,
name: true,
websiteUrl: true,
formId: true,
},
})
}
Expand Down

0 comments on commit f3f0f30

Please sign in to comment.