Skip to content

Commit

Permalink
Rename N/A to No items selected for several VSR fields
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminJohnson2204 committed Apr 18, 2024
1 parent 8970540 commit adef760
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { FieldDetail } from "@/components/VSRIndividual/FieldDetails/FieldDetail
export interface ListDetailProps {
title: string;
values: string[];
isEmpty: boolean;
}

/**
* A component that displays a list of values separated by commas on the VSR individual page.
*/
export function ListDetail({ title, values }: ListDetailProps) {
export function ListDetail({ title, values, isEmpty }: ListDetailProps) {
const list = (
<div className={styles.list}>
{values.map((value, index) => (
Expand All @@ -20,7 +21,7 @@ export function ListDetail({ title, values }: ListDetailProps) {
))}
</div>
);
const noList = <div className={styles.noList}>N/A</div>;
const noList = <div className={styles.noList}>{values[0]}</div>;

return <FieldDetail title={title}>{values.includes("N/A") ? noList : list}</FieldDetail>;
return <FieldDetail title={title}>{isEmpty ? noList : list}</FieldDetail>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ export interface SingleDetailProps {
value: string | number | number[] | ReactNode;
valueFontSize?: string | number;
className?: string;
isEmpty?: boolean;
}

/**
* A component for a single (non-list) field on the VSR individual page.
*/
export function SingleDetail({ title, value, valueFontSize, className }: SingleDetailProps) {
export function SingleDetail({
title,
value,
valueFontSize,
className,
isEmpty,
}: SingleDetailProps) {
const valueStyle = {
fontSize: valueFontSize, // Use the passed font size or default to CSS class
};
Expand All @@ -29,13 +36,13 @@ export function SingleDetail({ title, value, valueFontSize, className }: SingleD
</div>
);

const noValue = <div className={styles.noValue}>N/A</div>;
const noValue = <div className={styles.noValue}>{value}</div>;

return (
<FieldDetail className={className} title={title}>
{typeof value === "string" && value.includes("@")
? email
: typeof value === "string" && value.includes("N/A")
: typeof value === "string" && isEmpty
? noValue
: basic}
</FieldDetail>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export const MilitaryBackground = ({ vsr, isEditing, formProps }: MilitaryBackgr
) : (
<ListDetail
title="Branch"
values={vsr.branch && vsr.branch.length > 0 ? vsr.branch : ["N/A"]}
values={vsr.branch && vsr.branch.length > 0 ? vsr.branch : ["No branch selected"]}
isEmpty={!(vsr.branch && vsr.branch.length > 0)}
/>
)}
</div>
Expand All @@ -70,7 +71,10 @@ export const MilitaryBackground = ({ vsr, isEditing, formProps }: MilitaryBackgr
) : (
<ListDetail
title="Conflicts"
values={vsr.conflicts && vsr.conflicts.length > 0 ? vsr.conflicts : ["N/A"]}
values={
vsr.conflicts && vsr.conflicts.length > 0 ? vsr.conflicts : ["No conflicts selected"]
}
isEmpty={!(vsr.conflicts && vsr.conflicts.length > 0)}
/>
)}
</div>
Expand All @@ -89,8 +93,9 @@ export const MilitaryBackground = ({ vsr, isEditing, formProps }: MilitaryBackgr
values={
vsr.dischargeStatus && vsr.dischargeStatus.length > 0
? [vsr.dischargeStatus]
: ["N/A"]
: ["No discharge status"]
}
isEmpty={!(vsr.dischargeStatus && vsr.dischargeStatus.length > 0)}
/>
)}
</div>
Expand All @@ -102,7 +107,11 @@ export const MilitaryBackground = ({ vsr, isEditing, formProps }: MilitaryBackgr
formProps={formProps}
/>
) : (
<ListDetail title="Service Connected" values={[vsr.serviceConnected ? "Yes" : "No"]} />
<ListDetail
title="Service Connected"
values={[vsr.serviceConnected ? "Yes" : "No"]}
isEmpty={false}
/>
)}
</div>
<div className={styles.row}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const PersonalInformation = ({ vsr, isEditing, formProps }: PersonalInfor
allowMultiple={false}
/>
) : (
<ListDetail title="Marital Status" values={[vsr.maritalStatus]} />
<ListDetail title="Marital Status" values={[vsr.maritalStatus]} isEmpty={false} />
)}
</div>
{formProps.watch().maritalStatus === "Married" ? (
Expand All @@ -142,7 +142,7 @@ export const PersonalInformation = ({ vsr, isEditing, formProps }: PersonalInfor
) : (
<SingleDetail
title="Spouse's Name"
value={vsr.spouseName && vsr.spouseName.length > 0 ? vsr.spouseName : "N/A"}
value={vsr.spouseName && vsr.spouseName.length > 0 ? vsr.spouseName : "No spouse"}
/>
)}
</div>
Expand All @@ -158,8 +158,11 @@ export const PersonalInformation = ({ vsr, isEditing, formProps }: PersonalInfor
<SingleDetail
title="Age(s)"
value={
vsr.agesOfBoys && vsr.agesOfBoys.length > 0 ? vsr.agesOfBoys.join(", ") : "N/A"
vsr.agesOfBoys && vsr.agesOfBoys.length > 0
? vsr.agesOfBoys.join(", ")
: "No male children"
}
isEmpty={!(vsr.agesOfBoys && vsr.agesOfBoys.length > 0)}
/>
</>
)}
Expand All @@ -175,8 +178,11 @@ export const PersonalInformation = ({ vsr, isEditing, formProps }: PersonalInfor
<SingleDetail
title="Age(s)"
value={
vsr.agesOfGirls && vsr.agesOfGirls.length > 0 ? vsr.agesOfGirls.join(", ") : "N/A"
vsr.agesOfGirls && vsr.agesOfGirls.length > 0
? vsr.agesOfGirls.join(", ")
: "No female children"
}
isEmpty={!(vsr.agesOfGirls && vsr.agesOfGirls.length > 0)}
/>
</>
)}
Expand All @@ -194,7 +200,10 @@ export const PersonalInformation = ({ vsr, isEditing, formProps }: PersonalInfor
) : (
<ListDetail
title="Ethnicity"
values={vsr.ethnicity && vsr.ethnicity.length > 0 ? vsr.ethnicity : ["N/A"]}
values={
vsr.ethnicity && vsr.ethnicity.length > 0 ? vsr.ethnicity : ["No items selected"]
}
isEmpty={!(vsr.ethnicity && vsr.ethnicity.length > 0)}
/>
)}
</div>
Expand All @@ -208,7 +217,7 @@ export const PersonalInformation = ({ vsr, isEditing, formProps }: PersonalInfor
allowMultiple={false}
/>
) : (
<ListDetail title="Employment Status" values={[vsr.employmentStatus]} />
<ListDetail title="Employment Status" values={[vsr.employmentStatus]} isEmpty={false} />
)}
</div>
<div className={styles.row}>
Expand All @@ -221,7 +230,7 @@ export const PersonalInformation = ({ vsr, isEditing, formProps }: PersonalInfor
allowMultiple={false}
/>
) : (
<ListDetail title="Income Level" values={[vsr.incomeLevel]} />
<ListDetail title="Income Level" values={[vsr.incomeLevel]} isEmpty={false} />
)}
</div>
<div className={styles.row}>
Expand All @@ -234,7 +243,7 @@ export const PersonalInformation = ({ vsr, isEditing, formProps }: PersonalInfor
allowMultiple={false}
/>
) : (
<ListDetail title="Size of Home" values={[vsr.sizeOfHome]} />
<ListDetail title="Size of Home" values={[vsr.sizeOfHome]} isEmpty={false} />
)}
</div>
</VSRIndividualAccordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ export const RequestedFurnishings = ({
: ""
}`,
)
: ["N/A"]
: ["No items selected"]
}
isEmpty={!(selectedItemsForCategory && selectedItemsForCategory.length > 0)}
/>
</div>
);
Expand All @@ -141,8 +142,11 @@ export const RequestedFurnishings = ({
<SingleDetail
title="Additional Items:"
value={
vsr.additionalItems && vsr.additionalItems.length > 0 ? vsr.additionalItems : "n/a"
vsr.additionalItems && vsr.additionalItems.length > 0
? vsr.additionalItems
: "No items selected"
}
isEmpty={!(vsr.additionalItems && vsr.additionalItems.length > 0)}
/>
)}
</div>
Expand Down

0 comments on commit adef760

Please sign in to comment.