generated from nhcarrigan/template
feat: add form for submitting testimonials #3
@ -165,7 +165,8 @@ export class ApiService {
|
|||||||
| "events"
|
| "events"
|
||||||
| "meetings"
|
| "meetings"
|
||||||
| "mentorships"
|
| "mentorships"
|
||||||
| "staff",
|
| "staff"
|
||||||
|
| "testimonials",
|
||||||
token: string,
|
token: string,
|
||||||
): Promise<DataResponse | ErrorResponse> {
|
): Promise<DataResponse | ErrorResponse> {
|
||||||
const request = await fetch(`${this.url}/list/${type}`, {
|
const request = await fetch(`${this.url}/list/${type}`, {
|
||||||
@ -187,7 +188,8 @@ export class ApiService {
|
|||||||
| "events"
|
| "events"
|
||||||
| "meetings"
|
| "meetings"
|
||||||
| "mentorships"
|
| "mentorships"
|
||||||
| "staff",
|
| "staff"
|
||||||
|
| "testimonials",
|
||||||
id: string,
|
id: string,
|
||||||
token: string,
|
token: string,
|
||||||
): Promise<SuccessResponse | ErrorResponse> {
|
): Promise<SuccessResponse | ErrorResponse> {
|
||||||
|
@ -58,11 +58,21 @@
|
|||||||
>
|
>
|
||||||
Staff Applications
|
Staff Applications
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
[disabled]="view === 'testimonials'"
|
||||||
|
type="button"
|
||||||
|
(click)="setView('testimonials')"
|
||||||
|
>
|
||||||
|
Testimonials
|
||||||
|
</button>
|
||||||
<h2>{{ view }}</h2>
|
<h2>{{ view }}</h2>
|
||||||
<div *ngFor="let datum of data">
|
<div *ngFor="let datum of data">
|
||||||
<h3>{{ datum.email }}</h3>
|
<h3>{{ datum.email }}</h3>
|
||||||
<div *ngFor="let obj of datum.info">
|
<div *ngFor="let obj of datum.info">
|
||||||
<p><strong>{{ obj.key }}</strong>: {{ obj.value }}</p>
|
<p>
|
||||||
|
<strong>{{ obj.key }}</strong
|
||||||
|
>: {{ obj.value }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" (click)="markReviewed(datum.id)">
|
<button type="button" (click)="markReviewed(datum.id)">
|
||||||
Mark as Reviewed
|
Mark as Reviewed
|
||||||
|
@ -41,7 +41,8 @@ export class ReviewComponent {
|
|||||||
| "events"
|
| "events"
|
||||||
| "meetings"
|
| "meetings"
|
||||||
| "mentorships"
|
| "mentorships"
|
||||||
| "staff" = "";
|
| "staff"
|
||||||
|
| "testimonials" = "";
|
||||||
|
|
||||||
public constructor(private readonly apiService: ApiService) {
|
public constructor(private readonly apiService: ApiService) {
|
||||||
const storedToken = localStorage.getItem("token");
|
const storedToken = localStorage.getItem("token");
|
||||||
@ -98,7 +99,8 @@ export class ReviewComponent {
|
|||||||
| "events"
|
| "events"
|
||||||
| "meetings"
|
| "meetings"
|
||||||
| "mentorships"
|
| "mentorships"
|
||||||
| "staff";
|
| "staff"
|
||||||
|
| "testimonials";
|
||||||
void this.apiService.
|
void this.apiService.
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- We know token is not null
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- We know token is not null
|
||||||
markReviewed(view, id, this.token.value!).then((data) => {
|
markReviewed(view, id, this.token.value!).then((data) => {
|
||||||
@ -120,7 +122,8 @@ export class ReviewComponent {
|
|||||||
| "events"
|
| "events"
|
||||||
| "meetings"
|
| "meetings"
|
||||||
| "mentorships"
|
| "mentorships"
|
||||||
| "staff",
|
| "staff"
|
||||||
|
| "testimonials",
|
||||||
): void {
|
): void {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- We know token is not null
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- We know token is not null
|
||||||
|
@ -14,6 +14,7 @@ import type {
|
|||||||
Mentorships,
|
Mentorships,
|
||||||
PrismaClient,
|
PrismaClient,
|
||||||
Staff,
|
Staff,
|
||||||
|
Testimonials,
|
||||||
} from "@prisma/client";
|
} from "@prisma/client";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +28,14 @@ const listUnreviewedSubmissions = async(
|
|||||||
route: DatabasePath,
|
route: DatabasePath,
|
||||||
): Promise<
|
): Promise<
|
||||||
Array<
|
Array<
|
||||||
Appeals | Commissions | Contacts | Events | Meetings | Mentorships | Staff
|
| Appeals
|
||||||
|
| Commissions
|
||||||
|
| Contacts
|
||||||
|
| Events
|
||||||
|
| Meetings
|
||||||
|
| Mentorships
|
||||||
|
| Staff
|
||||||
|
| Testimonials
|
||||||
>
|
>
|
||||||
> => {
|
> => {
|
||||||
const query = {};
|
const query = {};
|
||||||
@ -46,6 +54,8 @@ const listUnreviewedSubmissions = async(
|
|||||||
return await database.mentorships.findMany(query);
|
return await database.mentorships.findMany(query);
|
||||||
case "staff":
|
case "staff":
|
||||||
return await database.staff.findMany(query);
|
return await database.staff.findMany(query);
|
||||||
|
case "testimonials":
|
||||||
|
return await database.testimonials.findMany(query);
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@ -79,6 +89,8 @@ const checkSubmissionExists = async(
|
|||||||
return Boolean(await database.mentorships.findUnique(query));
|
return Boolean(await database.mentorships.findUnique(query));
|
||||||
case "staff":
|
case "staff":
|
||||||
return Boolean(await database.staff.findUnique(query));
|
return Boolean(await database.staff.findUnique(query));
|
||||||
|
case "testimonials":
|
||||||
|
return Boolean(await database.testimonials.findUnique(query));
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -122,6 +134,9 @@ const markSubmissionReviewed = async(
|
|||||||
case "staff":
|
case "staff":
|
||||||
await database.staff.delete(update);
|
await database.staff.delete(update);
|
||||||
break;
|
break;
|
||||||
|
case "testimonials":
|
||||||
|
await database.testimonials.delete(update);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user