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

Hardcoded a lot in getDriverLicenseSharingRenderData #17

Open
tshemsedinov opened this issue Mar 16, 2024 · 0 comments
Open

Hardcoded a lot in getDriverLicenseSharingRenderData #17

tshemsedinov opened this issue Mar 16, 2024 · 0 comments

Comments

@tshemsedinov
Copy link

tshemsedinov commented Mar 16, 2024

  1. Multiple code duplication, use intermediate variables to reduce code
  2. All text messages should use internationalization as in other part of this code, but you have no access to them from here, that's due to bad code structure, use injection of pass it somehow
  3. magic numbers detected
    private static getDriverLicenseSharingRenderData(
    document: DriverLicense,
    requester: string,
    requestDateTime: string,
    requestIdentifier: string,
    ): GenericData {
    const { lastNameEN, firstNameEN, lastNameUA, firstNameUA, middleNameUA, docNumber, photo, eng, ua } = document
    return {
    documentTitle: 'Driver License',
    blocks: [
    {
    logoBlock: {
    header: 'Driving Licence',
    title: ApplicationUtils.getDocumentName(DocumentType.DriverLicense),
    subtitle: 'Ukraine • Україна',
    },
    marginBottom: 16,
    },
    { hasSeparator: true, marginBottom: 24 },
    {
    identityBlock: {
    lastName: lastNameEN,
    firstName: firstNameEN,
    fullName: ApplicationUtils.getFullName(lastNameUA, firstNameUA, middleNameUA),
    documentNumber: docNumber,
    photo,
    },
    marginBottom: 0,
    },
    { hasSeparator: true, marginBottom: 16 },
    {
    textBlock: [
    `The digital document copy requested on ${requestDateTime}`,
    `Request initiator: ${requester}`,
    `Request ID: ${requestIdentifier}`,
    ],
    },
    {
    tableBlock: [
    [
    RowType.ThreeColumns,
    { primaryText: eng?.lastName.code },
    { primaryText: eng?.lastName.name, secondaryText: ua?.lastName.name },
    { primaryText: eng?.lastName.value, secondaryText: ua?.lastName.value },
    ],
    [
    RowType.ThreeColumns,
    { primaryText: eng?.firstName.code },
    { primaryText: eng?.firstName.name, secondaryText: ua?.firstName.name },
    { primaryText: eng?.firstName.value, secondaryText: ua?.firstName.value },
    ],
    [
    RowType.ThreeColumns,
    { primaryText: eng?.birth.code },
    { primaryText: eng?.birth.name, secondaryText: ua?.birth.name },
    { primaryText: eng?.birth.value.split('\n')[0], secondaryText: ua?.birth.value.split('\n')[1] },
    ],
    [
    RowType.ThreeColumns,
    { primaryText: eng?.issueDate.code },
    { primaryText: eng?.issueDate.name, secondaryText: ua?.issueDate.name },
    { primaryText: eng?.issueDate.value },
    ],
    [
    RowType.ThreeColumns,
    { primaryText: eng?.expiryDate.code },
    { primaryText: eng?.expiryDate.name, secondaryText: ua?.expiryDate.name },
    { primaryText: eng?.expiryDate.value },
    ],
    [
    RowType.ThreeColumns,
    { primaryText: eng?.department.code },
    { primaryText: eng?.department.name, secondaryText: ua?.department.name },
    { primaryText: eng?.department.value },
    ],
    [
    RowType.ThreeColumns,
    { primaryText: eng?.identifier.code },
    { primaryText: eng?.identifier.name, secondaryText: ua?.identifier.name },
    { primaryText: eng?.identifier.value },
    ],
    [
    RowType.ThreeColumns,
    { primaryText: eng?.documentNumber.code },
    { primaryText: eng?.documentNumber.name, secondaryText: ua?.documentNumber.name },
    { primaryText: eng?.documentNumber.value },
    ],
    [
    RowType.ThreeColumns,
    { primaryText: eng?.category.code },
    { primaryText: eng?.category.name, secondaryText: ua?.category.name },
    { primaryText: eng?.category.value.split('\n') },
    ],
    [
    RowType.ThreeColumns,
    { primaryText: eng?.categoryOpeningDate.code },
    { primaryText: eng?.categoryOpeningDate.name, secondaryText: ua?.categoryOpeningDate.name },
    { primaryText: eng?.categoryOpeningDate.value.split('\n') },
    ],
    ],
    },
    ],
    }
    }

We have same problems in all functions in this file https://github.com/diia-open-source/be-pkg-utils/blob/main/src/pdfUtils.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant