Skip to content

Commit

Permalink
Finished mijn verify functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed May 23, 2024
1 parent 817519f commit a896ab9
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 15 deletions.
131 changes: 131 additions & 0 deletions myconext-gui/src/components/LinkedAccountSummary.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<script>
import I18n from "i18n-js";
import {dateFromEpoch} from "../utils/date";
import {onMount} from "svelte";
import {institutionName, isStudent, linkedAccountFamilyName, linkedAccountGivenName} from "../utils/services";
import trash from "../icons/verify/bin.svg"
import studentIcon from "../icons/student.svg";
import personalInfo from "../icons/verify/personalInfo.svg";
import {isEmpty} from "../utils/utils";
import ValidatedField from "../verify/ValidatedField.svelte";
export let linkedAccount;
export let preferredAccount = false;
export let deleteLinkedAccount;
let expiresAt = 0;
onMount(() => {
if (linkedAccount.external) {
expiresAt = linkedAccount.expiresAt;
} else {
expiresAt = linkedAccount.expiresAtRole ? linkedAccount.expiresAtRole : (linkedAccount.expiresAtNonValidated || linkedAccount.expiresAt);
}
})
</script>
<style lang="scss">
.linked-account-container {
.linked-account {
display: flex;
div.info {
display: flex;
flex-direction: column;
gap: 6px;
margin-bottom: 15px;
h4 {
color: var(--color-primary-green);
}
span {
color: var(--color-tertiare-grey);
font-size: 14px;
}
}
}
.button-container {
display: flex;
align-items: center;
a {
text-decoration: underline;
}
:global(svg) {
width: 18px;
height: auto;
margin-right: 15px;
}
}
.no-valid-information {
font-style: italic;
margin: 10px 0 25px 0;
}
}
</style>
<div class="linked-account-container">
<div class="linked-account">
<div class="info">
<h4>{I18n.t("profile.from", {name: institutionName(linkedAccount)})}</h4>
<span>{@html I18n.t("profile.receivedOnInfo", {date: dateFromEpoch(linkedAccount.createdAt)})}</span>
<span>{@html I18n.t("profile.validUntilDateInfo", {date: dateFromEpoch(expiresAt)})}</span>
</div>
<!--{#if linkedAccount.logoUrl}-->
<!-- <img src={linkedAccount.logoUrl} alt="logo">-->
<!--{:else if linkedAccount.external}-->
<!-- {@html logo(linkedAccount.issuer.id)}-->
<!--{:else}-->
<!-- {@html notFound}-->
<!--{/if}-->
</div>
<div class="">
{#if linkedAccount.idpScoping !== "idin" && !isEmpty(linkedAccountGivenName(linkedAccount))}
<ValidatedField label={I18n.t("profile.validatedGivenName")}
icon={preferredAccount ? personalInfo : null}
value={linkedAccountGivenName(linkedAccount)}/>
{/if}

{#if !isEmpty(linkedAccountFamilyName(linkedAccount))}
<ValidatedField label={I18n.t("profile.validatedFamilyName")}
icon={preferredAccount ? personalInfo : null}
value={linkedAccountFamilyName(linkedAccount)}/>
{/if}

{#if !isEmpty(linkedAccount.dateOfBirth)}
<ValidatedField label={I18n.t("profile.validatedDayOfBirth")}
icon={preferredAccount ? personalInfo : null}
value={dateFromEpoch(linkedAccount.dateOfBirth)}/>
{/if}

{#if isStudent(linkedAccount)}
<ValidatedField label={I18n.t("profile.atInstitution", {name: institutionName(linkedAccount)})}
icon={preferredAccount ? personalInfo : null}
overrideShieldIcon={studentIcon}
value={I18n.t("profile.studentRole")}/>
{/if}

{#if (linkedAccount.idpScoping === "idin" || isEmpty(linkedAccountGivenName(linkedAccount))) &&
isEmpty(linkedAccount.dateOfBirth) && isEmpty(linkedAccountFamilyName(linkedAccount)) &&
!isStudent(linkedAccount)}
<div class="no-valid-information">{I18n.t("profile.noValidInformation", {name: institutionName(linkedAccount)})}</div>
{/if}

</div>
<div class="button-container">
{@html trash}
<div class="remove">
<a href="/#"
on:click|preventDefault|stopPropagation={deleteLinkedAccount}>
{I18n.t("profile.removeLinkPrefix")}
</a>
<span>{I18n.t("profile.removeLinkPostfix")}</span>
</div>
</div>
</div>

5 changes: 5 additions & 0 deletions myconext-gui/src/components/ValidatedData.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import {user} from "../stores/user";
import {isEmpty} from "../utils/utils";
import {dateFromEpoch} from "../utils/date";
import personalInfo from "../icons/verify/personalInfo.svg";
export let institution = {};
export let replacement = false;
export let preferredAccount = false;
</script>
<style lang="scss">
Expand Down Expand Up @@ -47,14 +49,17 @@

{#if institution.idpScoping !== "idin"}
<ValidatedField label={I18n.t("profile.validatedGivenName")}
icon={preferredAccount ? personalInfo : null}
value={linkedAccountGivenName(institution)}/>
{/if}

<ValidatedField label={I18n.t("profile.validatedFamilyName")}
icon={preferredAccount ? personalInfo : null}
value={linkedAccountFamilyName(institution)}/>

{#if !isEmpty(institution.dateOfBirth)}
<ValidatedField label={I18n.t("profile.validatedDayOfBirth")}
icon={preferredAccount ? personalInfo : null}
value={dateFromEpoch(institution.dateOfBirth)}/>
{/if}
</div>
3 changes: 1 addition & 2 deletions myconext-gui/src/icons/student.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions myconext-gui/src/icons/verify/bin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a896ab9

Please sign in to comment.