Skip to content

Commit

Permalink
Use FullName for events students #712 #713
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed Dec 17, 2024
1 parent 5d356d9 commit b579fa8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
12 changes: 4 additions & 8 deletions src/app/events/services/events-students-state.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,19 @@ describe("EventsStudentsStateService", () => {
};

const paul = buildStudent(10);
paul.FirstName = "Paul";
paul.LastName = "McCartney";
paul.FullName = "McCartney Paul";
paul.DisplayEmail = "[email protected]";

const john = buildStudent(20);
john.FirstName = "John";
john.LastName = "Lennon";
john.FullName = "Lennon John";
john.DisplayEmail = "[email protected]";

const george = buildStudent(30);
george.FirstName = "George";
george.LastName = "Harrison";
george.FullName = "Harrison George";
george.DisplayEmail = "[email protected]";

const ringo = buildStudent(40);
ringo.FirstName = "Ringo";
ringo.LastName = "Starr";
ringo.FullName = "Starr Ringo";
ringo.DisplayEmail = "[email protected]";

students = [paul, john, george, ringo];
Expand Down
4 changes: 2 additions & 2 deletions src/app/events/utils/events-students.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function convertCourseToStudentEntries(course: Course): StudentEntries {
(student) =>
({
id: student.Id,
name: `${student.LastName} ${student.FirstName}`,
name: student.FullName,
email: student.DisplayEmail ?? undefined,
}) satisfies StudentEntry,
) ?? [];
Expand Down Expand Up @@ -70,7 +70,7 @@ export function convertPersonsToStudentEntries(
(person) =>
({
id: person.Id,
name: `${person.LastName} ${person.FirstName}`,
name: person.FullName,
email: person.DisplayEmail ?? undefined,
status: subscriptions.find((s) => s.PersonId === person.Id)?.Status,
}) satisfies StudentEntry,
Expand Down
3 changes: 1 addition & 2 deletions src/app/shared/models/person.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const Person = t.type({
const PersonSummary = t.type({
Id: t.number,
DisplayEmail: Option(t.string),
FirstName: t.string,
LastName: t.string,
FullName: t.string,
});

type Person = t.TypeOf<typeof Person>;
Expand Down
7 changes: 3 additions & 4 deletions src/app/shared/services/persons-rest.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ describe("PersonsRestService", () => {
const personSummaries: ReadonlyArray<PersonSummary> = [
buildPersonSummary(54425),
buildPersonSummary(56200),
].map(({ Id, FirstName, LastName, DisplayEmail }) => ({
].map(({ Id, FullName, DisplayEmail }) => ({
Id,
FirstName,
LastName,
FullName,
DisplayEmail,
}));

Expand All @@ -52,7 +51,7 @@ describe("PersonsRestService", () => {

httpTestingController
.expectOne(
"https://eventotest.api/Persons/?filter.Id=;54425;56200&fields=Id,FirstName,LastName,DisplayEmail",
"https://eventotest.api/Persons/?filter.Id=;54425;56200&fields=Id,FullName,DisplayEmail",
)
.flush(personSummaries);
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/services/persons-rest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class PersonsRestService extends RestService<typeof Person> {
.get<unknown>(`${this.baseUrl}/`, {
params: {
"filter.Id": `;${ids.join(";")}`,
fields: ["Id", "FirstName", "LastName", "DisplayEmail"].join(","),
fields: ["Id", "FullName", "DisplayEmail"].join(","),
},
})
.pipe(switchMap(decodeArray(PersonSummary)));
Expand Down
3 changes: 1 addition & 2 deletions src/spec-builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ export function buildPersonSummary(id: number): PersonSummary {
return {
Id: id,
DisplayEmail: null,
FirstName: "T",
LastName: "Tux",
FullName: "Tux",
};
}

Expand Down

0 comments on commit b579fa8

Please sign in to comment.