Skip to content

Commit

Permalink
fix:application form use detail
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar committed Dec 1, 2024
1 parent 8128c58 commit ece218c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/screens/application/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ interface UserData {
}

const myApplicationData: ApplicationField[] = [
{ id: 1, label: "Full Name", value: "first_name" },
{ id: 2, label: "Last Name", value: "last_name" },
{ id: 1, label: "Full Name", value: "firstName" },
{ id: 2, label: "Last Name", value: "lastName" },
{ id: 3, label: "Gender", value: "gender" },
{ id: 4, label: "Age", value: "age" },
{ id: 5, label: "Samagra Id", value: "samagra_id" },
// { id: 5, label: "Samagra Id", value: "samagra_id" },
{ id: 6, label: "Class", value: "class" },
{ id: 7, label: "Adhaar Card", value: "aadhaar" },
{ id: 8, label: "Marks", value: "previous_year_marks" },
Expand Down Expand Up @@ -85,7 +85,16 @@ const Preview: React.FC = () => {

const getFieldDisplayValue = (fieldValue: string) => {
const value = userData?.[fieldValue];
if (value !== undefined && typeof value === "number") {
if (fieldValue === "age" && userData?.["aadhaar"]) {
const data = JSON.parse(decodeFromBase64(userData?.["aadhaar"]) ?? "");
const dob = data?.["KycRes"]?.["UidData"]?.["Poi"]?.["@dob"];
const [day, month, year] = dob.split("-"); // Split the string
const formattedDate = `${year}-${month}-${day}`;
const age = dob
? new Date().getFullYear() - new Date(formattedDate).getFullYear()
: "--";
return age ? age.toString() : "--";
} else if (value !== undefined && typeof value === "number") {
return value.toString();
}
return value ? (value as string) : "__";
Expand Down Expand Up @@ -159,3 +168,7 @@ const Preview: React.FC = () => {
};

export default Preview;

function decodeFromBase64(base64: any): any {
return decodeURIComponent(escape(atob(base64)));
}

0 comments on commit ece218c

Please sign in to comment.