Merge remote-tracking branch 'upstream/dev' into feat/human-in-the-loop

This commit is contained in:
Anish Sarkar 2026-03-21 13:17:24 +05:30
commit 77cc2af14f
30 changed files with 4975 additions and 1162 deletions

View file

@ -1,18 +1,18 @@
import { atomWithMutation, queryClientAtom } from "jotai-tanstack-query";
import type { UpdateUserRequest } from "@/contracts/types/user.types";
import { userApiService } from "@/lib/apis/user-api.service";
import { cacheKeys } from "@/lib/query-client/cache-keys";
import { USER_QUERY_KEY } from "./user-query.atoms";
export const updateUserMutationAtom = atomWithMutation((get) => {
const queryClient = get(queryClientAtom);
return {
mutationKey: cacheKeys.user.current(),
mutationKey: USER_QUERY_KEY,
mutationFn: async (request: UpdateUserRequest) => {
return userApiService.updateMe(request);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: cacheKeys.user.current() });
queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
},
};
});

View file

@ -1,14 +1,16 @@
import { atomWithQuery } from "jotai-tanstack-query";
import { userApiService } from "@/lib/apis/user-api.service";
import { getBearerToken, isPublicRoute } from "@/lib/auth-utils";
import { cacheKeys } from "@/lib/query-client/cache-keys";
export const USER_QUERY_KEY = ["user", "me"] as const;
const userQueryFn = () => userApiService.getMe();
export const currentUserAtom = atomWithQuery(() => {
const pathname = typeof window !== "undefined" ? window.location.pathname : null;
return {
queryKey: cacheKeys.user.current(),
staleTime: 5 * 60 * 1000, // 5 minutes
queryKey: USER_QUERY_KEY,
staleTime: 5 * 60 * 1000,
enabled: !!getBearerToken() && pathname !== null && !isPublicRoute(pathname),
queryFn: async () => userApiService.getMe(),
queryFn: userQueryFn,
};
});