Skip to content

Commit 947829d

Browse files
committed
Changed profileURL proeprty to profilePath. Fixed Slack notifications
1 parent b75d0e2 commit 947829d

File tree

11 files changed

+40
-35
lines changed

11 files changed

+40
-35
lines changed

client/src/features/cohorts/Cohorts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface Cohort {
88
export interface TraineeSummary {
99
id: string;
1010
displayName: string;
11-
profileURL: string;
11+
profilePath: string;
1212
thumbnailURL: string | null;
1313
location?: string;
1414
hasWorkPermit?: boolean;

client/src/features/cohorts/components/CohortAccordion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const CohortAccordion = ({ cohortInfo }: CohortAccordionProps) => {
7272
hover
7373
sx={{ '&:last-child td, &:last-child th': { border: 0 }, cursor: 'pointer', textDecoration: 'none' }}
7474
component={Link}
75-
to={trainee.profileURL}
75+
to={trainee.profilePath}
7676
>
7777
<TableCell component="th" scope="row">
7878
<TraineeAvatar imageURL={trainee.thumbnailURL ?? ''} altText={trainee.displayName}></TraineeAvatar>

client/src/features/search/Search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ export interface SearchResult {
22
id: number;
33
name: string;
44
thumbnail: string | null;
5-
profileURL: string;
5+
profilePath: string;
66
cohort: number | null;
77
}

client/src/features/search/components/SearchResultsList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const SearchResultsList = ({ isLoading, data }: SearchResultsListProps) => {
3939
return (
4040
<ListItem disablePadding key={trainee.id}>
4141
<Link
42-
to={trainee.profileURL}
42+
to={trainee.profilePath}
4343
style={{
4444
textDecoration: 'none',
4545
color: 'inherit',

server/api.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ paths:
149149
name:
150150
type: string
151151
example: John Doe
152-
profileURL:
152+
profilePath:
153153
type: string
154-
example: https://example.com/trainee/Isaac-Pagaca_HpOjvmwX
154+
example: /trainee/Isaac-Pagaca_HpOjvmwX
155155
thumbnailURL:
156156
type: string
157157
example: https://cdn.example.com/images/HpOjvmwX_thumb.jpeg
@@ -1280,9 +1280,9 @@ components:
12801280
displayName:
12811281
type: string
12821282
example: Johnny Doe
1283-
profileURL:
1283+
profilePath:
12841284
type: string
1285-
example: https://example.com/trainee/Isaac-Pagaca_HpOjvmwX
1285+
example: /trainee/Isaac-Pagaca_HpOjvmwX
12861286
imageURL:
12871287
type: string
12881288
example: https://cdn.example.com/images/profile/HpOjvmwX.jpeg

server/scripts/setup/generators/traineeGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const generateTrainee = (): Trainee => {
3939
displayName: '',
4040
createdAt: new Date(),
4141
updatedAt: new Date(),
42-
profileURL: '',
42+
profilePath: '',
4343
personalInfo,
4444
contactInfo,
4545
educationInfo,

server/src/controllers/CohortsController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface Cohort {
1010
interface TraineeSummary {
1111
id: string;
1212
displayName: string;
13-
profileURL: string;
13+
profilePath: string;
1414
thumbnailURL: string | null;
1515
location?: string;
1616
hasWorkPermit?: boolean;
@@ -65,7 +65,7 @@ export class CohortsController implements CohortsControllerType {
6565
return {
6666
id: trainee.id,
6767
displayName: trainee.displayName,
68-
profileURL: trainee.profileURL,
68+
profilePath: trainee.profilePath,
6969
thumbnailURL: trainee.thumbnailURL ?? null,
7070
location: trainee.personalInfo.location,
7171
hasWorkPermit: trainee.personalInfo.hasWorkPermit,

server/src/controllers/SearchController.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface SearchResult {
1616
id: string;
1717
name: string;
1818
thumbnail: string | null;
19-
profileURL: string;
19+
profilePath: string;
2020
cohort: number | null;
2121
searchScore: number;
2222
}
@@ -70,7 +70,6 @@ export class SearchController implements SearchControllerType {
7070
// In an ideal scenario we should have a complex query to filter on the DB side.
7171
// However, because our dataset is not large, we can get away with this for now.
7272
const trainees = await this.traineesRepository.getAllTrainees();
73-
7473
// Process all trainees, calculate the search score and return the top N results
7574
return trainees
7675
.map((trainee) => {
@@ -79,7 +78,7 @@ export class SearchController implements SearchControllerType {
7978
name: `${trainee.displayName}`,
8079
thumbnail: trainee.thumbnailURL ?? null,
8180
cohort: trainee.educationInfo.currentCohort ?? null,
82-
profileURL: trainee.profileURL,
81+
profilePath: trainee.profilePath,
8382
searchScore: this.calculateScore(trainee, keywords),
8483
};
8584
})

server/src/models/Trainee.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export interface Trainee {
9090
readonly id: string;
9191
readonly createdAt: Date;
9292
readonly updatedAt: Date;
93-
profileURL: string;
93+
profilePath: string;
9494
displayName: string;
9595
imageURL?: string;
9696
thumbnailURL?: string;
@@ -175,11 +175,17 @@ export const getDisplayName = (trainee: Trainee): string => {
175175
return `${name} ${lastName}`;
176176
};
177177

178-
export const getProfileURL = (trainee: Trainee): string => {
178+
export const getProfilePath = (trainee: Trainee): string => {
179179
const normalizedName = removeAccents(getDisplayName(trainee).toLowerCase()).replaceAll(/\s/g, '-');
180180
return `/trainee/${normalizedName}_${trainee.id}`;
181181
};
182182

183+
export const getProfileURL = (trainee: Trainee): string => {
184+
const url = new URL(process.env.BASE_URL ?? 'https://localhost');
185+
url.pathname = getProfilePath(trainee);
186+
return url.toString();
187+
};
188+
183189
// Validations
184190
export const validateTrainee = (trainee: Trainee): void => {
185191
validatePersonalInfo(trainee.personalInfo);

server/src/schemas/TraineeSchema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
TraineeEmploymentInfo,
2424
TraineePersonalInfo,
2525
getDisplayName,
26-
getProfileURL,
26+
getProfilePath,
2727
} from '../models';
2828
import { WithMongoID, jsonFormatting } from '../utils/database';
2929

@@ -185,8 +185,8 @@ TraineeSchema.virtual('displayName').get(function () {
185185
return getDisplayName(this as Trainee);
186186
});
187187

188-
TraineeSchema.virtual('profileURL').get(function () {
189-
return getProfileURL(this as Trainee);
188+
TraineeSchema.virtual('profilePath').get(function () {
189+
return getProfilePath(this as Trainee);
190190
});
191191

192192
TraineeSchema.set('toJSON', jsonFormatting);

0 commit comments

Comments
 (0)