Skip to content

Commit

Permalink
Merge pull request #597 from credebl/develop
Browse files Browse the repository at this point in the history
merge: develop to QA
  • Loading branch information
nishad-ayanworks authored Feb 27, 2024
2 parents 008a17d + eab2e7f commit 23e1a56
Show file tree
Hide file tree
Showing 5 changed files with 492 additions and 233 deletions.
2 changes: 2 additions & 0 deletions src/commonComponents/datatable/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface TableData {
}

export interface Data {
handleChange(value: string): void;
inputType: string;
data: string | JSX.Element;
subData?: string;
}
Expand Down
84 changes: 41 additions & 43 deletions src/components/Issuance/EmailIssuance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const EmailIssuance = () => {
const [userData, setUserData] = useState();
const [loading, setLoading] = useState<boolean>(true);
const [credentialOptions, setCredentialOptions] = useState([]);
const [credentialSelected, setCredentialSelected] = useState<string | null>('');
const [credentialSelected, setCredentialSelected] = useState<string | null>(
'',
);
const [openModal, setOpenModal] = useState<boolean>(false);
const [batchName, setBatchName] = useState('');
const [openResetModal, setOpenResetModal] = useState<boolean>(false);
Expand Down Expand Up @@ -99,19 +101,21 @@ const EmailIssuance = () => {

let transformedData = { credentialOffer: [] };
if (existingData && existingData.formData) {
existingData.formData.forEach((entry: { email: any; attributes: any[]; }) => {
const transformedEntry = { emailId: entry.email, attributes: [] };
entry.attributes.forEach((attribute) => {
const transformedAttribute = {
value: String(attribute.value || ''),
name: attribute.name || '',
isRequired: attribute.isRequired,
};
transformedEntry?.attributes?.push(transformedAttribute);
});
existingData?.formData?.forEach(
(entry: { email: any; attributes: any[] }) => {
const transformedEntry = { emailId: entry.email, attributes: [] };
entry.attributes.forEach((attribute) => {
const transformedAttribute = {
value: String(attribute.value || ''),
name: attribute.name || '',
isRequired: attribute.isRequired,
};
transformedEntry?.attributes?.push(transformedAttribute);
});

transformedData.credentialOffer.push(transformedEntry);
});
transformedData.credentialOffer.push(transformedEntry);
},
);
transformedData.credentialDefinitionId = credentialSelected;
const transformedJson = JSON.stringify(transformedData, null, 2);
const response = await issueOobEmailCredential(transformedJson);
Expand Down Expand Up @@ -148,17 +152,17 @@ const EmailIssuance = () => {
};

useEffect(() => {
const initFormData = {
email: '',
attributes: attributes?.map((item:IAttributes) => {
return {
...item,
value: '',
name: item?.attributeName,
isRequired: item?.isRequired,
};
}),
};
const initFormData = {
email: '',
attributes: attributes?.map((item: IAttributes) => {
return {
...item,
value: '',
name: item?.attributeName,
isRequired: item?.isRequired,
};
}),
};

setFormData({ formData: [initFormData] });
}, [attributes]);
Expand Down Expand Up @@ -563,17 +567,17 @@ const EmailIssuance = () => {
</span>
)}
</label>
<Field
type={
item.schemaDataType
}
placeholder={
item.name
}
name={`formData[${index}].attributes.${attIndex}.value`}
className="w-8/12 bg-gray-50 border border-gray-300 text-gray-900 sm:text-md rounded-lg focus:ring-primary-500 focus:border-primary-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
/>
<div className="flex absolute bottom-[-20px] right-0">
<div className="w-8/12">
<Field
type={
item.schemaDataType
}
placeholder={
item.name
}
name={`formData[${index}].attributes.${attIndex}.value`}
className="w-full bg-gray-50 border border-gray-300 text-gray-900 sm:text-md rounded-lg focus:ring-primary-500 focus:border-primary-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
/>
{formikHandlers
?.touched
?.formData &&
Expand Down Expand Up @@ -610,13 +614,7 @@ const EmailIssuance = () => {
attIndex
]
?.value && (
<label
style={{
color:
'red',
}}
className="text-sm"
>
<label className="text-xs text-red-500 absolute">
{
formikHandlers
?.errors
Expand Down Expand Up @@ -648,7 +646,7 @@ const EmailIssuance = () => {
arrayHelpers.push({
email: '',
attributes: attributes?.map(
(item:IAttributes) => {
(item: IAttributes) => {
return {
attributeName:
item.attributeName,
Expand Down
31 changes: 15 additions & 16 deletions src/components/Issuance/Issuance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ const IssueCred = () => {
),
});


const getSchemaDetails = async (): Promise<DataTypeAttributes[] | null> => {
const schemaAttributes = await getFromLocalStorage(storageKeys.SCHEMA_ATTR);
const parsedSchemaAttributes = JSON.parse(schemaAttributes) || [];
Expand Down Expand Up @@ -190,7 +189,7 @@ const IssueCred = () => {
<SummaryCard
schemaId={schemaDetails.schemaId}
schemaName={schemaDetails.schemaName}
version={schemaDetails.schemaName}
version={schemaDetails.version}
credDefId={schemaDetails.credDefId}
hideCredDefId={false}
/>
Expand Down Expand Up @@ -244,7 +243,7 @@ const IssueCred = () => {
<div key={attr.attributeName}>
<div
key={attr?.attributeName}
className="flex relative"
className="flex"
>
<label
htmlFor={`attributes.${index}.value`}
Expand All @@ -260,23 +259,23 @@ const IssueCred = () => {
:
</div>
</label>
<Field
type={
attr?.schemaDataType === 'date'
? 'date'
: attr?.schemaDataType
}
id={`attributes.${index}.value`}
name={`attributes.${index}.value`}
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500 w-3/5"
/>
<div className="absolute bottom-[-20px] right-0">
<div className='w-3/5'>
<Field
type={
attr?.schemaDataType === 'date'
? 'date'
: attr?.schemaDataType
}
id={`attributes.${index}.value`}
name={`attributes.${index}.value`}
className="bg-gray-50 relative border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
/>
{errors?.attributes &&
errors?.attributes[index] &&
touched?.attributes &&
touched?.attributes[index] &&
errors?.attributes[index]?.value && (
<div className="text-red-500 text-xs p-1">
<div className="text-red-500 absolute text-xs word-break-word">
{errors?.attributes[index]?.value}
</div>
)}
Expand Down Expand Up @@ -304,7 +303,7 @@ const IssueCred = () => {
type="submit"
disabled={!isValid || issuanceLoader}
isProcessing={issuanceLoader}
className='text-base text-center text-white bg-primary-700 hover:!bg-primary-800 rounded-lg hover:bg-accent-00 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800"'
className='text-base text-center text-white bg-primary-700 hover:!bg-primary-800 rounded-lg hover:bg-accent-00 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800'
>
<div className="pr-3">
<svg
Expand Down
Loading

0 comments on commit 23e1a56

Please sign in to comment.