Skip to content

Commit f3f0f30

Browse files
Added Public Route to display approved reviews
1 parent 7cbdf65 commit f3f0f30

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

functions/graphql/form/resolver.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ const queries = {
3232
{ input }: { input: GetFormResponsesByFormIdInput },
3333
ctx: ServerContext
3434
) => {
35-
ensureAuthenticated(ctx)
36-
return FormService.getFormResponsesByFormId(input.formId, ctx)
35+
return FormService.getFormResponsesByFormId(input.formId)
3736
},
3837
getFormResponsesByProjectId: async (
3938
_: any,

services/form.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,27 @@ class FormService {
107107
})
108108
}
109109

110-
public static getFormResponsesByFormId(formId: string, ctx: ServerContext) {
111-
if (!ctx.user?.id) throw new AccessDeniedError()
112-
110+
public static getFormResponsesByFormId(formId: string) {
113111
return prismaClient.formResponse.findMany({
114112
where: {
115-
AND: [
116-
{
117-
form: {
118-
id: formId,
119-
project: {
120-
ProjectAccessMapping: { every: { user: { id: ctx.user.id } } }, // TODO: Need to test more deeply
121-
},
122-
},
123-
},
124-
],
113+
formId,
114+
},
115+
orderBy: {
116+
updatedAt: 'desc',
117+
},
118+
select: {
119+
approved: true,
120+
company: true,
121+
createdAt: true,
122+
email: true,
123+
imageURL: true,
124+
id: true,
125+
jobTitle: true,
126+
rating: true,
127+
testimonial: true,
128+
name: true,
129+
websiteUrl: true,
130+
formId: true,
125131
},
126132
})
127133
}

0 commit comments

Comments
 (0)