Merge watch profiles into user accounts — one profile per login, no picker

- Removed the "Who's Watching" sub-profile picker entirely: ProfileProvider now
  auto-resolves the single profile tied to the account immediately after login
- Backend: removed POST/DELETE /profiles (no more creating/deleting extra
  profiles — lifecycle is entirely driven by user create/delete, already wired
  in the admin Users CRUD); kept GET (internal) and PATCH (edit your own
  profile's avatar/kids-mode/rating cap)
- Deleted ProfileSelect page and the now-unused ProtectedRoute component
- Navbar: removed the "switch profile" action, account avatar is now just a
  static display
- api.js: dropped the now-dead X-Profile-Id header logic (backend already
  falls back to the account's single profile when the header is absent)
This commit is contained in:
Myron Blair
2026-07-26 19:40:12 -05:00
parent 5b191da471
commit f7626ced2e
8 changed files with 22 additions and 262 deletions
+3 -19
View File
@@ -6,19 +6,15 @@ const ProfileCtx = createContext(null);
export const ProfileProvider = ({ children }) => {
const { user } = useAuth();
const [profiles, setProfiles] = useState([]);
const [active, setActive] = useState(null);
const [loading, setLoading] = useState(false);
const refresh = useCallback(async () => {
if (!user) { setProfiles([]); setActive(null); return; }
if (!user) { setActive(null); return; }
setLoading(true);
try {
const { data } = await api.get("/profiles");
setProfiles(data);
const stored = localStorage.getItem(`kino_profile_${user.id}`);
const found = data.find((p) => p.id === stored);
setActive(found || null);
setActive(data[0] || null);
} finally {
setLoading(false);
}
@@ -26,20 +22,8 @@ export const ProfileProvider = ({ children }) => {
useEffect(() => { refresh(); }, [refresh]);
const switchTo = (p) => {
if (!user) return;
localStorage.setItem(`kino_profile_${user.id}`, p.id);
setActive(p);
};
const clearActive = () => {
if (!user) return;
localStorage.removeItem(`kino_profile_${user.id}`);
setActive(null);
};
return (
<ProfileCtx.Provider value={{ profiles, active, loading, refresh, switchTo, clearActive }}>
<ProfileCtx.Provider value={{ active, loading, refresh }}>
{children}
</ProfileCtx.Provider>
);