- LockScreen: full rewrite — username/password auth (setup/login/TOTP states), ambient glow blobs, UMBRA wordmark in flex flow, animate-slide-up card, HTTP 423 lockout banner, Loader2 spinner, client-side password validation - SettingsPage: two-column lg grid (Profile/Appearance/Weather left, Calendar/Dashboard right), fixed h-16 page header, icon-anchored CardHeaders, labeled accent swatch grid with aria-pressed, max-w-xs removed from name input, upcoming days onBlur save with NaN+no-op guard, Security card removed - useSettings: remove deprecated changePin/isChangingPin stubs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
919 B
TypeScript
33 lines
919 B
TypeScript
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
import api from '@/lib/api';
|
|
import type { Settings } from '@/types';
|
|
|
|
export function useSettings() {
|
|
const queryClient = useQueryClient();
|
|
|
|
const settingsQuery = useQuery({
|
|
queryKey: ['settings'],
|
|
queryFn: async () => {
|
|
const { data } = await api.get<Settings>('/settings');
|
|
return data;
|
|
},
|
|
});
|
|
|
|
const updateMutation = useMutation({
|
|
mutationFn: async (updates: Partial<Settings> & { preferred_name?: string | null }) => {
|
|
const { data } = await api.put<Settings>('/settings', updates);
|
|
return data;
|
|
},
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['settings'] });
|
|
},
|
|
});
|
|
|
|
return {
|
|
settings: settingsQuery.data,
|
|
isLoading: settingsQuery.isLoading,
|
|
updateSettings: updateMutation.mutateAsync,
|
|
isUpdating: updateMutation.isPending,
|
|
};
|
|
}
|