From 54be0c30ed0759c39b162c89aa55dd8d4fe1f339 Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Sun, 22 Nov 2026 12:10:12 +0100 Subject: [PATCH 1/7] add example to search placeholder and announce no results with aria-live --- frontend/src/i18n/locales/en/translation.json | 1 + frontend/src/i18n/locales/no/translation.json | 1 + .../pages/explorePlants/ExplorePlantsPage.css | 5 +++++ .../pages/explorePlants/ExplorePlantsPage.tsx | 22 +++++++++++-------- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/frontend/src/i18n/locales/en/translation.json b/frontend/src/i18n/locales/en/translation.json index eab30686..8c42dd71 100644 --- a/frontend/src/i18n/locales/en/translation.json +++ b/frontend/src/i18n/locales/en/translation.json @@ -43,6 +43,7 @@ }, "explorePlantsPage": { "search": "Search for plants", + "searchPlaceholder": "Search for plants, e.g. maple or leaf", "loading": "Loading plants...", "error": "Could not load plants. Please try again later.", "filters": "Filters", diff --git a/frontend/src/i18n/locales/no/translation.json b/frontend/src/i18n/locales/no/translation.json index fb265e30..8cd9a631 100644 --- a/frontend/src/i18n/locales/no/translation.json +++ b/frontend/src/i18n/locales/no/translation.json @@ -43,6 +43,7 @@ }, "explorePlantsPage": { "search": "Søk etter planter", + "searchPlaceholder": "Søk etter planter, f.eks. maple eller leaf", "loading": "Laster planter...", "error": "Kunne ikke hente planter. Prøv igjen senere.", "filters": "Filtre", diff --git a/frontend/src/pages/explorePlants/ExplorePlantsPage.css b/frontend/src/pages/explorePlants/ExplorePlantsPage.css index 3bcc0020..32a81159 100644 --- a/frontend/src/pages/explorePlants/ExplorePlantsPage.css +++ b/frontend/src/pages/explorePlants/ExplorePlantsPage.css @@ -113,6 +113,11 @@ color: var(--text-dark); } +/* "No results found" is centred */ +.explore-results .results-count--empty { + text-align: center; +} + .plant-grid { list-style: none; margin: 0; diff --git a/frontend/src/pages/explorePlants/ExplorePlantsPage.tsx b/frontend/src/pages/explorePlants/ExplorePlantsPage.tsx index 67d1852d..aeaed9e8 100644 --- a/frontend/src/pages/explorePlants/ExplorePlantsPage.tsx +++ b/frontend/src/pages/explorePlants/ExplorePlantsPage.tsx @@ -90,7 +90,7 @@ export default function ExplorePlantsPage() { setSearch(e.target.value)} /> @@ -134,14 +134,18 @@ export default function ExplorePlantsPage() {
{loading &&

{t("explorePlantsPage.loading")}

} {error &&

{t("explorePlantsPage.error")}

} - {!loading && !error && plants.length === 0 && ( -

{t("explorePlantsPage.noResults")}

- )} - {/* aria-live so screen readers hear the new count when search or filters change */} -

- {!loading && !error && totalCount > 0 - ? t("explorePlantsPage.resultsCount", { count: totalCount }) - : ""} + {/* aria-live so screen readers hear the new count, or that nothing was + found, when search or filters change. The element is always there, + since screen readers only announce changes to a region they already know. */} +

+ {loading || error + ? "" + : totalCount > 0 + ? t("explorePlantsPage.resultsCount", { count: totalCount }) + : t("explorePlantsPage.noResults")}

    From ad711105ac98b1f6eb00245f25fdf5e6a96641dd Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Sun, 22 Nov 2026 12:33:55 +0100 Subject: [PATCH 2/7] add match counts per filter value to explorePlants in backend --- backend/src/queryBuilders.ts | 54 ++++++++++++++++++++++++++++++++- backend/src/resolvers.ts | 20 +++++++++++-- backend/src/schema.ts | 19 +++++++++++- backend/src/types.ts | 19 ++++++++++++ backend/tests/server.test.ts | 58 ++++++++++++++++++++++++++++++++++++ 5 files changed, 165 insertions(+), 5 deletions(-) diff --git a/backend/src/queryBuilders.ts b/backend/src/queryBuilders.ts index 39d7b74e..4c84d08e 100644 --- a/backend/src/queryBuilders.ts +++ b/backend/src/queryBuilders.ts @@ -1,5 +1,10 @@ import type { Document, Filter, ObjectId } from "mongodb"; -import type { ExplorePlantsArgs, PlantDoc } from "./types.js"; +import type { + ExplorePlantsArgs, + FilterCounts, + FilterParam, + PlantDoc, +} from "./types.js"; // Helpers for searching, filtering and sorting plants @@ -120,6 +125,53 @@ export const buildExploreFilter = ( return filter; }; +// The values each filter can have. Must match FILTERS in +// frontend/src/pages/explorePlants/ExplorePlantsPage.tsx +export const FILTER_OPTIONS: Record = { + watering: ["minimum", "average", "frequent"], + sunlight: ["full_sun", "part_shade", "filtered_shade"], + careLevel: ["low", "medium", "high"], +}; + +// The name of one count in the $facet result, e.g. "watering:minimum" +const facetKey = (param: string, value: string) => `${param}:${value}`; + +// Stages that count, for every filter value, how many plants the user would get +// by choosing it. The value replaces the current choice in that filter, while the +// search and the other filters stay. Uses buildExploreFilter, so the counts +// always agree with the results. All counts are done in one query. +export const buildFilterCountStages = (args: ExplorePlantsArgs): Document[] => { + const facets: Record = {}; + for (const [param, options] of Object.entries(FILTER_OPTIONS)) { + for (const value of options) { + facets[facetKey(param, value)] = [ + { $match: buildExploreFilter({ ...args, [param]: value }) }, + { $count: "count" }, + ]; + } + } + return [ + // Only the plants matching the search need to be looked at + { $match: buildExploreFilter({ search: args.search }) }, + { $facet: facets }, + ]; +}; + +// Turns the $facet result into the FilterCounts the API returns. +// $count gives an empty list when nothing matches, so that becomes 0. +export const toFilterCounts = ( + facets: Record = {}, +): FilterCounts => { + const counts = {} as FilterCounts; + for (const [param, options] of Object.entries(FILTER_OPTIONS)) { + counts[param as FilterParam] = options.map((value) => ({ + value, + count: facets[facetKey(param, value)]?.[0]?.count ?? 0, + })); + } + return counts; +}; + // Lowercased field value, missing values become "" const lower = (field: string): Document => ({ $toLower: { $ifNull: [field, ""] }, diff --git a/backend/src/resolvers.ts b/backend/src/resolvers.ts index ecdd4101..67ed8d96 100644 --- a/backend/src/resolvers.ts +++ b/backend/src/resolvers.ts @@ -4,13 +4,16 @@ import type { Document, WithId } from "mongodb"; import { db } from "./db.js"; import { buildExploreFilter, + buildFilterCountStages, buildMatchSortStages, buildSortStages, matchScore, PREFERENCE_MATCHERS, + toFilterCounts, } from "./queryBuilders.js"; import type { ExplorePlantsArgs, + ExplorePage, GetPlantsArgs, MyMatchesArgs, Plant, @@ -181,10 +184,10 @@ export const resolvers = { explorePlants: async ( _parent: unknown, args: ExplorePlantsArgs, - ): Promise<{ plants: Plant[]; totalCount: number }> => { + ): Promise => { const filter = buildExploreFilter(args); - const [docs, totalCount] = await Promise.all([ + const [docs, totalCount, [facets]] = await Promise.all([ plants .aggregate>([ { $match: filter }, @@ -194,9 +197,20 @@ export const resolvers = { ]) .toArray(), plants.countDocuments(filter), + // Match counts for the filter values, so the frontend can show them + // and disable the values that would give no plants + plants + .aggregate>( + buildFilterCountStages(args), + ) + .toArray(), ]); - return { plants: docs.map(toPlant), totalCount }; + return { + plants: docs.map(toPlant), + totalCount, + filterCounts: toFilterCounts(facets), + }; }, getUser: async ( diff --git a/backend/src/schema.ts b/backend/src/schema.ts index f6d1f935..87193276 100644 --- a/backend/src/schema.ts +++ b/backend/src/schema.ts @@ -10,7 +10,7 @@ export const typeDefs = ` sort: String limit: Int = 12 offset: Int = 0 - ): PlantPage! + ): ExplorePage! getUser(userId: ID!): User myMatches( userId: ID! @@ -38,6 +38,23 @@ export const typeDefs = ` totalCount: Int! } + type OptionCount { + value: String! + count: Int! + } + + type FilterCounts { + watering: [OptionCount!]! + sunlight: [OptionCount!]! + careLevel: [OptionCount!]! + } + + type ExplorePage { + plants: [Plant!]! + totalCount: Int! + filterCounts: FilterCounts! + } + type Plant{ id: ID! name: String! diff --git a/backend/src/types.ts b/backend/src/types.ts index b0e4f0a8..ffe1d580 100644 --- a/backend/src/types.ts +++ b/backend/src/types.ts @@ -45,6 +45,25 @@ export interface ExplorePlantsArgs { offset?: number | null; } +// The filters on Explore Plants +export type FilterParam = "watering" | "sunlight" | "careLevel"; + +// How many plants a filter value would give, with the current search and other filters +export interface OptionCount { + value: string; + count: number; +} + +export type FilterCounts = Record; + +// What explorePlants returns. A separate type from PlantPage, since +// My Matches also uses PlantPage but has no filters to count. +export interface ExplorePage { + plants: Plant[]; + totalCount: number; + filterCounts: FilterCounts; +} + // The shape of a user document in MongoDB. _id is added by MongoDB. export interface UserDoc { // null means the user has not chosen one, the frontend shows a translated default diff --git a/backend/tests/server.test.ts b/backend/tests/server.test.ts index 5d4b8661..c46e0110 100644 --- a/backend/tests/server.test.ts +++ b/backend/tests/server.test.ts @@ -459,6 +459,64 @@ describe("plants", () => { ])("sorts with %s", async (sort, expected) => { expect((await explore({ sort })).names).toEqual(expected); }); + + const FILTER_COUNTS = ` + query ($search: String, $watering: String) { + explorePlants(search: $search, watering: $watering) { + filterCounts { + watering { value count } + sunlight { value count } + careLevel { value count } + } + } + } + `; + + type Counts = Record; + + // The counts as { watering: { minimum: 2, ... }, ... }, easier to read in the tests + async function filterCounts(variables: Record = {}) { + const result = await execute<{ explorePlants: { filterCounts: Counts } }>( + FILTER_COUNTS, + variables, + ); + expect(result.errors).toBeUndefined(); + return Object.fromEntries( + Object.entries(result.data!.explorePlants.filterCounts).map( + ([param, options]) => [ + param, + Object.fromEntries(options.map((o) => [o.value, o.count])), + ], + ), + ); + } + + it("counts the matches for every filter value", async () => { + expect(await filterCounts()).toEqual({ + watering: { minimum: 2, average: 2, frequent: 1 }, + sunlight: { full_sun: 2, part_shade: 2, filtered_shade: 1 }, + careLevel: { low: 1, medium: 3, high: 1 }, + }); + }); + + it("counts with the search and the other filters, but not the filter's own choice", async () => { + const counts = await filterCounts({ watering: "average" }); + // Choosing another watering value replaces "average", so these are unchanged + expect(counts.watering).toEqual({ minimum: 2, average: 2, frequent: 1 }); + // Only Daisy and Fern (giant) have average watering + expect(counts.sunlight).toEqual({ + full_sun: 0, + part_shade: 1, + filtered_shade: 1, + }); + expect(counts.careLevel).toEqual({ low: 0, medium: 2, high: 0 }); + + expect((await filterCounts({ search: "fern" })).watering).toEqual({ + minimum: 0, + average: 1, + frequent: 0, + }); + }); }); describe("users", () => { From 36d7fa74a5a91785881c918a2a881e03c36bcdc7 Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Sun, 22 Nov 2026 12:55:23 +0100 Subject: [PATCH 3/7] show match counts in filters, disable empty values and keep results while loading --- .../components/filterSelect/FilterSelect.tsx | 15 +++- frontend/src/graphql/plants/queries.ts | 26 +++++- .../pages/explorePlants/ExplorePlantsPage.css | 7 ++ .../pages/explorePlants/ExplorePlantsPage.tsx | 29 +++++-- frontend/src/tests/ExplorePlantsPage.test.tsx | 83 ++++++++++++++++++- .../ExplorePlantsPage.test.tsx.snap | 73 ++++++++-------- 6 files changed, 186 insertions(+), 47 deletions(-) diff --git a/frontend/src/components/filterSelect/FilterSelect.tsx b/frontend/src/components/filterSelect/FilterSelect.tsx index 2f7dee90..bb243580 100644 --- a/frontend/src/components/filterSelect/FilterSelect.tsx +++ b/frontend/src/components/filterSelect/FilterSelect.tsx @@ -1,6 +1,7 @@ import "./FilterSelect.css"; -type FilterOption = { value: string; label: string }; +// count is how many plants the value would give. Without a count, only the label is shown. +type FilterOption = { value: string; label: string; count?: number }; type FilterSelectProps = { label: string; @@ -25,8 +26,16 @@ export default function FilterSelect({ diff --git a/frontend/src/graphql/plants/queries.ts b/frontend/src/graphql/plants/queries.ts index 184da1d5..ef222210 100644 --- a/frontend/src/graphql/plants/queries.ts +++ b/frontend/src/graphql/plants/queries.ts @@ -42,12 +42,36 @@ export const EXPLORE_PLANTS = gql` plants { ...PlantFields } + filterCounts { + watering { + value + count + } + sunlight { + value + count + } + careLevel { + value + count + } + } } } ${PLANT_FIELDS} `; export type GetPlantsData = { getPlants: Plant[] }; +// How many plants each filter value would give, with the current search and other filters +export type OptionCount = { value: string; count: number }; +export type FilterCounts = Record< + "watering" | "sunlight" | "careLevel", + OptionCount[] +>; export type ExplorePlantsData = { - explorePlants: { totalCount: number; plants: Plant[] }; + explorePlants: { + totalCount: number; + plants: Plant[]; + filterCounts: FilterCounts; + }; }; diff --git a/frontend/src/pages/explorePlants/ExplorePlantsPage.css b/frontend/src/pages/explorePlants/ExplorePlantsPage.css index 32a81159..40bcf4a0 100644 --- a/frontend/src/pages/explorePlants/ExplorePlantsPage.css +++ b/frontend/src/pages/explorePlants/ExplorePlantsPage.css @@ -118,6 +118,13 @@ text-align: center; } +/* The previous results are dimmed a little while new ones load, + so the user sees that something is happening */ +.explore-results.is-refreshing .plant-grid { + opacity: 0.6; + transition: opacity 0.2s; +} + .plant-grid { list-style: none; margin: 0; diff --git a/frontend/src/pages/explorePlants/ExplorePlantsPage.tsx b/frontend/src/pages/explorePlants/ExplorePlantsPage.tsx index aeaed9e8..34794458 100644 --- a/frontend/src/pages/explorePlants/ExplorePlantsPage.tsx +++ b/frontend/src/pages/explorePlants/ExplorePlantsPage.tsx @@ -59,7 +59,12 @@ export default function ExplorePlantsPage() { // Matches come from the user in the database, so every page sees the same list const { matchedPlantIds, addMatch, removeMatch } = useMatchedPlants(); - const { data, loading, error } = useQuery(EXPLORE_PLANTS, { + const { + data: currentData, + previousData, + loading, + error, + } = useQuery(EXPLORE_PLANTS, { variables: { search: debouncedSearch || null, watering: filters.watering || null, @@ -71,9 +76,17 @@ export default function ExplorePlantsPage() { }, }); + // While new results load, the previous ones stay on screen, so the page does + // not flicker or jump when the search, a filter or the page changes. + // The loading text is only shown the first time, when there is nothing to show. + const data = error ? undefined : (currentData ?? previousData); + const initialLoading = loading && !data; + const refreshing = loading && !!data; + const plants = data?.explorePlants.plants ?? []; const totalCount = data?.explorePlants.totalCount ?? 0; const totalPages = Math.max(1, Math.ceil(totalCount / PAGE_SIZE)); + const filterCounts = data?.explorePlants.filterCounts; return (
    @@ -110,6 +123,10 @@ export default function ExplorePlantsPage() { options={filter.options.map((option) => ({ value: option, label: t(`explorePlantsPage.${option}`), + // No counts until the first result has come, then nothing is disabled + count: filterCounts?.[filter.param].find( + (c) => c.value === option, + )?.count, }))} onChange={(value) => setFilter(filter.param, value)} /> @@ -131,17 +148,19 @@ export default function ExplorePlantsPage() { {t("explorePlantsPage.reset")} -
    - {loading &&

    {t("explorePlantsPage.loading")}

    } +
    + {initialLoading &&

    {t("explorePlantsPage.loading")}

    } {error &&

    {t("explorePlantsPage.error")}

    } {/* aria-live so screen readers hear the new count, or that nothing was found, when search or filters change. The element is always there, since screen readers only announce changes to a region they already know. */}

    - {loading || error + {initialLoading || error ? "" : totalCount > 0 ? t("explorePlantsPage.resultsCount", { count: totalCount }) diff --git a/frontend/src/tests/ExplorePlantsPage.test.tsx b/frontend/src/tests/ExplorePlantsPage.test.tsx index d216738b..bf44d331 100644 --- a/frontend/src/tests/ExplorePlantsPage.test.tsx +++ b/frontend/src/tests/ExplorePlantsPage.test.tsx @@ -83,12 +83,30 @@ function makePlants(count: number, start = 1, prefix = "Plant") { })); } +// Match counts for the filter dropdowns. Every value gives 1 plant, +// unless a test sets another number, e.g. { high: 0 } +function makeFilterCounts(overrides: Record = {}) { + const counts = (values: string[]) => + values.map((value) => ({ + __typename: "OptionCount", + value, + count: overrides[value] ?? 1, + })); + return { + __typename: "FilterCounts", + watering: counts(["minimum", "average", "frequent"]), + sunlight: counts(["full_sun", "part_shade", "filtered_shade"]), + careLevel: counts(["low", "medium", "high"]), + }; +} + // A mocked backend response for one exact set of query variables. // `result` is a spy, so tests can check whether the request was sent. function mockResponse( variables: Partial, plants = makePlants(3), totalCount = plants.length, + filterCounts = makeFilterCounts(), ) { return { request: { @@ -97,7 +115,12 @@ function mockResponse( }, result: vi.fn(() => ({ data: { - explorePlants: { __typename: "PlantPage", totalCount, plants }, + explorePlants: { + __typename: "ExplorePage", + totalCount, + plants, + filterCounts, + }, }, })), }; @@ -328,6 +351,64 @@ describe("ExplorePlantsPage", () => { await screen.findByText("explorePlantsPage.noResults"); expect(screen.queryByText(/resultsCount/)).not.toBeInTheDocument(); }); + + it("shows the number of matches for each filter value", async () => { + setup([ + mockResponse({}, makePlants(3), 3, makeFilterCounts({ high: 4 })), + ]); + await screen.findAllByTestId("plant-card"); + + expect( + screen.getByRole("option", { name: "explorePlantsPage.high (4)" }), + ).toBeInTheDocument(); + }); + + it("disables filter values with no matches, but not the chosen one", async () => { + setup( + [ + mockResponse( + { careLevel: "high" }, + [], + 0, + makeFilterCounts({ low: 0, high: 0 }), + ), + ], + "/explorePlants?careLevel=high", + ); + await screen.findByText("explorePlantsPage.noResults"); + + expect( + screen.getByRole("option", { name: "explorePlantsPage.low (0)" }), + ).toBeDisabled(); + // Chosen, so the user can still choose it away + expect( + screen.getByRole("option", { name: "explorePlantsPage.high (0)" }), + ).toBeEnabled(); + }); + + it("keeps the previous results on screen while new ones load", async () => { + const { user } = setup([ + mockResponse({}), + { + ...mockResponse({ careLevel: "high" }, makePlants(2, 1, "High")), + delay: 100, + }, + ]); + await screen.findAllByTestId("plant-card"); + + await user.selectOptions( + screen.getByLabelText("explorePlantsPage.careLevel"), + "high", + ); + + // The old plants are still there, and no loading text replaces them + expect(cardNames()).toEqual(["Plant 1", "Plant 2", "Plant 3"]); + expect( + screen.queryByText("explorePlantsPage.loading"), + ).not.toBeInTheDocument(); + + expect(await screen.findByText("High 1")).toBeInTheDocument(); + }); }); // Page-based navigation: the page counter, the previous/next buttons (disabled diff --git a/frontend/src/tests/__snapshots__/ExplorePlantsPage.test.tsx.snap b/frontend/src/tests/__snapshots__/ExplorePlantsPage.test.tsx.snap index 67e4adc6..18c2f8ac 100644 --- a/frontend/src/tests/__snapshots__/ExplorePlantsPage.test.tsx.snap +++ b/frontend/src/tests/__snapshots__/ExplorePlantsPage.test.tsx.snap @@ -45,7 +45,7 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with n @@ -71,17 +71,17 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with n @@ -98,17 +98,17 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with n @@ -125,17 +125,17 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with n @@ -211,13 +211,12 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with n

    -

    - explorePlantsPage.noResults -

    + class="results-count results-count--empty" + > + explorePlantsPage.noResults +

      @@ -271,7 +270,7 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with r @@ -297,17 +296,17 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with r @@ -324,17 +323,17 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with r @@ -351,17 +350,17 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with r @@ -877,7 +876,7 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with t @@ -903,17 +902,17 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with t @@ -930,17 +929,17 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with t @@ -957,17 +956,17 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with t @@ -975,7 +974,7 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with t class="sort-menu" >
      • - -
        diff --git a/frontend/src/tests/__snapshots__/ExplorePlantsPage.test.tsx.snap b/frontend/src/tests/__snapshots__/ExplorePlantsPage.test.tsx.snap index 18c2f8ac..b56fa8fa 100644 --- a/frontend/src/tests/__snapshots__/ExplorePlantsPage.test.tsx.snap +++ b/frontend/src/tests/__snapshots__/ExplorePlantsPage.test.tsx.snap @@ -200,14 +200,14 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with n + -
        @@ -425,14 +425,14 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with r + -
        @@ -1073,14 +1073,14 @@ exports[`ExplorePlantsPage > snapshots > matches the snapshot of the page with t
      + -
      From 4ebfe9604443ede23ee3f5d91ed47354c4eaa5f4 Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Sun, 22 Nov 2026 13:42:52 +0100 Subject: [PATCH 5/7] fit three plant cards per row on laptop screens on Explore and My Matches --- frontend/src/components/plantCard/PlantCard.css | 10 ++++++++++ frontend/src/pages/explorePlants/ExplorePlantsPage.css | 2 +- frontend/src/pages/myMatches/MyMatchesPage.css | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/plantCard/PlantCard.css b/frontend/src/components/plantCard/PlantCard.css index 4d73fa45..d567c581 100644 --- a/frontend/src/components/plantCard/PlantCard.css +++ b/frontend/src/components/plantCard/PlantCard.css @@ -6,6 +6,16 @@ --plant-card-compact-width: calc(390px * var(--plant-card-compact-scale)); } +/* Smaller compact cards on laptop screens, where the normal size only fits + two columns on Explore Plants and My Matches. From 1360 px three columns + fit at the normal size, so the cards keep it there instead of getting a + lot of space between them. */ +@media (min-width: 768px) and (max-width: 1359px) { + :root { + --plant-card-compact-scale: 0.7; + } +} + .plant-card-flipper { --card-name-height: clamp(100px, 8vh, 86px); --card-fold-base: clamp(38px, 19.5cqw, 60px); diff --git a/frontend/src/pages/explorePlants/ExplorePlantsPage.css b/frontend/src/pages/explorePlants/ExplorePlantsPage.css index 85a27ddd..de7f75c8 100644 --- a/frontend/src/pages/explorePlants/ExplorePlantsPage.css +++ b/frontend/src/pages/explorePlants/ExplorePlantsPage.css @@ -97,7 +97,7 @@ .explore-results { width: 100%; box-sizing: border-box; - padding: 40px; + padding: 24px; border-radius: 16px; background-color: var(--light-pink); } diff --git a/frontend/src/pages/myMatches/MyMatchesPage.css b/frontend/src/pages/myMatches/MyMatchesPage.css index 2aeefff1..a3afed7c 100644 --- a/frontend/src/pages/myMatches/MyMatchesPage.css +++ b/frontend/src/pages/myMatches/MyMatchesPage.css @@ -42,7 +42,7 @@ width: 100%; box-sizing: border-box; - padding: 40px; + padding: 24px; border-radius: 16px; background-color: var(--light-pink); } From 472daef0a492499277de7dc6eeb64c0a0d715847 Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Sun, 22 Nov 2026 14:17:24 +0100 Subject: [PATCH 6/7] update documentation for filter counts and loading on Explore --- README.md | 2 +- docs/architecture.md | 15 ++++++++------- docs/quality.md | 6 +++++- docs/tests.md | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5fa92af0..f7b825a4 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ http://it2810-03.idi.ntnu.no/project2/ - **Plant Match:** Plants matching the most preferences come first, otherwise the order is random. The deck is kept while the user visits other pages, so they can continue where they left off. - **My Matches:** Collects liked plants from both Plant Match and Explore Plants. The user only stores plant ids, and the list is fetched one page at a time, so responses do not grow with the number of matches. -- **Explore Plants:** Search, filtering, sorting and pagination run in the backend, so the frontend only receives one page at a time, whatever the size of the collection. The state is kept in the URL, so a view survives a refresh and can be shared as a link. +- **Explore Plants:** Search, filtering, sorting and pagination run in the backend, so the frontend only receives one page at a time, whatever the size of the collection. The state is kept in the URL, so a view survives a refresh and can be shared as a link. Each filter value shows how many plants it would give, and values that would give none can't be chosen, so filtering never ends in an empty list. ## Tech stack diff --git a/docs/architecture.md b/docs/architecture.md index e556b12c..4e281c31 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -101,7 +101,7 @@ The backend exposes a single GraphQL endpoint. With GraphQL, the frontend asks f - `server.ts` starts Apollo Server on `PORT` (default 3001) with the schema and resolvers below. - `schema.ts` defines the GraphQL schema (`typeDefs`). - `resolvers.ts` has the resolvers for plants and users, and validates user input. -- `queryBuilders.ts` builds the MongoDB filters and sort stages for searching, filtering and sorting plants on Explore Plants and My Matches. +- `queryBuilders.ts` builds the MongoDB filters and sort stages for searching, filtering and sorting plants on Explore Plants and My Matches, and the counts of how many plants each filter value would give on Explore Plants. - `indexes.ts` creates the database indexes the app needs when the server starts (see [Scalability](#design-choices-made-for-scalability)). - `types.ts` has the TypeScript types for the MongoDB documents, the GraphQL types and the resolver arguments. - `seedDataFetch.js` fills the `plants` collection with plant data (see [Data source](#data-source-the-perenual-api) below). @@ -110,12 +110,12 @@ The backend exposes a single GraphQL endpoint. With GraphQL, the frontend asks f **Queries** -| Query | Description | -| ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `getPlants(limit = 50, excludeIds, preferences): [Plant]` | Returns up to `limit` plants (at most 50) for the match page, leaving out the plants in `excludeIds` so each batch only has new plants (malformed ids are ignored). Without `preferences` the order is random (MongoDB `$sample`). With `preferences`, each plant gets a score: the number of the preferences it matches on watering, sunlight and care level ("Low" counts as easy care, "Medium" and "Moderate" as medium care). The highest scores come first and plants with the same score are shuffled. Unknown preferences are ignored. | -| `explorePlants(search, sunlight, watering, careLevel, sort, limit = 12, offset = 0): PlantPage!` | Search on common or scientific name (case-insensitive), filter on sunlight, watering and care level, sort and paginate (`limit` is kept between 1 and 50, and a negative `offset` counts as 0). Returns the plants on the page and `totalCount` for the whole result. Sort can be `name_desc`, `watering_asc` or `careLevel_asc`; the default is name A–Z. | -| `getUser(userId): User` | Returns the user, or `null` if the id is unknown or malformed. | -| `myMatches(userId, sort, limit = 12, offset = 0): PlantPage!` | Returns one page of the user's matched plants and `totalCount` (`limit` and `offset` are kept within the same bounds as in `explorePlants`). Sort can be `oldest`, `name_asc` or `name_desc`; the default is newest first. The order of `matchedPlantIds` is the order the plants were matched, so no date is needed. An unknown or malformed user id gives an empty page. | +| Query | Description | +| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `getPlants(limit = 50, excludeIds, preferences): [Plant]` | Returns up to `limit` plants (at most 50) for the match page, leaving out the plants in `excludeIds` so each batch only has new plants (malformed ids are ignored). Without `preferences` the order is random (MongoDB `$sample`). With `preferences`, each plant gets a score: the number of the preferences it matches on watering, sunlight and care level ("Low" counts as easy care, "Medium" and "Moderate" as medium care). The highest scores come first and plants with the same score are shuffled. Unknown preferences are ignored. | +| `explorePlants(search, sunlight, watering, careLevel, sort, limit = 12, offset = 0): ExplorePage!` | Search on common or scientific name (case-insensitive), filter on sunlight, watering and care level, sort and paginate (`limit` is kept between 1 and 50, and a negative `offset` counts as 0). Returns the plants on the page and `totalCount` for the whole result. Sort can be `name_desc`, `watering_asc` or `careLevel_asc`; the default is name A–Z. Also returns `filterCounts`: for every filter value, the number of plants it would give instead of the current choice in the same filter, together with the search and the other filters. The counts use the same filter as the results, so they always agree, and are done in one `$facet` aggregation. | +| `getUser(userId): User` | Returns the user, or `null` if the id is unknown or malformed. | +| `myMatches(userId, sort, limit = 12, offset = 0): PlantPage!` | Returns one page of the user's matched plants and `totalCount` (`limit` and `offset` are kept within the same bounds as in `explorePlants`). Sort can be `oldest`, `name_asc` or `name_desc`; the default is newest first. The order of `matchedPlantIds` is the order the plants were matched, so no date is needed. An unknown or malformed user id gives an empty page. | **Mutations** @@ -131,6 +131,7 @@ The backend exposes a single GraphQL endpoint. With GraphQL, the frontend asks f - `Plant`: `id`, `name`, `imageURL`, `scientificName`, `description`, `watering`, `sunlight`, `careLevel` - `PlantPage`: `plants`, `totalCount` +- `ExplorePage`: `plants`, `totalCount`, `filterCounts`. `FilterCounts` has `watering`, `sunlight` and `careLevel`, each a list of `OptionCount` (`value`, `count`). Explore has its own type, since My Matches also uses `PlantPage` but has no filters to count. - `User`: `id`, `name`, `description`, `profilePicture`, `preferences`, `matchedPlantIds`, `createdAt` `User.matchedPlantIds` only returns the ids, so the pages that just need to know whether a plant is matched do not fetch the whole plants with images. The plants themselves are fetched one page at a time with `myMatches`, which only shows and counts plants that still exist (for example after a reseed). diff --git a/docs/quality.md b/docs/quality.md index 938e1af5..45b6e20a 100644 --- a/docs/quality.md +++ b/docs/quality.md @@ -53,7 +53,7 @@ The app includes the following accessibility features: - **Forms and images:** Search, filters and profile inputs have associated labels. Plant images use the plant name as alternative text, and profile and avatar images also include alternative text. -- **Control states:** The sort menu and the mobile menu button expose their expanded state and which element they control. Sort, avatar and preference choices and the profile tabs expose their selected state with `aria-pressed`. The preference chips on the plant cards are a list, and a chip that matches the user's preferences also says so in text that only screen readers read, so the information is not given by color alone. Pagination marks the current page with `aria-current="page"` and announces page changes through an `aria-live="polite"` region. On Explore Plants and My Matches, the number of results or matches is also announced when it changes, including "no matches" when the last match is removed. Every page has one `h1` (the page title in the header) and a `main` landmark. The match button on the plant cards shows ✿ to add a plant to My Matches and ✖ to remove it, and its accessible name and tooltip say what a click does. If adding or removing a match fails, an error message is shown at the top of the screen in a `role="alert"` region, so screen readers read it at once without moving focus. +- **Control states:** The sort menu and the mobile menu button expose their expanded state and which element they control. Sort, avatar and preference choices and the profile tabs expose their selected state with `aria-pressed`. The preference chips on the plant cards are a list, and a chip that matches the user's preferences also says so in text that only screen readers read, so the information is not given by color alone. Pagination marks the current page with `aria-current="page"` and announces page changes through an `aria-live="polite"` region. On Explore Plants and My Matches, the number of results or matches is also announced when it changes, including "No results found" when a search gives no plants and "no matches" when the last match is removed. Filter values that would give no plants are disabled options, so screen readers say they are unavailable, and the number of plants is part of the option text. Every page has one `h1` (the page title in the header) and a `main` landmark. The match button on the plant cards shows ✿ to add a plant to My Matches and ✖ to remove it, and its accessible name and tooltip say what a click does. If adding or removing a match fails, an error message is shown at the top of the screen in a `role="alert"` region, so screen readers read it at once without moving focus. - **Plant cards:** The inactive side of a flipped card is hidden from assistive technology with `aria-hidden`, and its information button is removed from the keyboard tab order. @@ -83,12 +83,16 @@ We considered sustainability through both our design choices and our approach to - **Debouncing:** On the Explore Plants page, the search waits 300 ms after the user stops typing before sending a request, so results still feel instant without a request per keystroke, reducing unnecessary search operations. Profile text is saved after 500 ms, since the text is shown right away and the save happens in the background, and a longer delay only means fewer writes to the database. The profile is also saved immediately when a field loses focus or the user leaves the page, so no text is lost. +- **Filter counts in one query:** The number of plants for every filter value on Explore Plants is counted in the same request as the results, in one database query, instead of one request per value. Values that would give no plants can't be chosen, so the user does not send requests that only return an empty list. + ## Design choices - **Color palette and contrast:** We used a limited color palette to maintain a consistent visual identity across the application. We also checked the contrast between our chosen colors to help ensure that text and other interface elements remain distinguishable and in line with accessibility requirements. See [Accessibility](#accessibility). - **Reusable components:** Shared UI is kept in reusable components, so the pages look and work the same way and changes only need to be made in one place. This makes the application easier to maintain. The Header, Sidebar and plant cards are used across pages, `Pagination`, `SortMenu` and `MatchButton` are shared by Explore Plants and My Matches, and `ErrorMessage` shows error messages on every page. The filters on Explore Plants are defined in one list of `FilterSelect` components, so a new filter only needs one new line. +- **Keeping the previous results while loading:** On Explore Plants, the previous results and the number of results stay on screen, slightly dimmed, while new ones load (with Apollo's `previousData`). The page does not flicker or jump when the search, a filter or the page changes, and the loading text is only shown the first time. + - **Consistent icons:** All icons are inline SVG components in [Icons.tsx](../frontend/src/components/icons/Icons.tsx) and [ThemeIcons.tsx](../frontend/src/components/sidebarButtons/ThemeIcons.tsx), drawn on the same 24 × 24 grid. They use `currentColor`, so they follow the text color in both light and dark mode, and they are sized with `font-size`, so they scale with the text around them. They are marked with `aria-hidden` and `focusable="false"`, since the search field and the buttons they are in already have accessible names, so screen readers do not read the icons twice. Because we drew the icons ourselves, there are no third-party licences to credit. - **Responsive design:** We designed the application for both desktop and mobile screens. The layout adapts to different screen sizes to ensure that the content and navigation remain usable across devices. diff --git a/docs/tests.md b/docs/tests.md index d60e7c72..75dd1c66 100644 --- a/docs/tests.md +++ b/docs/tests.md @@ -116,7 +116,7 @@ The tests are in `frontend/src/tests`. Snapshot tests are used for the explore p - `ExplorePlantsPage.test.tsx` - Loading, error and empty results: a loading message, an error message when the query fails, and a message without page navigation when nothing matches. - Search, filters and sorting: the search text is only sent after the debounce delay, the chosen filters and sort order are sent in the query, the selected sort is visible and included in the sort button's accessible name, and the sort menu closes with Escape and with a click outside. - - Number of results: the total number for the whole result is shown, not only the plants on the page, it updates when a filter changes, it is in an `aria-live` region, and it is hidden while loading and when nothing matches. + - Number of results: the total number for the whole result is shown, not only the plants on the page, it updates when a filter changes, it is in an `aria-live` region together with "No results found", and it is hidden while loading. Each filter value shows its number of matches, values with no matches are disabled except the chosen one, and the previous results stay on screen while new ones load. - Pagination: moving between pages, disabled buttons at the ends, and going back to page 1 when a filter or the search text changes. - Matches: the button adds a plant that is not matched (✿), and removes a plant that is already matched (✖). - URL state: search, filters, sorting and page are restored from the URL, changes are written to the URL, and reset clears the Explore parameters. @@ -181,7 +181,7 @@ The tests are in `backend/tests`. They use a real MongoDB in memory, started in - Connecting to the database in `MONGODB_URI` and `DB_NAME`, using `iloveplants` when `DB_NAME` is not set, and the error messages when `MONGODB_URI` is missing or empty, is not a MongoDB address, or MongoDB cannot be reached (for example when the SSH tunnel is down). - `server.test.ts` - Starting the server: the default port 3001, the port in `PORT`, and stopping with the error when the port is in use. - - Plants: `getPlants` returns the plants that match the most of the user's preferences first, also when they are fetched in batches ("Low" counts as easy care), random plants when there are no preferences or only unknown ones, and leaves out the plants in `excludeIds` (returning none when all are excluded). Also stored image data before the image URL, and in `explorePlants` the default sorting, case-insensitive search across common and scientific names with special characters read as text, the watering, care level and sunlight filters ("Medium" and "Moderate" count as the same care level), pagination with the total count, that `limit` and `offset` are kept within valid bounds (at most 50 plants per request), and all sort orders. + - Plants: `getPlants` returns the plants that match the most of the user's preferences first, also when they are fetched in batches ("Low" counts as easy care), random plants when there are no preferences or only unknown ones, and leaves out the plants in `excludeIds` (returning none when all are excluded). Also stored image data before the image URL, and in `explorePlants` the default sorting, case-insensitive search across common and scientific names with special characters read as text, the watering, care level and sunlight filters ("Medium" and "Moderate" count as the same care level), pagination with the total count, that `limit` and `offset` are kept within valid bounds (at most 50 plants per request), and all sort orders, and the match counts for every filter value (with the search and the other filters, but not the filter's own choice). - Users: creating and fetching users, updating the profile (trimming text, storing empty text and `null` as `null`, and only changing the sent fields), the plant owner test results as profile pictures, preferences without duplicates, and adding and removing matches in order. - My matches: `myMatches` sorts by newest (the default), oldest, A–Z and Z–A, returns one page at a time with the total count, leaves out and does not count matched plants that were deleted, and returns an empty page for a user without matches and for an unknown or malformed user id. - Error messages: invalid input gives the right message and the code `BAD_USER_INPUT` and saves nothing (too long name or description, unknown profile picture, unknown preferences, unknown or malformed plant ids), invalid GraphQL requests give the right error, and the server passes on a database error and keeps running. From 1fd1471e544d9517ec190ab0239f5d154d25f63b Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Sun, 22 Nov 2026 14:54:32 +0100 Subject: [PATCH 7/7] show match count for "All" in the filters --- backend/src/queryBuilders.ts | 5 +++-- backend/tests/server.test.ts | 17 ++++++++++++----- docs/architecture.md | 12 ++++++------ .../components/filterSelect/FilterSelect.tsx | 7 ++++++- .../pages/explorePlants/ExplorePlantsPage.tsx | 3 +++ frontend/src/tests/ExplorePlantsPage.test.tsx | 10 +++++++--- .../ExplorePlantsPage.test.tsx.snap | 18 +++++++++--------- 7 files changed, 46 insertions(+), 26 deletions(-) diff --git a/backend/src/queryBuilders.ts b/backend/src/queryBuilders.ts index 4c84d08e..99305ca5 100644 --- a/backend/src/queryBuilders.ts +++ b/backend/src/queryBuilders.ts @@ -143,7 +143,8 @@ const facetKey = (param: string, value: string) => `${param}:${value}`; export const buildFilterCountStages = (args: ExplorePlantsArgs): Document[] => { const facets: Record = {}; for (const [param, options] of Object.entries(FILTER_OPTIONS)) { - for (const value of options) { + // "" is "All": nothing chosen in this filter, so only the search and the other filters count + for (const value of ["", ...options]) { facets[facetKey(param, value)] = [ { $match: buildExploreFilter({ ...args, [param]: value }) }, { $count: "count" }, @@ -164,7 +165,7 @@ export const toFilterCounts = ( ): FilterCounts => { const counts = {} as FilterCounts; for (const [param, options] of Object.entries(FILTER_OPTIONS)) { - counts[param as FilterParam] = options.map((value) => ({ + counts[param as FilterParam] = ["", ...options].map((value) => ({ value, count: facets[facetKey(param, value)]?.[0]?.count ?? 0, })); diff --git a/backend/tests/server.test.ts b/backend/tests/server.test.ts index c46e0110..7ef20356 100644 --- a/backend/tests/server.test.ts +++ b/backend/tests/server.test.ts @@ -493,25 +493,32 @@ describe("plants", () => { it("counts the matches for every filter value", async () => { expect(await filterCounts()).toEqual({ - watering: { minimum: 2, average: 2, frequent: 1 }, - sunlight: { full_sun: 2, part_shade: 2, filtered_shade: 1 }, - careLevel: { low: 1, medium: 3, high: 1 }, + watering: { "": 6, minimum: 2, average: 2, frequent: 1 }, + sunlight: { "": 6, full_sun: 2, part_shade: 2, filtered_shade: 1 }, + careLevel: { "": 6, low: 1, medium: 3, high: 1 }, }); }); it("counts with the search and the other filters, but not the filter's own choice", async () => { const counts = await filterCounts({ watering: "average" }); // Choosing another watering value replaces "average", so these are unchanged - expect(counts.watering).toEqual({ minimum: 2, average: 2, frequent: 1 }); + expect(counts.watering).toEqual({ + "": 6, + minimum: 2, + average: 2, + frequent: 1, + }); // Only Daisy and Fern (giant) have average watering expect(counts.sunlight).toEqual({ + "": 2, full_sun: 0, part_shade: 1, filtered_shade: 1, }); - expect(counts.careLevel).toEqual({ low: 0, medium: 2, high: 0 }); + expect(counts.careLevel).toEqual({ "": 2, low: 0, medium: 2, high: 0 }); expect((await filterCounts({ search: "fern" })).watering).toEqual({ + "": 2, minimum: 0, average: 1, frequent: 0, diff --git a/docs/architecture.md b/docs/architecture.md index 4e281c31..7647b3f5 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -110,12 +110,12 @@ The backend exposes a single GraphQL endpoint. With GraphQL, the frontend asks f **Queries** -| Query | Description | -| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `getPlants(limit = 50, excludeIds, preferences): [Plant]` | Returns up to `limit` plants (at most 50) for the match page, leaving out the plants in `excludeIds` so each batch only has new plants (malformed ids are ignored). Without `preferences` the order is random (MongoDB `$sample`). With `preferences`, each plant gets a score: the number of the preferences it matches on watering, sunlight and care level ("Low" counts as easy care, "Medium" and "Moderate" as medium care). The highest scores come first and plants with the same score are shuffled. Unknown preferences are ignored. | -| `explorePlants(search, sunlight, watering, careLevel, sort, limit = 12, offset = 0): ExplorePage!` | Search on common or scientific name (case-insensitive), filter on sunlight, watering and care level, sort and paginate (`limit` is kept between 1 and 50, and a negative `offset` counts as 0). Returns the plants on the page and `totalCount` for the whole result. Sort can be `name_desc`, `watering_asc` or `careLevel_asc`; the default is name A–Z. Also returns `filterCounts`: for every filter value, the number of plants it would give instead of the current choice in the same filter, together with the search and the other filters. The counts use the same filter as the results, so they always agree, and are done in one `$facet` aggregation. | -| `getUser(userId): User` | Returns the user, or `null` if the id is unknown or malformed. | -| `myMatches(userId, sort, limit = 12, offset = 0): PlantPage!` | Returns one page of the user's matched plants and `totalCount` (`limit` and `offset` are kept within the same bounds as in `explorePlants`). Sort can be `oldest`, `name_asc` or `name_desc`; the default is newest first. The order of `matchedPlantIds` is the order the plants were matched, so no date is needed. An unknown or malformed user id gives an empty page. | +| Query | Description | +| -------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `getPlants(limit = 50, excludeIds, preferences): [Plant]` | Returns up to `limit` plants (at most 50) for the match page, leaving out the plants in `excludeIds` so each batch only has new plants (malformed ids are ignored). Without `preferences` the order is random (MongoDB `$sample`). With `preferences`, each plant gets a score: the number of the preferences it matches on watering, sunlight and care level ("Low" counts as easy care, "Medium" and "Moderate" as medium care). The highest scores come first and plants with the same score are shuffled. Unknown preferences are ignored. | +| `explorePlants(search, sunlight, watering, careLevel, sort, limit = 12, offset = 0): ExplorePage!` | Search on common or scientific name (case-insensitive), filter on sunlight, watering and care level, sort and paginate (`limit` is kept between 1 and 50, and a negative `offset` counts as 0). Returns the plants on the page and `totalCount` for the whole result. Sort can be `name_desc`, `watering_asc` or `careLevel_asc`; the default is name A–Z. Also returns `filterCounts`: for every filter value, and for "All" (an empty value), the number of plants it would give instead of the current choice in the same filter, together with the search and the other filters. The counts use the same filter as the results, so they always agree, and are done in one `$facet` aggregation. | +| `getUser(userId): User` | Returns the user, or `null` if the id is unknown or malformed. | +| `myMatches(userId, sort, limit = 12, offset = 0): PlantPage!` | Returns one page of the user's matched plants and `totalCount` (`limit` and `offset` are kept within the same bounds as in `explorePlants`). Sort can be `oldest`, `name_asc` or `name_desc`; the default is newest first. The order of `matchedPlantIds` is the order the plants were matched, so no date is needed. An unknown or malformed user id gives an empty page. | **Mutations** diff --git a/frontend/src/components/filterSelect/FilterSelect.tsx b/frontend/src/components/filterSelect/FilterSelect.tsx index bb243580..d09c81a7 100644 --- a/frontend/src/components/filterSelect/FilterSelect.tsx +++ b/frontend/src/components/filterSelect/FilterSelect.tsx @@ -7,6 +7,8 @@ type FilterSelectProps = { label: string; value: string; allLabel: string; + // How many plants "All" gives. Without a count, only the label is shown. + allCount?: number; options: FilterOption[]; onChange: (value: string) => void; }; @@ -17,6 +19,7 @@ export default function FilterSelect({ label, value, allLabel, + allCount, options, onChange, }: FilterSelectProps) { @@ -24,7 +27,9 @@ export default function FilterSelect({