department-of-veterans-affairs/vets-website

View on GitHub
src/applications/ivc-champva/10-7959C/chapters/formSignature.js

Summary

Maintainability
A
0 mins
Test Coverage
import {
  titleUI,
  radioUI,
  radioSchema,
} from 'platform/forms-system/src/js/web-component-patterns';

export const formSignatureSchema = {
  uiSchema: {
    ...titleUI('Signer information'),
    certifierRole: {
      ...radioUI({
        updateUiSchema: formData => {
          const labels = {
            applicant: `I'm ${
              formData?.applicantName?.first
            } and I'm signing for myself`,
            other: `I'm a parent, spouse, or legal representative signing on behalf of ${
              formData?.applicantName?.first
            }`,
          };

          return {
            'ui:title': `Who’s signing this form for ${
              formData?.applicantName?.first
            }?`,
            'ui:options': {
              labels,
            },
          };
        },
        required: () => true,
        labels: {
          applicant: 'The beneficiary',
          other: 'A representative on behalf of the beneficiary',
        },
      }),
    },
  },
  schema: {
    type: 'object',
    required: ['certifierRole'],
    properties: {
      certifierRole: radioSchema(['applicant', 'other']),
    },
  },
};