Merge pull request #195 from EETagent/candidate_preview_w_link_info

personalIdNumber & relatedApplications in list_applications
This commit is contained in:
Vojtěch Jungmann 2023-02-05 19:07:12 +01:00 committed by GitHub
commit 338db8f2eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 14 deletions

View file

@ -6,7 +6,7 @@ const PAGE_SIZE: u64 = 20;
#[derive(FromQueryResult, Clone)]
pub struct ApplicationCandidateJoin {
pub application_id: i32,
// pub personal_id_number: String,
pub personal_id_number: String,
pub candidate_id: i32,
pub name: Option<String>,
pub surname: Option<String>,

View file

@ -8,8 +8,9 @@ use super::candidate_details::EncryptedString;
#[serde(rename_all = "camelCase")]
pub struct ApplicationResponse {
pub application_id: i32,
// pub personal_id_number: String,
pub candidate_id: i32,
pub related_applications: Vec<i32>,
pub personal_id_number: String,
pub name: String,
pub surname: String,
pub email: String,
@ -20,8 +21,10 @@ pub struct ApplicationResponse {
impl ApplicationResponse {
pub async fn from_encrypted(
private_key: &String,
c: ApplicationCandidateJoin
c: ApplicationCandidateJoin,
related_applications: Vec<i32>,
) -> Result<Self, ServiceError> {
let personal_id_number = EncryptedString::from(c.personal_id_number.to_owned()).decrypt(private_key).await?;
let name = EncryptedString::decrypt_option(&EncryptedString::try_from(&c.name).ok(), private_key).await?;
let surname = EncryptedString::decrypt_option(&EncryptedString::try_from(&c.surname).ok(), private_key).await?;
let email = EncryptedString::decrypt_option(&EncryptedString::try_from(&c.email).ok(), private_key).await?;
@ -29,11 +32,13 @@ impl ApplicationResponse {
Ok(
Self {
application_id: c.application_id,
candidate_id: c.candidate_id,
related_applications,
personal_id_number,
name: name.unwrap_or_default(),
surname: surname.unwrap_or_default(),
email: email.unwrap_or_default(),
telephone: telephone.unwrap_or_default(),
candidate_id: c.candidate_id,
field_of_study: c.field_of_study,
}
)

View file

@ -267,7 +267,6 @@ impl ApplicationService {
db: &DbConn,
field_of_study: Option<String>,
page: Option<u64>,
) -> Result<Vec<ApplicationResponse>, ServiceError> {
let applications = Query::list_applications(db, field_of_study, page).await?;
@ -275,9 +274,12 @@ impl ApplicationService {
applications
.iter()
.map(|c| async move {
let related_applications = Query::find_applications_by_candidate_id(db, c.candidate_id).await?.iter()
.map(|a| a.id).collect();
ApplicationResponse::from_encrypted(
private_key,
c.to_owned()
c.to_owned(),
related_applications,
).await
})
).await

View file

@ -13,9 +13,9 @@
<thead class="bg-[#f6f4f4] ">
<tr>
<th scope="col"> Ev. č. přihlásky </th>
<th scope="col"> Jméno </th>
<th scope="col"> Příjmení </th>
<th scope="col"> Obor </th>
<th scope="col"> Rodné číslo </th>
<th scope="col"> Link </th>
<th scope="col" />
</tr>
</thead>
@ -29,15 +29,15 @@
href="/admin/candidate/{candidate.applicationId}">{candidate.applicationId}</a
></td
>
<td class="text-gray-900">
{candidate.name}
</td>
<td class="text-gray-900">
{candidate.surname}
</td>
<td class="text-gray-900">
{candidate.fieldOfStudy}
</td>
<td class="text-gray-900">
{candidate.personalIdNumber}
</td>
<td class="text-gray-900">
{candidate.relatedApplications?.filter((a) => a !== candidate.applicationId)}
</td>
<td class="text-sm">
<Delete id={candidate.applicationId} on:delete value="Odstranit" />
</td>

View file

@ -40,8 +40,12 @@ export interface CandidateData {
export interface CandidatePreview {
applicationId?: number;
candidateId?: number;
relatedApplications?: Array<number>;
personalIdNumber?: string;
name?: string;
surname?: string;
email?: string;
fieldOfStudy?: string;
}