Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance credential info and credentials fields in history #48

Open
wants to merge 4 commits into
base: funke
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 55 additions & 5 deletions src/components/Credentials/CredentialInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useEffect, useState } from 'react';
import { BiSolidCategoryAlt, BiSolidUserCircle } from 'react-icons/bi';
import { AiFillCalendar } from 'react-icons/ai';
import { RiPassExpiredFill, RiPassValidFill } from 'react-icons/ri';
import { MdTitle, MdGrade, MdOutlineNumbers, MdFlag, MdLocalPolice } from 'react-icons/md';
import { TbRating18Plus } from "react-icons/tb";
import { MdTitle, MdGrade, MdOutlineNumbers, MdFlag, MdLocalPolice, MdHome } from 'react-icons/md';
import { TbRating12Plus, TbRating14Plus, TbRating16Plus, TbRating18Plus, TbRating21Plus, TbCirclePlus } from "react-icons/tb";
import { GiLevelEndFlag } from 'react-icons/gi';
import { formatDate } from '../../functions/DateFormat';
import { parseCredential } from '../../functions/parseCredential';
Expand All @@ -18,8 +18,18 @@ const getFieldIcon = (fieldName) => {
return <RiPassValidFill size={25} className="inline mr-1" />;
case 'dateOfBirth':
return <AiFillCalendar size={25} className="inline mr-1" />;
case 'over12':
return <TbRating12Plus size={25} className="inline mr-1" />;
case 'over14':
return <TbRating14Plus size={25} className="inline mr-1" />;
case 'over16':
return <TbRating16Plus size={25} className="inline mr-1" />;
case 'over18':
return <TbRating18Plus size={25} className="inline mr-1" />;
case 'over21':
return <TbRating21Plus size={25} className="inline mr-1" />;
case 'over':
return <TbCirclePlus size={25} className="inline mr-1" />;
case 'id':
return <MdOutlineNumbers size={25} className="inline mr-1" />;
case 'familyName':
Expand All @@ -35,6 +45,8 @@ const getFieldIcon = (fieldName) => {
return <MdFlag size={25} className="inline mr-1" />;
case 'issuingCountry':
return <MdLocalPolice size={25} className="inline mr-1" />;
case 'address':
return <MdHome size={25} className="inline mr-1" />;
default:
return null;
}
Expand All @@ -61,7 +73,7 @@ const renderRow = (fieldName, label, fieldValue) => {
}
};

const CredentialInfo = ({ credential, mainClassName = "text-xs sm:text-sm md:text-base pt-5 pr-2 w-full" }) => {
const CredentialInfo = ({ credential, mainClassName = "text-xs sm:text-sm md:text-base pt-5 pr-2 w-full", displayAgeFields = 'false', displayExtraFields = 'false'}) => {

const [parsedCredential, setParsedCredential] = useState(null);

Expand All @@ -87,17 +99,55 @@ const CredentialInfo = ({ credential, mainClassName = "text-xs sm:text-sm md:tex
{renderRow('familyName', 'Family Name', parsedCredential?.familyName)}
{renderRow('familyName', 'Family Name', parsedCredential?.family_name)}
{renderRow('familyName', 'Given Name', parsedCredential?.given_name)}
{renderRow('familyName', 'Birth Family Name', parsedCredential?.birth_family_name)}
{renderRow('familyName', 'Birth Family Name', parsedCredential?.family_name_birth)}
{parsedCredential?.nationalities && renderRow('placeOfBirth', 'Nationality', parsedCredential?.nationalities[0])}
{renderRow('placeOfBirth', 'Nationality', parsedCredential?.nationality?.value)}
{renderRow('placeOfBirth', 'Nationality (Country)', parsedCredential?.nationality?.countryName)}
{renderRow('placeOfBirth', 'Place of Birth', parsedCredential?.place_of_birth?.locality)}
{renderRow('placeOfBirth', 'Place of Birth', parsedCredential?.birth_place)}
{renderRow('issuingCountry', 'Issuing Country', parsedCredential?.issuing_country)}
{renderRow('issuingCountry', 'Issuing Authority', parsedCredential?.issuing_authority)}
{renderRow('issuingCountry', 'Issuing Company', parsedCredential?.issuing_company)}
{renderRow('firstName', 'First Name', parsedCredential?.firstName)}
{renderRow('id', 'Personal ID', parsedCredential?.personalIdentifier)}
{renderRow('dateOfBirth', 'Birthday', parsedCredential?.dateOfBirth)}
{renderRow('dateOfBirth', 'Birthday', parsedCredential?.birthdate)}
{renderRow('dateOfBirth', 'Birthday', parsedCredential?.birth_date)}
{renderRow('over18', 'Age Over 18', parsedCredential?.age_equal_or_over ? parsedCredential?.age_equal_or_over['18'] : null)}
{renderRow('over18', 'Age Over 18', parsedCredential?.age_over_18)}

{displayAgeFields === 'true' && (
<>
{renderRow('over12', 'Age Over 12', parsedCredential?.age_equal_or_over ? parsedCredential?.age_equal_or_over['12'] : null)}
{renderRow('over14', 'Age Over 14', parsedCredential?.age_equal_or_over ? parsedCredential?.age_equal_or_over['14'] : null)}
{renderRow('over16', 'Age Over 16', parsedCredential?.age_equal_or_over ? parsedCredential?.age_equal_or_over['16'] : null)}
{renderRow('over18', 'Age Over 18', parsedCredential?.age_equal_or_over ? parsedCredential?.age_equal_or_over['18'] : null)}
{renderRow('over21', 'Age Over 21', parsedCredential?.age_equal_or_over ? parsedCredential?.age_equal_or_over['21'] : null)}

{renderRow('over12', 'Age Over 12', parsedCredential?.age_over_12)}
{renderRow('over14', 'Age Over 14', parsedCredential?.age_over_14)}
{renderRow('over16', 'Age Over 16', parsedCredential?.age_over_16)}
{renderRow('over18', 'Age Over 18', parsedCredential?.age_over_18)}
{renderRow('over21', 'Age Over 21', parsedCredential?.age_over_21)}
{renderRow('over', 'Age Over 65', parsedCredential?.age_over_65)}

{renderRow('dateOfBirth', 'Birthday (Year)', parsedCredential?.age_birth_year)}
{renderRow('dateOfBirth', 'Age in years', parsedCredential?.age_in_years)}

</>
)}
{displayExtraFields === 'true' && (
<>
{renderRow('address', 'Resident Country', parsedCredential?.resident_country)}
{renderRow('address', 'Resident City', parsedCredential?.resident_city)}
{renderRow('address', 'Resident Postal Code', parsedCredential?.resident_postal_code)}
{renderRow('address', 'Resident Street', parsedCredential?.resident_street)}

{renderRow('address', 'Address (City)', parsedCredential?.address?.locality)}
{renderRow('address', 'Address (Country)', parsedCredential?.address?.country)}
{renderRow('address', 'Address (Postal Code)', parsedCredential?.address?.postal_code)}
{renderRow('address', 'Address (Street)', parsedCredential?.address?.street_address)}
</>
)}
</>
)}
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Popups/SelectCredentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
additionalClassName='text-xs w-full'
/>
<div
className={`transition-all ease-in-out duration-1000 overflow-hidden shadow-md rounded-lg dark:bg-gray-700 ${credentialDisplay[vcEntity.credentialIdentifier] ? 'max-h-[500px] opacity-100' : 'max-h-0 opacity-0'}`}
className={`transition-all ease-in-out duration-1000 overflow-hidden shadow-md rounded-lg dark:bg-gray-700 ${credentialDisplay[vcEntity.credentialIdentifier] ? 'max-h-[1000px] opacity-100' : 'max-h-0 opacity-0'}`}
>
<CredentialInfo credential={{ ...vcEntity }} mainClassName={"text-xs w-full"} />
<CredentialInfo displayAgeFields='false' displayExtraFields='true' credential={{ ...vcEntity }} mainClassName={"text-xs w-full"} />
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/History/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const History = () => {
<div className='h-[30vh]'>

<div className={`transition-all ease-in-out duration-500 ${(currentSlide === index + 1) ? 'max-h-[30vh] overflow-y-auto rounded-md custom-scrollbar my-2 bg-gray-800" opacity-100' : 'max-h-0 opacity-0'}`}>
<CredentialInfo credential={vcEntity} />
<CredentialInfo credential={vcEntity} displayAgeFields='true' displayExtraFields='true'/>
</div>
</div>

Expand Down
Loading