Skip to content

Commit

Permalink
[FIX] supervisor null check (#467)
Browse files Browse the repository at this point in the history
* supervisor null check

* fix: gov.bc.ca, lowercase
  • Loading branch information
fw-noel authored Jan 21, 2025
1 parent 10514f5 commit fc30ad2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions backend/src/personnel/personnel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export class PersonnelService {
): Promise<PersonnelEntity> {
const person = await this.findOneById(id);

if (!!personnel.supervisorEmail) {
personnel.supervisorEmail = personnel.supervisorEmail.toLowerCase();
}

if (personnel.tools?.[0]?.hasOwnProperty('tool')) {
const allTools = await this.toolsRepository.find();
const personnelTools = personnel.tools.map((t) => ({
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/recommitment/RecommitmentFormBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,10 @@ export const RecommitmentFormBase = ({
// For SupervisorForm, require first name, last name, and email
if (currentComponentType === SupervisorForm) {
const { firstName, lastName, email } = supervisorInformation;
const isValidEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
const isValidEmail = /^[^\s@]+@gov.bc.ca+$/.test(email);

return Boolean(
firstName.trim() && lastName.trim() && email.trim() && isValidEmail,
firstName?.trim() && lastName?.trim() && email?.trim() && isValidEmail,
);
}

Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/recommitment/SupervisorForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const SupervisorForm = ({ initialData, onUpdate }: SupervisorFormProps) =
onChange={handleChange}
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500"
/>
<p className="text-xs text-gray-600">Must be a valid @gov.bc.ca email</p>
</div>

{/* Phone */}
Expand Down

0 comments on commit fc30ad2

Please sign in to comment.