Skip to content

Commit

Permalink
VKT(Backend&Frontend): Better align data shown on ExaminerContactRequ…
Browse files Browse the repository at this point in the history
…estListing with designs [deploy]
  • Loading branch information
pkoivisto committed Dec 30, 2024
1 parent 4b255c2 commit 61c2548
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package fi.oph.vkt.api.dto.examiner;

import jakarta.validation.constraints.NotEmpty;
import java.util.List;
import java.time.LocalDate;
import lombok.Builder;
import lombok.NonNull;

@Builder
public record ExaminerContactRequestDTO(@NonNull Long id, @NonNull String lastName, @NonNull String firstName) {}
public record ExaminerContactRequestDTO(
@NonNull Long id,
@NonNull String lastName,
@NonNull String firstName,
@NonNull String email,
@NonNull LocalDate contactDate
) {}
2 changes: 2 additions & 0 deletions backend/vkt/src/main/java/fi/oph/vkt/util/ExaminerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public static ExaminerContactRequestDTO toContactRequestDTO(final EnrollmentAppo
.id(enrollmentAppointment.getId())
.firstName(enrollmentAppointment.getFirstName())
.lastName(enrollmentAppointment.getLastName())
.email(enrollmentAppointment.getEmail())
.contactDate(enrollmentAppointment.getCreatedAt().toLocalDate())
.build();
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/packages/vkt/public/i18n/fi-FI/examiner.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"actions": "Toiminnot",
"contactRequest": "Yhteydenottopyyntö",
"contactFields": "Yhteystiedot",
"contactDate": "Yhteydenottopäivä",
"lastName": "Sukunimi",
"firstName": "Etunimi",
"requesterName": "Lähettäjän nimi",
"email": "Sähköpostiosoite",
"examination": "Tutkinto",
"phoneNumber": "Puhelinnumero",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TableCell, TableHead, TableRow } from '@mui/material';
import { useParams } from 'react-router';
import { CustomButtonLink, CustomTable, Text } from 'shared/components';
import { Color, Variant } from 'shared/enums';
import { DateUtils } from 'shared/utils';

import { useExaminerTranslation } from 'configs/i18n';
import { useAppSelector } from 'configs/redux';
Expand All @@ -18,8 +19,9 @@ const ExaminerExamEventListingHeader = () => {
return (
<TableHead className="heading-text">
<TableRow>
<TableCell>{t('firstName')}</TableCell>
<TableCell>{t('lastName')}</TableCell>
<TableCell>{t('requesterName')}</TableCell>
<TableCell>{t('email')}</TableCell>
<TableCell>{t('contactDate')}</TableCell>
<TableCell>{t('actions')}</TableCell>
</TableRow>
</TableHead>
Expand All @@ -40,10 +42,13 @@ const ExaminerContactRequestListingRow = ({
return (
<TableRow>
<TableCell>
<Text>{contactRequest.firstName}</Text>
<Text>{`${contactRequest.firstName} ${contactRequest.lastName}`}</Text>
</TableCell>
<TableCell>
<Text>{contactRequest.lastName}</Text>
<Text>{contactRequest.email}</Text>
</TableCell>
<TableCell>
<Text>{DateUtils.formatOptionalDate(contactRequest.contactDate)}</Text>
</TableCell>
<TableCell>
<CustomButtonLink
Expand Down
11 changes: 10 additions & 1 deletion frontend/packages/vkt/src/interfaces/examinerDetails.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Dayjs } from 'dayjs';
import { APIResponseStatus } from 'shared/enums';
import { WithId } from 'shared/interfaces';

Expand All @@ -23,6 +24,13 @@ export interface ContactRequest extends WithId {
id: number;
firstName: string;
lastName: string;
email: string;
contactDate: Dayjs;
}

export interface ContactRequestResponse
extends Omit<ContactRequest, 'contactDate'> {
contactDate: string;
}

export interface ExaminerDetails extends WithId {
Expand All @@ -40,8 +48,9 @@ export interface ExaminerDetails extends WithId {
}

export interface ExaminerDetailsResponse
extends Omit<ExaminerDetails, 'examEvents'> {
extends Omit<ExaminerDetails, 'examEvents' | 'contactRequests'> {
examEvents: Array<ExaminerExamEventResponse>;
contactRequests: Array<ContactRequestResponse>;
}

export type ExaminerDetailsInit = Pick<
Expand Down
14 changes: 14 additions & 0 deletions frontend/packages/vkt/src/utils/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
ClerkListExamEventResponse,
} from 'interfaces/clerkListExamEvent';
import {
ContactRequest,
ContactRequestResponse,
ExaminerDetails,
ExaminerDetailsResponse,
} from 'interfaces/examinerDetails';
Expand Down Expand Up @@ -347,6 +349,15 @@ export class SerializationUtils {
};
}

static deserializeContactRequest(
contactRequest: ContactRequestResponse,
): ContactRequest {
return {
...contactRequest,
contactDate: dayjs(contactRequest.contactDate),
};
}

static deserializeExaminerDetails(
examinerDetails: ExaminerDetailsResponse,
): ExaminerDetails {
Expand All @@ -355,6 +366,9 @@ export class SerializationUtils {
examEvents: examinerDetails.examEvents.map(
SerializationUtils.deserializeExaminerExamEvent,
),
contactRequests: examinerDetails.contactRequests.map(
SerializationUtils.deserializeContactRequest,
),
};
}
}

0 comments on commit 61c2548

Please sign in to comment.