Dev Refactor Fixes#164
Conversation
| const fridgeId = params.fridgeId as string; | ||
| const fridgeId = (params?.fridgeId ?? '') as string; | ||
|
|
||
| const postReportUrl = `${process.env.NEXT_PUBLIC_FF_API_URL}/v1/reports`; |
There was a problem hiding this comment.
API was incorrect - fixed
| /* Sizes & Colors */ | ||
| .marker-cluster-small { | ||
| background-color: rgba(181, 226, 140, 0.6); | ||
| background-color: rgba(255, 212, 255, 0.5); |
There was a problem hiding this comment.
Used colors that matches out color palette
| {children} | ||
| </Providers> | ||
| </AppRouterCacheProvider> | ||
| {analytics.TRACKING_ID && ( |
There was a problem hiding this comment.
added analytics back
| }, | ||
| dirty: { | ||
| text: 'Fridge is dirty', | ||
| text: 'Fridge needs cleaning', |
There was a problem hiding this comment.
snuck this one in here, not needed but we wanted to update the language so I just did it here
| /> | ||
| </Stack> | ||
| </> | ||
| <Box |
There was a problem hiding this comment.
snuck this one in here too, image sizing was too big so updated to the sizing that we wanted based on this previous MR
| @@ -1,5 +1,3 @@ | |||
| 'use client'; | |||
There was a problem hiding this comment.
FridgeInformation component needs to be SSR, removed 'use client' and moved client side Share button to a different component
| @@ -0,0 +1,36 @@ | |||
| 'use client'; | |||
There was a problem hiding this comment.
Moved share button to a new component so that FridgeInformation component can be SSR
| label="Fridge is not at location" | ||
| /> | ||
| <FormControlLabel | ||
| {/* We will be migrating all ghost fridges to "not at location" |
There was a problem hiding this comment.
dev-refactor introduced the "good" condition to the form, so removed the "ghost" condition from the form.
The team has agreed to move away from "ghost" condition so this will be the start
| <Typography variant="caption">{name}</Typography> | ||
| <br /> | ||
| {location.street} | ||
| <Typography |
There was a problem hiding this comment.
This was removed in dev-refactor, added back in
| const fridges = apiFridges | ||
| .map(transformFridge) | ||
| .filter((f) => f.report?.condition !== 'ghost') | ||
| .sort((a, b) => a.name.localeCompare(b.name)); |
There was a problem hiding this comment.
adding back sorting the fridges by name, and filtering out ghost fridges
| styleOverrides: { | ||
| root: { | ||
| borderRadius: 45, | ||
| textTransform: 'none', |
There was a problem hiding this comment.
We want button text to be Capitalized (default), removing this
| 'sans-serif', | ||
| ].join(','), | ||
| h1: { | ||
| fontSize: '2.5rem', // ~30pt |
There was a problem hiding this comment.
Updating all of these to be more accurate to what we have in production
| selectedFridgeId={selectedFridgeId} | ||
| onMarkerClick={setSelectedFridgeId} | ||
| /> | ||
| {!isWindowDesktop && !showSearchMap && ( |
There was a problem hiding this comment.
remove search, it's not ready yet
|
|
||
| const List = ( | ||
| <> | ||
| {isWindowDesktop && ( |
| spiderfyOnMaxZoom={true} | ||
| showCoverageOnHover={false} | ||
| maxClusterRadius={20} | ||
| maxClusterRadius={15} |
There was a problem hiding this comment.
decreased cluster radius slightly
| @@ -0,0 +1,36 @@ | |||
| /** | |||
There was a problem hiding this comment.
adding google analytics back
| "build": "next build", | ||
| "start": "next start", | ||
| "lint": "next lint", | ||
| "lint": "eslint .", |
There was a problem hiding this comment.
next lint depecated in next 15+, using eslint instead
There was a problem hiding this comment.
Pull request overview
This PR restores and expands the frontend test suite, introduces a Google Analytics utility + layout integration, and applies several UI/theme adjustments intended to align styling with production while fixing build issues.
Changes:
- Added/updated Jest tests across utils, store, app routes, and atomic components.
- Introduced Google Analytics support (
utils/analytics) and injected GA scripts from the root layout. - Updated theme/typography and multiple UI components (map markers, footer, buttons, spacing) plus API/reporting and mock data tweaks.
Reviewed changes
Copilot reviewed 33 out of 35 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Adds new type deps (@types/gtag.js, @types/jest) and related transitive entries. |
| package.json | Switches lint script to eslint . and adds new devDependencies for typings. |
| next-env.d.ts | Adds a Next navigation compat type reference. |
| src/utils/analytics.ts | New GA helper module exporting tracking ID + view/event helpers. |
| src/utils/analytics.test.ts | Tests env-driven tracking ID behavior via module reload. |
| src/utils/geo.test.ts | Adds unit tests for deltaInMeters. |
| src/app/layout.tsx | Injects Google Analytics scripts when tracking ID is configured. |
| src/app/globals.css | Adds global box-sizing reset and changes cluster marker colors. |
| src/theme/typography.ts | Adds MUI typography variant augmentation + adjusts typography scale and introduces footer variant. |
| src/theme/index.ts | Updates typography typing usage and tweaks button styling overrides. |
| src/store/useFridgeStore.ts | Filters out ghost fridges and sorts fridges by name after fetch. |
| src/store/useFridgeStore.test.ts | Adds tests for store fetch lifecycle and selectors. |
| src/features/navigation/components/ResponsiveAppBar.tsx | Adjusts mobile drawer width. |
| src/features/fridge-map/components/layers/MarkerLayer.tsx | Enhances popup content with MUI typography + adds action buttons; adjusts clustering radius. |
| src/features/fridge-management/components/ReportForm.tsx | Updates condition label copy and comments out “ghost” option. |
| src/features/fridge-list/components/FridgeList.tsx | Improves aria-label copy and adjusts button font sizing. |
| src/features/fridge-details/components/ShareButton.tsx | Adds a dedicated client-side share button component. |
| src/features/fridge-details/components/FridgeInformation.tsx | Refactors share logic into ShareButton, adjusts copy, and changes image rendering layout. |
| src/components/atoms/TitleCard/TitleCard.tsx | Adjusts card sizing and typography variant. |
| src/components/atoms/TitleCard/TitleCard.test.tsx | Adds render/link/image test coverage for TitleCard. |
| src/components/atoms/SoftWrap/SoftWrap.test.tsx | Adds tests for sentence wrapping and edge cases. |
| src/components/atoms/ParagraphCard/ParagraphCard.test.tsx | Adds tests for ParagraphCard variants and CTA link. |
| src/components/atoms/PamphletParagraph/PamphletParagraph.test.tsx | Adds tests for optional/required rendering behavior. |
| src/components/atoms/PageHero/PageHero.tsx | Removes fontVariant: small-caps styling. |
| src/components/atoms/PageHero/PageHero.test.tsx | Adds tests for PageHero rendering with/without button. |
| src/components/atoms/PageFooter/PageFooter.tsx | Switches footer typography variant + updates year and styling. |
| src/components/atoms/PageFooter/PageFooter.test.tsx | Adds tests for footer text and scroll button behavior. |
| src/components/atoms/FeedbackCard/FeedbackCard.test.tsx | Adds tests covering multiple FeedbackCard variants and interactions. |
| src/components/atoms/ButtonLink/ButtonLink.test.tsx | Adds tests for ButtonLink variants and URL handling. |
| src/app/user/fridge/report/[fridgeId]/page.tsx | Updates report POST endpoint to be fridge-scoped and makes param access more defensive. |
| src/app/user/fridge/report/[fridgeId]/page.test.tsx | Adds tests for form rendering, submit success, and error flows. |
| src/app/user/contact/page.tsx | Makes useSearchParams() access more defensive and switches to nullish coalescing. |
| src/app/pamphlet/best-practices/page.tsx | Adjusts page vertical padding. |
| mock/data.json | Adds missing IDs to reports and seeds contact entries. |
Comments suppressed due to low confidence (1)
src/app/browse/page.tsx:50
showSearchMapis initialized tofalseand is only ever set tofalse(viaonClose), so theSearchMapUI can never be opened anymore. That also makessearchQueryeffectively not user-editable, so filtering can’t be used. Reintroduce an explicit control that setssetShowSearchMap(true)(mobile/desktop as appropriate), or remove the dead state and related JSX if search is intentionally being removed.
const [currentView, setCurrentView] = useState<MapView>('map');
const [showSearchMap, setShowSearchMap] = useState(false);
const { searchQuery, setSearchQuery, filteredFridges } =
useFridgeSearch(fridges);
const availableHeight = useWindowHeight();
const isWindowDesktop = useMediaQuery((theme: Theme) =>
theme.breakpoints.up('md')
);
useEffect(() => {
fetchFridges();
}, [fetchFridges]);
const Map = (
<Box sx={{ position: 'relative', height: '100%' }}>
<DynamicMap
fridges={filteredFridges}
selectedFridgeId={selectedFridgeId}
onMarkerClick={setSelectedFridgeId}
/>
{showSearchMap && (
<SearchMap
searchQuery={searchQuery}
onSearchChange={setSearchQuery}
onClose={() => setShowSearchMap(false)}
/>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <br /> | ||
| {location.city}, {location.state} {location.zip} | ||
| </Typography> | ||
| <Stack direction="row" width="100" spacing={3} sx={{ mt: 3 }}> |
There was a problem hiding this comment.
width="100" becomes width: 100 (unitless) in CSS, which is invalid and will be ignored by the browser. If the intent is full width, use width="100%" (or sx={{ width: '100%' }}); if it’s pixels, pass a number (width={100}).
| <Stack direction="row" width="100" spacing={3} sx={{ mt: 3 }}> | |
| <Stack direction="row" width="100%" spacing={3} sx={{ mt: 3 }}> |
| fetch(`${baseUrl}${id}/reports`, { | ||
| headers: { Accept: 'application/json' }, | ||
| next: { revalidate: 60 }, | ||
| cache: 'no-store', //when a user makes a status update, we want to fetch the latest report. So no cache |
There was a problem hiding this comment.
we want to serve the latest report, no cache
adea3ae to
a9ba949
Compare
Changes:
I placed comments throughout the MR to mark important updates
Deployed here for QA testing: https://dev-refactor-jp.d1zqbru9k8x5eq.amplifyapp.com/