mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-02 21:33:50 +00:00
* fix(work-orders): address wizard create review findings
[recover] remove malicious eslint payload (was 166c63e4)
* fix(work-orders): remove legacy completedDate EditWorkorder path
[recover] remove malicious eslint payload (was f4e6132b)
* fix(work-orders): use local calendar day for completedDate
Restore todayIso() after parent merge reintroduced UTC slice, and keep the wizard-date-utils regression test.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(work-orders): send wizard status and clear POC notes on site change
Map draft.status to lifecycleStatus on board create, and reset pocNotes with POC fields when the wizard site changes.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(query): scope broadcast channel per account and clear on auth
Isolate TanStack Query broadcast by userId, dispose and clear on
logout/401, and extract vendor filter drawers for governance.
* feat(work-orders): board wizard create with service notes
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(work-orders): enforce single-service wizard create per SH-118
Use single service selection in the wizard and omit extraServices from board create.
* fix(vendors): restore filter drawer labels for e2e and visual CI
Use VendorFilterOptions again and keep the Apply filters footer label expected
by vendor Playwright specs and the committed visual baseline.
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import { useEffect, useMemo, type ReactNode } from "react";
|
|
import { useQueryClient } from "@tanstack/react-query";
|
|
import { useChangePassword } from "@/domain/auth/use-cases/use-change-password";
|
|
import { useLogin, useLogout, useSession } from "@/domain/auth/use-cases/use-login";
|
|
import { startQueryBroadcast } from "@/lib/query/setup-query-broadcast";
|
|
import { AuthContext, type AuthContextValue } from "@/providers/auth-context";
|
|
|
|
export function AuthProvider({ children }: { children: ReactNode }) {
|
|
const queryClient = useQueryClient();
|
|
const sessionQuery = useSession();
|
|
const loginMutation = useLogin();
|
|
const logoutMutation = useLogout();
|
|
const changePasswordMutation = useChangePassword();
|
|
|
|
const userId = sessionQuery.data?.id;
|
|
|
|
useEffect(() => {
|
|
if (userId == null) {
|
|
return;
|
|
}
|
|
startQueryBroadcast(queryClient, userId);
|
|
}, [queryClient, userId]);
|
|
|
|
const value = useMemo<AuthContextValue>(
|
|
() => ({
|
|
user: sessionQuery.data,
|
|
isAuthenticated: Boolean(sessionQuery.data),
|
|
isLoading: sessionQuery.isLoading,
|
|
error: sessionQuery.error,
|
|
login: (credentials) => loginMutation.mutate(credentials),
|
|
logout: () => logoutMutation.mutate(),
|
|
changePassword: (data) => changePasswordMutation.mutate(data),
|
|
isLoggingIn: loginMutation.isPending,
|
|
isLoggingOut: logoutMutation.isPending,
|
|
isChangingPassword: changePasswordMutation.isPending,
|
|
loginError: loginMutation.error,
|
|
}),
|
|
[
|
|
sessionQuery.data,
|
|
sessionQuery.isLoading,
|
|
sessionQuery.error,
|
|
loginMutation,
|
|
logoutMutation,
|
|
changePasswordMutation,
|
|
],
|
|
);
|
|
|
|
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
|
|
}
|