Skip to content

Commit

Permalink
2108 conditional back text (#2124)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyarensman authored Apr 29, 2024
1 parent d749a91 commit adc4196
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,27 @@ const StakeholderDetails = ({ onBackClick, isDesktop }) => {
);
}, [onBackClick]);

const organizationContainsCategory = (categoryId) => {
return selectedOrganization.categories.some(
(obj) => obj["id"] === categoryId
);
};

const getCategoryText = () => {
const isMealProgram = organizationContainsCategory(
MEAL_PROGRAM_CATEGORY_ID
);
const isFoodPantry = organizationContainsCategory(FOOD_PANTRY_CATEGORY_ID);

if (isMealProgram && !isFoodPantry) {
return "Meal";
} else if (isFoodPantry && !isMealProgram) {
return "Pantry";
} else {
return "Meal and Pantry";
}
};

return (
<>
<SEO
Expand Down Expand Up @@ -278,7 +299,7 @@ const StakeholderDetails = ({ onBackClick, isDesktop }) => {
position: "relative",
})}
>
Food and Pantry
{getCategoryText()}
</Typography>
</Stack>
<Divider
Expand Down

0 comments on commit adc4196

Please sign in to comment.