Conversation
| @@ -0,0 +1,256 @@ | |||
| import { useMutation } from "@tanstack/react-query"; | |||
There was a problem hiding this comment.
This is the old Settings page that was actually renamed to Profile. It appears as new on GitHub but only the title has changed.
| @@ -1,256 +1,407 @@ | |||
| import { useMutation } from "@tanstack/react-query"; | |||
There was a problem hiding this comment.
Although it appears as a changed file, this is indeed a new page. It's just that I reused the old name for the user profile page, so GitHub shows it as a diff.
| * Also rejects duplicate slug values. | ||
| * Returns undefined if valid, or an error message string. | ||
| */ | ||
| const validateItemsInUse = ( |
There was a problem hiding this comment.
I think this can be moved into its own files.
I'd also add unit test on this function.
There was a problem hiding this comment.
I've added unit tests but I'm -1 for moving this function to its own file.
| const slugs = items.map((i) => i.value || toSlug(i.label)); | ||
| const seen = new Set<string>(); | ||
| const duplicates = new Set<string>(); | ||
| for (const slug of slugs) { | ||
| if (seen.has(slug)) duplicates.add(slug); | ||
| seen.add(slug); | ||
| } | ||
| if (duplicates.size > 0) { | ||
| return `Duplicate ${displayName}: ${[...duplicates].join(", ")}`; | ||
| } |
There was a problem hiding this comment.
You could use lodash uniqBy followed by differenceBy to get the duplicated items.
There was a problem hiding this comment.
i don't think this would be significantly better or shorter
Problem
Settings (title, deal categories, etc) can only be customized by code.
Solution
Let admins edit these settings and store the result in the database.
How To Test
Key changes
Rename SettingsPAge to ProfilePage to avoid confusion
New Settings UI (AppConfigPage.tsx - 320 lines)
To do
Additional Checks