feat: add form for submitting testimonials #3

Merged
naomi merged 3 commits from feat/testimonials into main 2025-02-20 16:07:40 -08:00
4 changed files with 38 additions and 8 deletions
Showing only changes of commit 5ea66c56a0 - Show all commits

View File

@ -165,7 +165,8 @@ export class ApiService {
| "events"
| "meetings"
| "mentorships"
| "staff",
| "staff"
| "testimonials",
token: string,
): Promise<DataResponse | ErrorResponse> {
const request = await fetch(`${this.url}/list/${type}`, {
@ -187,7 +188,8 @@ export class ApiService {
| "events"
| "meetings"
| "mentorships"
| "staff",
| "staff"
| "testimonials",
id: string,
token: string,
): Promise<SuccessResponse | ErrorResponse> {

View File

@ -58,11 +58,21 @@
>
Staff Applications
</button>
<button
[disabled]="view === 'testimonials'"
type="button"
(click)="setView('testimonials')"
>
Testimonials
</button>
<h2>{{ view }}</h2>
<div *ngFor="let datum of data">
<h3>{{ datum.email }}</h3>
<div *ngFor="let obj of datum.info">
<p><strong>{{ obj.key }}</strong>: {{ obj.value }}</p>
<p>
<strong>{{ obj.key }}</strong
>: {{ obj.value }}
</p>
</div>
<button type="button" (click)="markReviewed(datum.id)">
Mark as Reviewed

View File

@ -41,7 +41,8 @@ export class ReviewComponent {
| "events"
| "meetings"
| "mentorships"
| "staff" = "";
| "staff"
| "testimonials" = "";
public constructor(private readonly apiService: ApiService) {
const storedToken = localStorage.getItem("token");
@ -98,7 +99,8 @@ export class ReviewComponent {
| "events"
| "meetings"
| "mentorships"
| "staff";
| "staff"
| "testimonials";
void this.apiService.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- We know token is not null
markReviewed(view, id, this.token.value!).then((data) => {
@ -120,7 +122,8 @@ export class ReviewComponent {
| "events"
| "meetings"
| "mentorships"
| "staff",
| "staff"
| "testimonials",
): void {
this.view = view;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- We know token is not null

View File

@ -14,6 +14,7 @@ import type {
Mentorships,
PrismaClient,
Staff,
Testimonials,
} from "@prisma/client";
/**
@ -27,10 +28,17 @@ const listUnreviewedSubmissions = async(
route: DatabasePath,
): Promise<
Array<
Appeals | Commissions | Contacts | Events | Meetings | Mentorships | Staff
| Appeals
| Commissions
| Contacts
| Events
| Meetings
| Mentorships
| Staff
| Testimonials
>
> => {
const query = { };
const query = {};
switch (route) {
case "appeals":
return await database.appeals.findMany(query);
@ -46,6 +54,8 @@ const listUnreviewedSubmissions = async(
return await database.mentorships.findMany(query);
case "staff":
return await database.staff.findMany(query);
case "testimonials":
return await database.testimonials.findMany(query);
default:
return [];
}
@ -79,6 +89,8 @@ const checkSubmissionExists = async(
return Boolean(await database.mentorships.findUnique(query));
case "staff":
return Boolean(await database.staff.findUnique(query));
case "testimonials":
return Boolean(await database.testimonials.findUnique(query));
default:
return false;
}
@ -122,6 +134,9 @@ const markSubmissionReviewed = async(
case "staff":
await database.staff.delete(update);
break;
case "testimonials":
await database.testimonials.delete(update);
break;
default:
break;
}