diff --git a/client/src/components/FoodSeeker/SearchResults/StakeholderDetails/StakeholderDetails.js b/client/src/components/FoodSeeker/SearchResults/StakeholderDetails/StakeholderDetails.js
index 35191949e..24ef086ac 100644
--- a/client/src/components/FoodSeeker/SearchResults/StakeholderDetails/StakeholderDetails.js
+++ b/client/src/components/FoodSeeker/SearchResults/StakeholderDetails/StakeholderDetails.js
@@ -325,41 +325,43 @@ const StakeholderDetails = ({ onBackClick, isDesktop }) => {
marginTop="8px"
sx={{ gap: "16px" }}
>
- {selectedOrganization.categories.map((category, index) => (
-
- {category.id === FOOD_PANTRY_CATEGORY_ID ? (
-
- ) : category.id === MEAL_PROGRAM_CATEGORY_ID ? (
-
- ) : (
- ""
- )}
-
- c.isForFoodSeeker)
+ .map((category, index) => (
+
- {category.name}
-
-
- ))}
+ {category.id === FOOD_PANTRY_CATEGORY_ID ? (
+
+ ) : category.id === MEAL_PROGRAM_CATEGORY_ID ? (
+
+ ) : (
+ ""
+ )}
+
+
+ {category.name}
+
+
+ ))}
diff --git a/client/src/components/FoodSeeker/SearchResults/StakeholderPreview/StakeholderPreview.js b/client/src/components/FoodSeeker/SearchResults/StakeholderPreview/StakeholderPreview.js
index 8de08a5d2..30a1014a2 100644
--- a/client/src/components/FoodSeeker/SearchResults/StakeholderPreview/StakeholderPreview.js
+++ b/client/src/components/FoodSeeker/SearchResults/StakeholderPreview/StakeholderPreview.js
@@ -202,39 +202,43 @@ const StakeholderPreview = ({ stakeholder, onSelect, isDesktop }) => {
sx={{ gap: "16px" }}
onClick={() => handleSelectOrganization(stakeholder)}
>
- {stakeholder.categories.map((category, index) => (
-
- {category.id === FOOD_PANTRY_CATEGORY_ID ? (
-
- ) : category.id === MEAL_PROGRAM_CATEGORY_ID ? (
-
- ) : (
- ""
- )}
-
- c.isForFoodSeeker)
+ .map((category, index) => (
+
- {category.name}
-
-
- ))}
+ {category.id === FOOD_PANTRY_CATEGORY_ID ? (
+
+ ) : category.id === MEAL_PROGRAM_CATEGORY_ID ? (
+
+ ) : (
+ ""
+ )}
+
+
+ {category.name}
+
+
+ ))}
=> {
const sql = `
- select id, name, display_order, inactive
+ select id, name, display_order, inactive, is_for_food_seeker
from category
order by name
`;
@@ -13,7 +13,7 @@ const selectAll = async (): Promise => {
};
const selectById = async (id: string): Promise => {
- const sql = `select id, name, display_order as displayOrder, inactive
+ const sql = `select id, name, display_order as displayOrder, inactive, is_for_food_seeker
from category where id = $`;
const row: Category = await db.one(sql, { id: Number(id) });
diff --git a/server/app/services/stakeholder-best-service.ts b/server/app/services/stakeholder-best-service.ts
index 0e7f1d57c..9225cfd63 100644
--- a/server/app/services/stakeholder-best-service.ts
+++ b/server/app/services/stakeholder-best-service.ts
@@ -71,7 +71,7 @@ const selectAll = async ({ tenantId }: { tenantId: string }) => {
if (stakeholder_ids.length) {
// Hoover up all the stakeholder categories
// for all of our stakeholder row results.
- const categoriesSql = `select sc.stakeholder_id, c.id, c.name, c.display_order
+ const categoriesSql = `select sc.stakeholder_id, c.id, c.name, c.display_order, c.is_for_food_seeker
from category c
join stakeholder_best_category sc on c.id = sc.category_id
where sc.stakeholder_id in (${stakeholder_ids.join(",")})
@@ -86,7 +86,12 @@ const selectAll = async ({ tenantId }: { tenantId: string }) => {
categories: categories
.filter((cr) => cr.stakeholder_id === row.id)
.map((c) => {
- return { id: c.id, name: c.name, displayOrder: c.display_order };
+ return {
+ id: c.id,
+ name: c.name,
+ displayOrder: c.display_order,
+ isForFoodSeeker: c.is_for_food_seeker,
+ };
}),
});
});
@@ -182,7 +187,7 @@ const search = async ({
if (stakeholder_ids.length) {
// Hoover up all the stakeholder categories
// for all of our stakeholder row results.
- const categoriesSql = `select sc.stakeholder_id, c.id, c.name, c.display_order
+ const categoriesSql = `select sc.stakeholder_id, c.id, c.name, c.display_order, c.is_for_food_seeker
from category c
join stakeholder_best_category sc on c.id = sc.category_id
where sc.stakeholder_id in (${stakeholder_ids.join(",")})
@@ -197,7 +202,12 @@ const search = async ({
categories
.filter((cr) => cr.stakeholder_id === row.id)
.map((c) => {
- return { id: c.id, name: c.name, displayOrder: c.display_order };
+ return {
+ id: c.id,
+ name: c.name,
+ displayOrder: c.display_order,
+ isForFoodSeeker: c.is_for_food_seeker,
+ };
})
),
isVerified: row.is_verified,
@@ -214,7 +224,7 @@ const selectById = async (id: string): Promise => {
array_to_json(s.hours) as hours,
(select array(select row_to_json(category_row)
from (
- select c.id, c.name, c.display_order
+ select c.id, c.name, c.display_order, c.is_for_food_seeker
from category c
join stakeholder_best_category sc on c.id = sc.category_id
where sc.stakeholder_id = s.id
@@ -253,8 +263,36 @@ const selectById = async (id: string): Promise => {
where s.id = ${Number(id)}`;
const row = await db.one(sql);
+ let categories: StakeholderCategory[] = [];
+
+ const rows = await db.manyOrNone(sql);
+ const stakeholder_ids = rows.map((a) => a.id);
+
+ if (stakeholder_ids.length) {
+ // Hoover up all the stakeholder categories
+ // for all of our stakeholder row results.
+ const categoriesSql = `select sc.stakeholder_id, c.id, c.name, c.display_order, c.is_for_food_seeker
+ from category c
+ join stakeholder_best_category sc on c.id = sc.category_id
+ where sc.stakeholder_id = ${row.id}
+ order by c.display_order, c.name`;
+ categories = await db.manyOrNone(categoriesSql);
+ }
+
return {
- ...stakeholderHelpers.rowToStakeholder(row),
+ ...stakeholderHelpers.rowToStakeholder(
+ row,
+ categories
+ .filter((cr) => cr.stakeholder_id === row.id)
+ .map((c) => {
+ return {
+ id: c.id,
+ name: c.name,
+ displayOrder: c.display_order,
+ isForFoodSeeker: c.is_for_food_seeker,
+ };
+ })
+ ),
isVerified: row.is_verified,
distance: row.distance,
};
diff --git a/server/migrations/1713838465175_set-category-is-for-food-seeker-values-1154.js b/server/migrations/1713838465175_set-category-is-for-food-seeker-values-1154.js
new file mode 100644
index 000000000..24ebe8776
--- /dev/null
+++ b/server/migrations/1713838465175_set-category-is-for-food-seeker-values-1154.js
@@ -0,0 +1,12 @@
+/* eslint-disable camelcase */
+
+exports.shorthands = undefined;
+
+exports.up = (pgm) => {
+ pgm.sql(`UPDATE Category SET is_for_food_seeker = false;
+
+ UPDATE Category SET is_for_food_seeker = true
+ WHERE id in (1,9,7,8,10 );`);
+};
+
+exports.down = (pgm) => {};
diff --git a/server/types/category-types.ts b/server/types/category-types.ts
index 0d323d15d..bf0986fca 100644
--- a/server/types/category-types.ts
+++ b/server/types/category-types.ts
@@ -4,4 +4,5 @@ export interface Category {
displayOrder: number;
inactive: boolean;
suggestionStatusId?: number;
+ isForFoodSeeker: boolean;
}
diff --git a/server/types/stakeholder-types.ts b/server/types/stakeholder-types.ts
index b1f8344ea..722f671d2 100644
--- a/server/types/stakeholder-types.ts
+++ b/server/types/stakeholder-types.ts
@@ -43,6 +43,7 @@ export interface StakeholderCategory {
id: number;
name: string;
display_order: number;
+ is_for_food_seeker: boolean;
}
// Interface with common properties for all the full stakeholder types.