4 Commits

Author SHA1 Message Date
fc3f175150 chore: remove colons from input componentns
All checks were successful
Node.js CI / Lint and Test (pull_request) Successful in 1m37s
2025-03-01 21:48:39 -05:00
9fb83b100c chore: add sonar workflow
All checks were successful
Code Analysis / SonarQube (push) Successful in 1m48s
Node.js CI / Lint and Test (push) Successful in 3m13s
2025-02-26 13:23:59 -08:00
88de1e309c fix: include testimonials in review/list endpoints
All checks were successful
Node.js CI / Lint and Test (push) Successful in 1m51s
2025-02-20 18:13:26 -08:00
f8662980af feat: add form for submitting testimonials (#3)
All checks were successful
Node.js CI / Lint and Test (push) Successful in 1m48s
### Explanation

_No response_

### Issue

_No response_

### Attestations

- [x] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [x] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [x] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [x] I have run the linter and resolved any errors.
- [x] My pull request uses an appropriate title, matching the conventional commit standards.
- [x] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

Minor - My pull request introduces a new non-breaking feature.

Reviewed-on: nhcarrigan/forms#3
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2025-02-20 16:07:39 -08:00
30 changed files with 331 additions and 46 deletions

View File

@ -0,0 +1,34 @@
name: Code Analysis
on:
push:
branches:
- main
jobs:
sonar:
name: SonarQube
steps:
- name: Checkout Source Files
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: SonarCube Scan
uses: SonarSource/sonarqube-scan-action@v4
timeout-minutes: 10
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: "https://quality.nhcarrigan.com"
with:
args: >
-Dsonar.sources=.
-Dsonar.projectKey=forms
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@v1
with:
pollingTimeoutSec: 600
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: "https://quality.nhcarrigan.com"

View File

@ -16,6 +16,7 @@ import type {
SuccessResponse, SuccessResponse,
Staff, Staff,
DataResponse, DataResponse,
Testimonial,
} from "@repo/types"; } from "@repo/types";
@Injectable({ @Injectable({
@ -142,6 +143,20 @@ export class ApiService {
return response; return response;
} }
public async submitTestimonial(
testimonial: Partial<Testimonial>,
): Promise<SuccessResponse | ErrorResponse> {
const request = await fetch(`${this.url}/submit/testimonials`, {
body: JSON.stringify(testimonial),
headers: {
"Content-type": "application/json",
},
method: "POST",
});
const response = await request.json() as SuccessResponse | ErrorResponse;
return response;
}
public async getData( public async getData(
type: type:
| "appeals" | "appeals"
@ -150,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}`, {
@ -172,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> {

View File

@ -13,6 +13,8 @@ import { MeetingComponent } from "./forms/meeting/meeting.component.js";
import { MentorshipComponent } import { MentorshipComponent }
from "./forms/mentorship/mentorship.component.js"; from "./forms/mentorship/mentorship.component.js";
import { StaffComponent } from "./forms/staff/staff.component.js"; import { StaffComponent } from "./forms/staff/staff.component.js";
import { TestimonialComponent }
from "./forms/testimonial/testimonial.component.js";
import { HomeComponent } from "./home/home.component.js"; import { HomeComponent } from "./home/home.component.js";
import { ReviewComponent } from "./review/review.component.js"; import { ReviewComponent } from "./review/review.component.js";
import type { Routes } from "@angular/router"; import type { Routes } from "@angular/router";
@ -27,4 +29,5 @@ export const routes: Routes = [
{ component: MentorshipComponent, path: "mentorship" }, { component: MentorshipComponent, path: "mentorship" },
{ component: StaffComponent, path: "staff" }, { component: StaffComponent, path: "staff" },
{ component: ReviewComponent, path: "review" }, { component: ReviewComponent, path: "review" },
{ component: TestimonialComponent, path: "testimonial" },
]; ];

View File

@ -7,18 +7,18 @@
<app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo> <app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo>
<app-checkbox [control]="understandBinding" label="I understand that the decision made by the appeals team is final and binding. If my appeal is denied, I agree that I cannot appeal again."></app-checkbox> <app-checkbox [control]="understandBinding" label="I understand that the decision made by the appeals team is final and binding. If my appeal is denied, I agree that I cannot appeal again."></app-checkbox>
<div class="two-col"> <div class="two-col">
<app-select-menu label="What sanction was levied against you?" options="reminder,warning,temporary removal,permanent removal" [control]="sanctionType"></app-select-menu> <app-select-menu label="What sanction was levied against you?:" options="reminder,warning,temporary removal,permanent removal" [control]="sanctionType"></app-select-menu>
<app-single-line label="What is your moderation case number?" type="number" [control]="caseNumber"></app-single-line> <app-single-line label="What is your moderation case number?:" type="number" [control]="caseNumber"></app-single-line>
</div> </div>
<div class="two-col"> <div class="two-col">
<app-select-menu label="What platform were you sanctioned on?" options="Forum,IRC,Matrix,Gitea,Fediverse" [control]="sanctionPlatform"></app-select-menu> <app-select-menu label="What platform were you sanctioned on?:" options="Forum,IRC,Matrix,Gitea,Fediverse" [control]="sanctionPlatform"></app-select-menu>
<app-single-line label="What is your username on that platform?" type="text" [control]="platformUsername"></app-single-line> <app-single-line label="What is your username on that platform?:" type="text" [control]="platformUsername"></app-single-line>
</div> </div>
<app-multi-line label="Why were you sanctioned? Use your own words. Do NOT copy the sanction reason you were provided by our team." [control]="sanctionReason"></app-multi-line> <app-multi-line label="Why were you sanctioned? Use your own words. Do NOT copy the sanction reason you were provided by our team.:" [control]="sanctionReason"></app-multi-line>
<app-multi-line label="Do you feel the sanction was fair? Why or why not?" [control]="sanctionFair"></app-multi-line> <app-multi-line label="Do you feel the sanction was fair? Why or why not?:" [control]="sanctionFair"></app-multi-line>
<app-multi-line label="How did your behaviour violate our Code of Conduct, Community Guidelines, or other policies?" [control]="behaviourViolation"></app-multi-line> <app-multi-line label="How did your behaviour violate our Code of Conduct, Community Guidelines, or other policies?:" [control]="behaviourViolation"></app-multi-line>
<app-multi-line label="Why do you feel this sanction should be revoked?" [control]="appealReason"></app-multi-line> <app-multi-line label="Why do you feel this sanction should be revoked?:" [control]="appealReason"></app-multi-line>
<app-multi-line label="How will you improve your conduct to prevent future sanctions?" [control]="behaviourImprove"></app-multi-line> <app-multi-line label="How will you improve your conduct to prevent future sanctions?:" [control]="behaviourImprove"></app-multi-line>
<app-consent [control]="consent"></app-consent> <app-consent [control]="consent"></app-consent>
<button type="button" (click)="submit($event)">Submit</button> <button type="button" (click)="submit($event)">Submit</button>
</form> </form>

View File

@ -4,7 +4,7 @@
<app-success *ngIf="success"></app-success> <app-success *ngIf="success"></app-success>
<form *ngIf="!loading"> <form *ngIf="!loading">
<app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo> <app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo>
<app-multi-line label="Explain your business needs and how we can meet those needs for you. Be as descriptive as possible." [control]="request"></app-multi-line> <app-multi-line label="Explain your business needs and how we can meet those needs for you. Be as descriptive as possible.:" [control]="request"></app-multi-line>
<app-consent [control]="consent"></app-consent> <app-consent [control]="consent"></app-consent>
<button type="button" (click)="submit($event)">Submit</button> <button type="button" (click)="submit($event)">Submit</button>
</form> </form>

View File

@ -5,7 +5,7 @@
<app-success *ngIf="success"></app-success> <app-success *ngIf="success"></app-success>
<form *ngIf="!loading"> <form *ngIf="!loading">
<app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo> <app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo>
<app-multi-line label="What can we help you with today?" [control]="request"></app-multi-line> <app-multi-line label="What can we help you with today?:" [control]="request"></app-multi-line>
<app-consent [control]="consent"></app-consent> <app-consent [control]="consent"></app-consent>
<button type="button" (click)="submit($event)">Submit</button> <button type="button" (click)="submit($event)">Submit</button>
</form> </form>

View File

@ -4,11 +4,11 @@
<app-success *ngIf="success"></app-success> <app-success *ngIf="success"></app-success>
<form *ngIf="!loading"> <form *ngIf="!loading">
<app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo> <app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo>
<app-multi-line label="What is your event about?" [control]="eventDescription"></app-multi-line> <app-multi-line label="What is your event about?:" [control]="eventDescription"></app-multi-line>
<app-multi-line label="What would you like us to speak about at your event?" [control]="eventTopic"></app-multi-line> <app-multi-line label="What would you like us to speak about at your event?:" [control]="eventTopic"></app-multi-line>
<app-single-line label="Where is your event located? Provide an address if in-person, a URL if remote." type="text" [control]="eventLocation"></app-single-line> <app-single-line label="Where is your event located? Provide an address if in-person, a URL if remote.:" type="text" [control]="eventLocation"></app-single-line>
<app-single-line label="When is your event?" type="text" [control]="eventDate"></app-single-line> <app-single-line label="When is your event?:" type="text" [control]="eventDate"></app-single-line>
<app-single-line label="What is your budget to pay us for attending?" type="text" [control]="eventBudget"></app-single-line> <app-single-line label="What is your budget to pay us for attending?:" type="text" [control]="eventBudget"></app-single-line>
<app-checkbox [control]="travelCovered" label="We will cover travel expenses for NHCarrigan to attend."></app-checkbox> <app-checkbox [control]="travelCovered" label="We will cover travel expenses for NHCarrigan to attend."></app-checkbox>
<app-checkbox [control]="lodgingCovered" label="We will cover lodging expenses for NHCarrigan to attend."></app-checkbox> <app-checkbox [control]="lodgingCovered" label="We will cover lodging expenses for NHCarrigan to attend."></app-checkbox>
<app-checkbox [control]="foodCovered" label="We will cover food expenses for NHCarrigan to attend."></app-checkbox> <app-checkbox [control]="foodCovered" label="We will cover food expenses for NHCarrigan to attend."></app-checkbox>

View File

@ -5,8 +5,8 @@
<app-success *ngIf="success"></app-success> <app-success *ngIf="success"></app-success>
<form *ngIf="!loading"> <form *ngIf="!loading">
<app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo> <app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo>
<app-select-menu [control]="sessionLength" label="How long of a session would you like (in minutes)?" options="15,30,60"></app-select-menu> <app-select-menu [control]="sessionLength" label="How long of a session would you like (in minutes)?:" options="15,30,60"></app-select-menu>
<app-multi-line label="What do you wish to achieve during this session?" [control]="sessionGoal"></app-multi-line> <app-multi-line label="What do you wish to achieve during this session?:" [control]="sessionGoal"></app-multi-line>
<app-checkbox [control]="paymentUnderstanding" label="I understand that I will be invoiced for the session, and that payment must be submitted prior to the scheduled time or our session will be cancelled."></app-checkbox> <app-checkbox [control]="paymentUnderstanding" label="I understand that I will be invoiced for the session, and that payment must be submitted prior to the scheduled time or our session will be cancelled."></app-checkbox>
<app-consent [control]="consent"></app-consent> <app-consent [control]="consent"></app-consent>
<button type="button" (click)="submit($event)">Submit</button> <button type="button" (click)="submit($event)">Submit</button>

View File

@ -4,8 +4,8 @@
<app-success *ngIf="success"></app-success> <app-success *ngIf="success"></app-success>
<form *ngIf="!loading"> <form *ngIf="!loading">
<app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo> <app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo>
<app-multi-line label="What do you want to focus on during your time in our programme?" [control]="mentorshipGoal"></app-multi-line> <app-multi-line label="What do you want to focus on during your time in our programme?:" [control]="mentorshipGoal"></app-multi-line>
<app-multi-line label="Where are you currently at in your learning journey?" [control]="currentFocus"></app-multi-line> <app-multi-line label="Where are you currently at in your learning journey?:" [control]="currentFocus"></app-multi-line>
<app-checkbox [control]="paymentUnderstanding" label="I understand that the programme cost is $200 per month, due on the first of the month. I also understand that failure to pay on the due date will result in my removal from the programme."></app-checkbox> <app-checkbox [control]="paymentUnderstanding" label="I understand that the programme cost is $200 per month, due on the first of the month. I also understand that failure to pay on the due date will result in my removal from the programme."></app-checkbox>
<app-consent [control]="consent"></app-consent> <app-consent [control]="consent"></app-consent>
<button type="button" (click)="submit($event)">Submit</button> <button type="button" (click)="submit($event)">Submit</button>

View File

@ -7,16 +7,16 @@
<app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo> <app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo>
<app-checkbox [control]="understandVolunteer" label="I understand that my membership on the staff team is on a voluntary basis, and I expect no compensation for my time or effort."></app-checkbox> <app-checkbox [control]="understandVolunteer" label="I understand that my membership on the staff team is on a voluntary basis, and I expect no compensation for my time or effort."></app-checkbox>
<div class="two-col"> <div class="two-col">
<app-select-menu [control]="platform" label="Which platform do you wish to moderate?" options="Forum,IRC,Matrix,Gitea,Fediverse"></app-select-menu> <app-select-menu [control]="platform" label="Which platform do you wish to moderate?:" options="Forum,IRC,Matrix,Gitea,Fediverse"></app-select-menu>
<app-single-line label="What is your username on that platform?" type="text" [control]="platformUsername"></app-single-line> <app-single-line label="What is your username on that platform?:" type="text" [control]="platformUsername"></app-single-line>
</div> </div>
<app-multi-line label="Why do you wish to join our team?" [control]="whyJoin"></app-multi-line> <app-multi-line label="Why do you wish to join our team?:" [control]="whyJoin"></app-multi-line>
<app-multi-line label="Describe how your current behaviour in our communities embodies our Code of Conduct, Community Guidelines, and other Policies." [control]="currentBehaviour"></app-multi-line> <app-multi-line label="Describe how your current behaviour in our communities embodies our Code of Conduct, Community Guidelines, and other Policies.:" [control]="currentBehaviour"></app-multi-line>
<app-multi-line label="What prior moderation experience do you have, if any?" [control]="priorExperience"></app-multi-line> <app-multi-line label="What prior moderation experience do you have, if any?:" [control]="priorExperience"></app-multi-line>
<app-multi-line label="You and another member of our team are in disagreement with how to handle a situation, and are unable to reach a consensus. What do you do?" [control]="internalConflict"></app-multi-line> <app-multi-line label="You and another member of our team are in disagreement with how to handle a situation, and are unable to reach a consensus. What do you do?:" [control]="internalConflict"></app-multi-line>
<app-multi-line label="A member of the community has posted material which violates our rules and may be traumatic to other members. How do you address the situation to ensure the well-being of our community?" [control]="handlingTrauma"></app-multi-line> <app-multi-line label="A member of the community has posted material which violates our rules and may be traumatic to other members. How do you address the situation to ensure the well-being of our community?:" [control]="handlingTrauma"></app-multi-line>
<app-multi-line label="Explain a time where you were in a difficult situation, and you had to be the one to resolve it. How did you do so, and why did you take that approach?" [control]="difficultSituation"></app-multi-line> <app-multi-line label="Explain a time where you were in a difficult situation, and you had to be the one to resolve it. How did you do so, and why did you take that approach?:" [control]="difficultSituation"></app-multi-line>
<app-multi-line label="Explain a situation in which you had to display strong leadership. How did you do so, and why did you take that approach?" [control]="leadershipSituation"></app-multi-line> <app-multi-line label="Explain a situation in which you had to display strong leadership. How did you do so, and why did you take that approach?:" [control]="leadershipSituation"></app-multi-line>
<app-consent [control]="consent"></app-consent> <app-consent [control]="consent"></app-consent>
<button type="button" (click)="submit($event)">Submit</button> <button type="button" (click)="submit($event)">Submit</button>
</form> </form>

View File

@ -0,0 +1,12 @@
<h1>Testimonials</h1>
<p>This form allows past clients and colleagues to submit reviews reflecting their positive experience with our work.</p>
<p>We will respond to these submissions when your testimonial is <a href="https://testimonials.nhcarrigan.com" target="_blank">on our site</a>.</p>
<app-error *ngIf="error" error="{{ error }}"></app-error>
<app-success *ngIf="success"></app-success>
<form *ngIf="!loading">
<app-userinfo [firstNameControl]="firstName" [lastNameControl]="lastName" [emailControl]="email" [companyControl]="company"></app-userinfo>
<app-multi-line label="Share your experience working with us!:" [control]="content"></app-multi-line>
<app-consent [control]="consent"></app-consent>
<button type="button" (click)="submit($event)">Submit</button>
</form>
<a routerLink="/">Back to home</a>

View File

@ -0,0 +1,80 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { CommonModule } from "@angular/common";
import { Component } from "@angular/core";
import { FormControl, ReactiveFormsModule } from "@angular/forms";
import { RouterModule } from "@angular/router";
import { ApiService } from "../../api.service.js";
import { ConsentComponent } from "../../consent/consent.component.js";
import { ErrorComponent } from "../../error/error.component.js";
import { MultiLineComponent }
from "../../inputs/multi-line/multi-line.component.js";
import { SuccessComponent } from "../../success/success.component.js";
import { UserinfoComponent } from "../../userinfo/userinfo.component.js";
@Component({
imports: [
RouterModule,
CommonModule,
ConsentComponent,
UserinfoComponent,
ErrorComponent,
ReactiveFormsModule,
MultiLineComponent,
SuccessComponent,
],
selector: "app-testimonial",
styleUrl: "./testimonial.component.css",
templateUrl: "./testimonial.component.html",
})
export class TestimonialComponent {
public loading = false;
public error = "";
public success = false;
public firstName = new FormControl("");
public lastName = new FormControl("");
public email = new FormControl("");
public company = new FormControl("");
public content = new FormControl("");
public consent = new FormControl(false);
public constructor(private readonly apiService: ApiService) {}
public submit(event: MouseEvent): void {
this.error = "";
const { form } = event.target as HTMLButtonElement;
const valid = form?.reportValidity();
if (valid !== true) {
return;
}
this.loading = true;
this.apiService.
submitTestimonial({
consent: this.consent.value ?? false,
content: this.content.value ?? undefined,
email: this.email.value ?? undefined,
firstName: this.firstName.value ?? undefined,
lastName: this.lastName.value ?? undefined,
}).
then((response) => {
if ("error" in response) {
this.error = response.error;
this.loading = false;
} else {
this.error = "";
this.success = true;
}
}).
catch(() => {
this.error = "An error occurred while submitting the form.";
this.loading = false;
});
}
}

View File

@ -29,3 +29,6 @@
<a routerLink="/mentorship"> <a routerLink="/mentorship">
<i class="fa-solid fa-brain" aria-hidden="true"></i> Mentorship Programme <i class="fa-solid fa-brain" aria-hidden="true"></i> Mentorship Programme
</a> </a>
<a routerLink="/testimonial">
<i class="fa-solid fa-star-half-stroke" aria-hidden="true"></i> Testimonials
</a>

View File

@ -1,4 +1,4 @@
<div> <div>
<label for="{{label()}}-input">{{ label() }}:</label> <label for="{{label()}}-input">{{ label() }}</label>
<textarea id="{{label()}}-input" required [formControl]="control()"></textarea> <textarea id="{{label()}}-input" required [formControl]="control()"></textarea>
</div> </div>

View File

@ -1,5 +1,5 @@
<div> <div>
<label for="{{label()}}-input">{{ label() }}:</label> <label for="{{label()}}-input">{{ label() }}</label>
<select id="{{label()}}-input" [formControl]="control()" required> <select id="{{label()}}-input" [formControl]="control()" required>
<option value="" disabled selected>Select an option</option> <option value="" disabled selected>Select an option</option>
<option *ngFor="let option of options().split(',')" [value]="option">{{ option }}</option> <option *ngFor="let option of options().split(',')" [value]="option">{{ option }}</option>

View File

@ -1,4 +1,4 @@
<div> <div>
<label for="{{label()}}-input">{{ label() }}:</label> <label for="{{label()}}-input">{{ label() }}</label>
<input [type]="type()" id="{{label()}}-input" required [formControl]="control()" /> <input [type]="type()" id="{{label()}}-input" required [formControl]="control()" />
</div> </div>

View File

@ -2,7 +2,7 @@
<app-error *ngIf="error" error="{{ error }}"></app-error> <app-error *ngIf="error" error="{{ error }}"></app-error>
<form *ngIf="!valid"> <form *ngIf="!valid">
<app-single-line <app-single-line
label="API Key" label="API Key:"
[control]="token" [control]="token"
type="text" type="text"
></app-single-line> ></app-single-line>
@ -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

View File

@ -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

View File

@ -1,8 +1,8 @@
<div class="two-col"> <div class="two-col">
<app-single-line label="First Name" type="text" [control]="firstNameControl()"></app-single-line> <app-single-line label="First Name:" type="text" [control]="firstNameControl()"></app-single-line>
<app-single-line label="Last Name" type="text" [control]="lastNameControl()"></app-single-line> <app-single-line label="Last Name:" type="text" [control]="lastNameControl()"></app-single-line>
</div> </div>
<div class="two-col"> <div class="two-col">
<app-single-line label="Email" type="email" [control]="emailControl()"></app-single-line> <app-single-line label="Email:" type="email" [control]="emailControl()"></app-single-line>
<app-single-line label="Company Name" type="text" [control]="companyControl()"></app-single-line> <app-single-line label="Company Name:" type="text" [control]="companyControl()"></app-single-line>
</div> </div>

View File

@ -0,0 +1,13 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
export interface Testimonial {
consent: boolean;
content: string;
email: string;
firstName: string;
lastName: string;
}

View File

@ -11,6 +11,7 @@ import type { Event } from "./forms/event.js";
import type { Meeting } from "./forms/meeting.js"; import type { Meeting } from "./forms/meeting.js";
import type { Mentorship } from "./forms/mentorship.js"; import type { Mentorship } from "./forms/mentorship.js";
import type { Staff } from "./forms/staff.js"; import type { Staff } from "./forms/staff.js";
import type { Testimonial } from "./forms/testimonial.js";
import type { ReviewRequest } from "./requests/review.js"; import type { ReviewRequest } from "./requests/review.js";
import type { DataResponse } from "./responses/data.js"; import type { DataResponse } from "./responses/data.js";
import type { ErrorResponse } from "./responses/error.js"; import type { ErrorResponse } from "./responses/error.js";
@ -28,4 +29,5 @@ export type {
DataResponse, DataResponse,
ErrorResponse, ErrorResponse,
SuccessResponse, SuccessResponse,
Testimonial,
}; };

View File

@ -103,3 +103,12 @@ model Mentorships {
paymentUnderstanding Boolean paymentUnderstanding Boolean
createdAt DateTime @default(now()) createdAt DateTime @default(now())
} }
model Testimonials {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
firstName String
lastName String
content String
createdAt DateTime @default(now())
}

View File

@ -0,0 +1,64 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { validateBody } from "../../modules/validateBody.js";
import { logger } from "../../utils/logger.js";
import { sendMail } from "../../utils/mailer.js";
import type { PrismaClient } from "@prisma/client";
import type { Testimonial, ErrorResponse, SuccessResponse } from "@repo/types";
import type { FastifyReply, FastifyRequest } from "fastify";
/**
*Handles testimonial form submissions.
* @param database - The Prisma database client.
* @param request - The request object.
* @param response - The Fastify reply utility.
*/
export const submitTestimonialHandler = async(
database: PrismaClient,
request: FastifyRequest<{ Body: Testimonial }>,
response: FastifyReply<{ Reply: SuccessResponse | ErrorResponse }>,
): Promise<void> => {
try {
const isInvalid = validateBody(
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- We're passing a narrower type and TS hates that?
request.body as unknown as Record<string, unknown>,
"testimonials",
);
if (isInvalid !== null) {
await response.status(400).send({ error: isInvalid });
return;
}
const exists = await database.staff.findUnique({
where: {
email: request.body.email,
},
});
if (exists !== null) {
await response.
status(429).
send({
error:
// eslint-disable-next-line stylistic/max-len -- This is a long string.
"You have already submitted a staff application. Please wait for it to be reviewed.",
});
return;
}
const data = { ...request.body };
// @ts-expect-error -- We're deleting a property here.
delete data.consent;
await database.testimonials.create({
data,
});
await sendMail("testimonials", data);
await response.send({ success: true });
} catch (error) {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we bein' lazy.
await logger.error("/submit/testimonials", error as Error);
await response.status(500).send({ error: error instanceof Error
? error.message
: "Internal Server Error" });
}
};

View File

@ -9,4 +9,5 @@ export type DatabasePath = | "appeals"
| "events" | "events"
| "meetings" | "meetings"
| "mentorships" | "mentorships"
| "staff"; | "staff"
| "testimonials";

View File

@ -14,6 +14,7 @@ import type {
Mentorships, Mentorships,
PrismaClient, PrismaClient,
Staff, Staff,
Testimonials,
} from "@prisma/client"; } from "@prisma/client";
/** /**
@ -27,10 +28,17 @@ 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 = {};
switch (route) { switch (route) {
case "appeals": case "appeals":
return await database.appeals.findMany(query); return await database.appeals.findMany(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;
} }

View File

@ -70,6 +70,12 @@ const validators: Record<DatabasePath, Array<string>> = {
"difficultSituation", "difficultSituation",
"leadershipSituation", "leadershipSituation",
], ],
testimonials: [
"firstName",
"lastName",
"email",
"content",
],
}; };
/** /**

View File

@ -22,6 +22,7 @@ export const listRoutes: WrappedRoute = (database) => {
"meetings", "meetings",
"mentorships", "mentorships",
"staff", "staff",
"testimonials",
]; ];
for (const route of routes) { for (const route of routes) {
fastify.get(`/list/${route}`, async(_request, response) => { fastify.get(`/list/${route}`, async(_request, response) => {

View File

@ -27,6 +27,7 @@ export const reviewRoutes: WrappedRoute = (database) => {
"meetings", "meetings",
"mentorships", "mentorships",
"staff", "staff",
"testimonials",
]; ];
for (const route of routes) { for (const route of routes) {
fastify.put<{ fastify.put<{

View File

@ -13,6 +13,8 @@ import { submitMeetingHandler } from "../handlers/submit/meetingHandler.js";
import { submitMentorshipHandler } import { submitMentorshipHandler }
from "../handlers/submit/mentorshipHandler.js"; from "../handlers/submit/mentorshipHandler.js";
import { submitStaffHandler } from "../handlers/submit/staffHandler.js"; import { submitStaffHandler } from "../handlers/submit/staffHandler.js";
import { submitTestimonialHandler }
from "../handlers/submit/testimonialHandler.js";
import type { WrappedRoute } from "../interfaces/wrappedRoute.js"; import type { WrappedRoute } from "../interfaces/wrappedRoute.js";
import type { import type {
Appeal, Appeal,
@ -24,6 +26,7 @@ import type {
Staff, Staff,
ErrorResponse, ErrorResponse,
SuccessResponse, SuccessResponse,
Testimonial,
} from "@repo/types"; } from "@repo/types";
/** /**
@ -31,6 +34,7 @@ import type {
* @param database - The Prisma client. * @param database - The Prisma client.
* @returns A Fastify plugin. * @returns A Fastify plugin.
*/ */
// eslint-disable-next-line max-lines-per-function -- Prisma typings don't allow us to mount these dynamically...
export const submitRoutes: WrappedRoute = (database) => { export const submitRoutes: WrappedRoute = (database) => {
return async(fastify) => { return async(fastify) => {
fastify.post<{ Body: Appeal; Reply: SuccessResponse | ErrorResponse }>( fastify.post<{ Body: Appeal; Reply: SuccessResponse | ErrorResponse }>(
@ -81,5 +85,12 @@ export const submitRoutes: WrappedRoute = (database) => {
await submitStaffHandler(database, request, response); await submitStaffHandler(database, request, response);
}, },
); );
fastify.post<{ Body: Testimonial; Reply: SuccessResponse | ErrorResponse }>(
"/submit/testimonials",
async(request, response) => {
await submitTestimonialHandler(database, request, response);
},
);
}; };
}; };