@greatapps/common 1.1.477 → 1.1.479
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +3 -1
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -1
- package/dist/hooks/useAuthQueryKey.mjs +23 -0
- package/dist/hooks/useAuthQueryKey.mjs.map +1 -0
- package/dist/index.mjs +17 -2
- package/dist/index.mjs.map +1 -1
- package/dist/modules/accounts/hooks/current-account.hook.mjs +5 -2
- package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useAccountManagement.mjs +19 -9
- package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useCurrencies.mjs +3 -1
- package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useTimezones.mjs +3 -1
- package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -1
- package/dist/modules/auth/hooks/useUserQuery.mjs +15 -6
- package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -1
- package/dist/modules/cards/hooks/cards.hook.mjs +3 -1
- package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -1
- package/dist/modules/cards/hooks/create-card.hook.mjs +3 -1
- package/dist/modules/cards/hooks/create-card.hook.mjs.map +1 -1
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +3 -1
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -1
- package/dist/modules/plans/hooks/list-plans.hook.mjs +3 -1
- package/dist/modules/plans/hooks/list-plans.hook.mjs.map +1 -1
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs +4 -2
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -1
- package/dist/modules/plans/services/plans.service.mjs +4 -2
- package/dist/modules/plans/services/plans.service.mjs.map +1 -1
- package/dist/modules/projects/hooks/add-project-user.hook.mjs +15 -12
- package/dist/modules/projects/hooks/add-project-user.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +3 -1
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs +3 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-project-users.hook.mjs +3 -1
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs +15 -12
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/constants/query-keys.constants.mjs +2 -0
- package/dist/modules/subscriptions/constants/query-keys.constants.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +3 -1
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +3 -1
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs +6 -3
- package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs.map +1 -1
- package/dist/modules/users/hooks/messages.hook.mjs +9 -4
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -1
- package/dist/providers/auth.provider.mjs +6 -4
- package/dist/providers/auth.provider.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/account/hooks/useDisableTwoFactorAuthForm.tsx +3 -1
- package/src/hooks/useAuthQueryKey.ts +32 -0
- package/src/index.ts +10 -1
- package/src/modules/accounts/hooks/current-account.hook.tsx +7 -3
- package/src/modules/accounts/hooks/useAccountManagement.ts +20 -11
- package/src/modules/accounts/hooks/useCurrencies.ts +5 -2
- package/src/modules/accounts/hooks/useTimezones.ts +5 -2
- package/src/modules/auth/hooks/useUserQuery.ts +75 -65
- package/src/modules/cards/hooks/cards.hook.ts +5 -2
- package/src/modules/cards/hooks/create-card.hook.ts +3 -1
- package/src/modules/ia-credits/hooks/ia-credits.hook.ts +99 -97
- package/src/modules/plans/hooks/list-plans.hook.ts +5 -2
- package/src/modules/plans/hooks/use-plan-by-id.hook.ts +4 -2
- package/src/modules/plans/services/plans.service.ts +4 -2
- package/src/modules/projects/hooks/add-project-user.hook.ts +16 -13
- package/src/modules/projects/hooks/list-all-account-users.hook.ts +8 -3
- package/src/modules/projects/hooks/list-available-users.hook.ts +8 -3
- package/src/modules/projects/hooks/list-project-users.hook.ts +8 -3
- package/src/modules/projects/hooks/remove-project-user.hook.ts +16 -13
- package/src/modules/subscriptions/constants/query-keys.constants.ts +3 -1
- package/src/modules/subscriptions/hooks/find-active-subscription.hook.ts +4 -1
- package/src/modules/subscriptions/hooks/list-subscriptions.hook.ts +4 -1
- package/src/modules/subscriptions/hooks/update-subscription-plan.hook.ts +6 -3
- package/src/modules/users/hooks/messages.hook.ts +12 -5
- package/src/providers/auth.provider.tsx +162 -160
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/users/hooks/messages.hook.ts"],"sourcesContent":["'use client';\n\nimport { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { listMessagesAction } from '../action/list-messages.action';\nimport { markMessageAsReadAction } from '../action/mark-message-as-read.action';\nimport { markAllMessagesAsReadAction } from '../action/mark-all-messages-as-read.action';\nimport { withAction } from '../../../utils/withAction';\nimport type { FindMessagesParams } from '../schema/messages.schema';\n\nexport const MESSAGES_QUERY_KEY = ['messages'];\n\nconst INFINITE_MESSAGES_PAGE_SIZE = 10;\n\nexport function useMessages(params?: Partial<FindMessagesParams>) {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/users/hooks/messages.hook.ts"],"sourcesContent":["'use client';\n\nimport { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { listMessagesAction } from '../action/list-messages.action';\nimport { markMessageAsReadAction } from '../action/mark-message-as-read.action';\nimport { markAllMessagesAsReadAction } from '../action/mark-all-messages-as-read.action';\nimport { withAction } from '../../../utils/withAction';\nimport type { FindMessagesParams } from '../schema/messages.schema';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\n\nexport const MESSAGES_QUERY_KEY = ['messages'] as const;\n\nconst INFINITE_MESSAGES_PAGE_SIZE = 10;\n\nexport function useMessages(params?: Partial<FindMessagesParams>) {\n const queryKey = useAuthQueryKey([...MESSAGES_QUERY_KEY, params]);\n\n return useQuery({\n queryKey,\n queryFn: withAction(() => listMessagesAction(params)),\n });\n}\n\nexport function useInfiniteMessages(params?: Partial<Omit<FindMessagesParams, 'page' | 'limit'>>) {\n const queryKey = useAuthQueryKey([...MESSAGES_QUERY_KEY, 'infinite', params]);\n\n return useInfiniteQuery({\n queryKey,\n queryFn: ({ pageParam }) =>\n withAction(() =>\n listMessagesAction({\n ...params,\n page: pageParam as number,\n limit: INFINITE_MESSAGES_PAGE_SIZE,\n })\n )(),\n getNextPageParam: (lastPage, allPages) => {\n const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);\n return loaded < lastPage.total ? allPages.length + 1 : undefined;\n },\n initialPageParam: 1,\n });\n}\n\nexport function useMarkMessageAsRead() {\n const queryClient = useQueryClient();\n const messagesKey = useAuthQueryKey([...MESSAGES_QUERY_KEY]);\n\n return useMutation({\n mutationFn: withAction(markMessageAsReadAction),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: messagesKey });\n },\n });\n}\n\nexport function useMarkAllMessagesAsRead() {\n const queryClient = useQueryClient();\n const messagesKey = useAuthQueryKey([...MESSAGES_QUERY_KEY]);\n\n return useMutation({\n mutationFn: withAction(markAllMessagesAsReadAction),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: messagesKey });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,kBAAkB,aAAa,UAAU,sBAAsB;AACxE,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AACxC,SAAS,mCAAmC;AAC5C,SAAS,kBAAkB;AAE3B,SAAS,uBAAuB;AAEzB,MAAM,qBAAqB,CAAC,UAAU;AAE7C,MAAM,8BAA8B;AAE7B,SAAS,YAAY,QAAsC;AAChE,QAAM,WAAW,gBAAgB,CAAC,GAAG,oBAAoB,MAAM,CAAC;AAEhE,SAAO,SAAS;AAAA,IACd;AAAA,IACA,SAAS,WAAW,MAAM,mBAAmB,MAAM,CAAC;AAAA,EACtD,CAAC;AACH;AAEO,SAAS,oBAAoB,QAA8D;AAChG,QAAM,WAAW,gBAAgB,CAAC,GAAG,oBAAoB,YAAY,MAAM,CAAC;AAE5E,SAAO,iBAAiB;AAAA,IACtB;AAAA,IACA,SAAS,CAAC,EAAE,UAAU,MACpB;AAAA,MAAW,MACT,mBAAmB;AAAA,QACjB,GAAG;AAAA,QACH,MAAM;AAAA,QACN,OAAO;AAAA,MACT,CAAC;AAAA,IACH,EAAE;AAAA,IACJ,kBAAkB,CAAC,UAAU,aAAa;AACxC,YAAM,SAAS,SAAS,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,KAAK,QAAQ,CAAC;AACjE,aAAO,SAAS,SAAS,QAAQ,SAAS,SAAS,IAAI;AAAA,IACzD;AAAA,IACA,kBAAkB;AAAA,EACpB,CAAC;AACH;AAEO,SAAS,uBAAuB;AACrC,QAAM,cAAc,eAAe;AACnC,QAAM,cAAc,gBAAgB,CAAC,GAAG,kBAAkB,CAAC;AAE3D,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,uBAAuB;AAAA,IAC9C,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,YAAY,CAAC;AAAA,IACzD;AAAA,EACF,CAAC;AACH;AAEO,SAAS,2BAA2B;AACzC,QAAM,cAAc,eAAe;AACnC,QAAM,cAAc,gBAAgB,CAAC,GAAG,kBAAkB,CAAC;AAE3D,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,2BAA2B;AAAA,IAClD,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,YAAY,CAAC;AAAA,IACzD;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
ACCOUNT_QUERY_KEY
|
|
21
21
|
} from "../modules/accounts/hooks/current-account.hook";
|
|
22
22
|
import { useWhitelabelUrls } from "./whitelabel.provider";
|
|
23
|
+
import { useWlQueryKey } from "../hooks/useAuthQueryKey";
|
|
23
24
|
const AuthContext = createContext(
|
|
24
25
|
void 0
|
|
25
26
|
);
|
|
@@ -30,6 +31,7 @@ function AuthProvider({ children }) {
|
|
|
30
31
|
const queryClient = useQueryClient();
|
|
31
32
|
const setUserData = useSetUserData();
|
|
32
33
|
const { accountsUrl, pagesUrl } = useWhitelabelUrls();
|
|
34
|
+
const accountKey = useWlQueryKey([...ACCOUNT_QUERY_KEY]);
|
|
33
35
|
const { mutateAsync: loginMutate, isPending: isLogging } = useLogin();
|
|
34
36
|
const { mutateAsync: registerMutate, isPending: isRegistering } = useRegister();
|
|
35
37
|
const { mutateAsync: logoutMutate, isPending: isLoggingOut } = useLogout();
|
|
@@ -44,14 +46,14 @@ function AuthProvider({ children }) {
|
|
|
44
46
|
}
|
|
45
47
|
queryClient.clear();
|
|
46
48
|
setUserData(data.user);
|
|
47
|
-
queryClient.setQueryData(
|
|
49
|
+
queryClient.setQueryData(accountKey, data.account);
|
|
48
50
|
return { result: "success" };
|
|
49
51
|
} catch (error) {
|
|
50
52
|
const message = error instanceof Error ? error.message : "Ocorreu um erro ao fazer login. Tente novamente.";
|
|
51
53
|
return { result: "error", message };
|
|
52
54
|
}
|
|
53
55
|
},
|
|
54
|
-
[queryClient, setUserData]
|
|
56
|
+
[queryClient, setUserData, accountKey]
|
|
55
57
|
);
|
|
56
58
|
const register = useCallback(
|
|
57
59
|
async (data) => {
|
|
@@ -59,11 +61,11 @@ function AuthProvider({ children }) {
|
|
|
59
61
|
onSuccess: (data2) => {
|
|
60
62
|
queryClient.clear();
|
|
61
63
|
setUserData(data2.user);
|
|
62
|
-
queryClient.setQueryData(
|
|
64
|
+
queryClient.setQueryData(accountKey, data2.account);
|
|
63
65
|
}
|
|
64
66
|
});
|
|
65
67
|
},
|
|
66
|
-
[queryClient, setUserData]
|
|
68
|
+
[queryClient, setUserData, accountKey]
|
|
67
69
|
);
|
|
68
70
|
const resolveLogoutRedirect = useCallback(() => {
|
|
69
71
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/auth.provider.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"sources":["../../src/providers/auth.provider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n} from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n useUserQuery,\n useSetUserData,\n useUserValidateSession,\n} from \"../modules/auth/hooks/useUserQuery\";\nimport { useLogin } from \"../modules/auth/hooks/login.hook\";\nimport { useRegister } from \"../modules/auth/hooks/register.hook\";\nimport { useLogout } from \"../modules/auth/hooks/logout.hook\";\nimport {\n AuthState,\n LoginRequest,\n RegisterRequest,\n} from \"../modules/auth/schema\";\n\nexport type LoginResult =\n | { result: \"success\" }\n | { result: \"two_factor_required\"; cookie: string; twoFactorMode: \"verify\" | \"setup\" }\n | { result: \"error\"; message: string };\nimport {\n useCurrentAccount,\n ACCOUNT_QUERY_KEY,\n} from \"../modules/accounts/hooks/current-account.hook\";\nimport { useWhitelabelUrls } from \"./whitelabel.provider\";\nimport { useWlQueryKey } from \"../hooks/useAuthQueryKey\";\n\ninterface AuthContextProps extends AuthState {\n login: (credentials: LoginRequest) => Promise<LoginResult>;\n register: (data: RegisterRequest) => Promise<void>;\n logout: () => Promise<void>;\n}\n\nexport const AuthContext = createContext<AuthContextProps | undefined>(\n undefined,\n);\n\ninterface AuthProviderProps {\n children: ReactNode;\n}\n\nexport function AuthProvider({ children }: AuthProviderProps) {\n const { data: user, isLoading: isQueryLoading } = useUserQuery();\n const { data: account, isLoading: isAccountLoading } = useCurrentAccount();\n const { isLoading: isSessionLoading } = useUserValidateSession();\n\n const queryClient = useQueryClient();\n const setUserData = useSetUserData();\n const { accountsUrl, pagesUrl } = useWhitelabelUrls();\n const accountKey = useWlQueryKey([...ACCOUNT_QUERY_KEY]);\n\n const { mutateAsync: loginMutate, isPending: isLogging } = useLogin();\n const { mutateAsync: registerMutate, isPending: isRegistering } =\n useRegister();\n const { mutateAsync: logoutMutate, isPending: isLoggingOut } = useLogout();\n\n const isAuthenticated = !!user;\n const isLoading =\n isLogging ||\n isRegistering ||\n isLoggingOut ||\n isQueryLoading ||\n isAccountLoading ||\n isSessionLoading;\n\n const login = useCallback(\n async (credentials: LoginRequest): Promise<LoginResult> => {\n try {\n const data = await loginMutate(credentials);\n\n if (data.result === \"two_factor_required\") {\n return { result: \"two_factor_required\", cookie: data.cookie, twoFactorMode: data.twoFactorMode };\n }\n\n queryClient.clear();\n setUserData(data.user);\n queryClient.setQueryData(accountKey, data.account);\n\n return { result: \"success\" };\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : \"Ocorreu um erro ao fazer login. Tente novamente.\";\n return { result: \"error\", message };\n }\n },\n [queryClient, setUserData, accountKey],\n );\n\n const register = useCallback(\n async (data: RegisterRequest): Promise<void> => {\n await registerMutate(data, {\n onSuccess: (data) => {\n queryClient.clear();\n setUserData(data.user);\n queryClient.setQueryData(accountKey, data.account);\n },\n });\n },\n [queryClient, setUserData, accountKey],\n );\n\n const resolveLogoutRedirect = useCallback(() => {\n try {\n const currentOrigin = window.location.origin;\n const pagesOrigin = pagesUrl ? new URL(pagesUrl).origin : \"\";\n\n if (pagesOrigin && currentOrigin === pagesOrigin) {\n return `${accountsUrl}/login?redirect=${encodeURIComponent(pagesUrl)}`;\n }\n } catch {\n // fallback below\n }\n\n return `${accountsUrl}/login?redirect=${encodeURIComponent(pagesUrl || \"/\")}`;\n }, [accountsUrl, pagesUrl]);\n\n const logout = useCallback(async (): Promise<void> => {\n try {\n await logoutMutate(undefined);\n } catch {\n // cookie já removido no servidor mesmo se a API falhou\n } finally {\n queryClient.clear();\n window.location.assign(resolveLogoutRedirect());\n }\n }, [queryClient, logoutMutate, resolveLogoutRedirect]);\n\n const value: AuthContextProps = useMemo(\n () => ({\n user: user ?? null,\n account: account ?? null,\n isAuthenticated,\n isLoading,\n login,\n register,\n logout,\n }),\n [user, account, isAuthenticated, isLoading, login, register, logout],\n );\n\n return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;\n}\n\nexport function useAuth(): AuthContextProps {\n const context = useContext(AuthContext);\n\n if (context === undefined) {\n throw new Error(\"useAuth deve ser usado dentro de um AuthProvider\");\n }\n\n return context;\n}\n"],"mappings":"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","names":["data"]}
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import { toast } from 'sonner';
|
|
|
6
6
|
import { Toast } from '../../ui/feedback/Toast';
|
|
7
7
|
import { USER_QUERY_KEY } from '../../../modules/auth/hooks/useUserQuery';
|
|
8
8
|
import { disableTwoFactorAction } from '../../../modules/accounts/actions/account-management.action';
|
|
9
|
+
import { useWlQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
9
10
|
|
|
10
11
|
interface UseDisableTwoFactorAuthFormProps {
|
|
11
12
|
onClose: () => void;
|
|
@@ -18,6 +19,7 @@ export default function useDisableTwoFactorAuthForm({
|
|
|
18
19
|
}: UseDisableTwoFactorAuthFormProps) {
|
|
19
20
|
const [code, setCode] = useState('');
|
|
20
21
|
const queryClient = useQueryClient();
|
|
22
|
+
const userKey = useWlQueryKey([...USER_QUERY_KEY]);
|
|
21
23
|
|
|
22
24
|
const isValid = code.length === 6;
|
|
23
25
|
|
|
@@ -31,7 +33,7 @@ export default function useDisableTwoFactorAuthForm({
|
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
queryClient.invalidateQueries({ queryKey:
|
|
36
|
+
queryClient.invalidateQueries({ queryKey: userKey });
|
|
35
37
|
toast.custom((t) => (
|
|
36
38
|
<Toast variant="success" message="Autenticação de dois fatores desabilitada" toastId={t} />
|
|
37
39
|
));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useAuth } from '../providers/auth.provider';
|
|
4
|
+
import { useWhitelabel } from '../providers/whitelabel.provider';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Retorna o id da whitelabel do contexto.
|
|
8
|
+
*/
|
|
9
|
+
export function useWlId(): number {
|
|
10
|
+
const { whitelabel } = useWhitelabel();
|
|
11
|
+
return whitelabel?.id ?? 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Prefixa query keys com ['whitelabel', wlId] para isolamento por whitelabel.
|
|
16
|
+
* Usar para queries públicas e bootstrap (plans, currencies, user, account, etc).
|
|
17
|
+
*/
|
|
18
|
+
export function useWlQueryKey<T extends readonly unknown[]>(baseKey: [...T]): ['whitelabel', number, ...T] {
|
|
19
|
+
const wlId = useWlId();
|
|
20
|
+
return ['whitelabel', wlId, ...baseKey];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Prefixa query keys com ['whitelabel', wlId, 'user', userId] para isolamento
|
|
25
|
+
* por whitelabel + usuário. Usar para queries autenticadas (cards, subscriptions, etc).
|
|
26
|
+
*/
|
|
27
|
+
export function useAuthQueryKey<T extends readonly unknown[]>(baseKey: [...T]): ['whitelabel', number, 'user', number, ...T] {
|
|
28
|
+
const wlId = useWlId();
|
|
29
|
+
const { user } = useAuth();
|
|
30
|
+
const userId = user?.id ?? 0;
|
|
31
|
+
return ['whitelabel', wlId, 'user', userId, ...baseKey];
|
|
32
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,11 @@ export {
|
|
|
21
21
|
LIST_AVAILABLE_USERS_QUERY_KEY,
|
|
22
22
|
LIST_AVAILABLE_USERS_BASE_KEY,
|
|
23
23
|
} from "./modules/projects/hooks/list-available-users.hook";
|
|
24
|
+
export {
|
|
25
|
+
useListAllAccountUsers,
|
|
26
|
+
LIST_ALL_ACCOUNT_USERS_QUERY_KEY,
|
|
27
|
+
LIST_ALL_ACCOUNT_USERS_BASE_KEY,
|
|
28
|
+
} from "./modules/projects/hooks/list-all-account-users.hook";
|
|
24
29
|
export type {
|
|
25
30
|
ProjectUser,
|
|
26
31
|
AccountUser,
|
|
@@ -39,7 +44,7 @@ export {
|
|
|
39
44
|
export { useManagementPermissions } from "./modules/auth/hooks/useManagementPermissions";
|
|
40
45
|
export type { ManagementPermission } from "./modules/auth/types/management-permission.type";
|
|
41
46
|
export { useSubscriptions } from "./modules/subscriptions/hooks/list-subscriptions.hook";
|
|
42
|
-
export { SUBSCRIPTIONS_QUERY_KEY } from "./modules/subscriptions/constants/query-keys.constants";
|
|
47
|
+
export { SUBSCRIPTIONS_QUERY_KEY, CHARGES_QUERY_KEY } from "./modules/subscriptions/constants/query-keys.constants";
|
|
43
48
|
export { useActiveSubscription } from "./modules/subscriptions/hooks/find-active-subscription.hook";
|
|
44
49
|
export { useCancelledSubscriptionGuard } from "./modules/subscriptions/hooks/use-cancelled-subscription-guard";
|
|
45
50
|
export { usePlanById } from "./modules/plans/hooks/use-plan-by-id.hook";
|
|
@@ -151,6 +156,9 @@ export type { NavItemConfig } from './components/navigation/subcomponents/NavIte
|
|
|
151
156
|
export type { NavigationProject } from './components/navigation/types';
|
|
152
157
|
export { useMobileNavbarSheet } from './store/useMobileNavbarSheet';
|
|
153
158
|
|
|
159
|
+
// Auth Query Key Utilities
|
|
160
|
+
export { useAuthQueryKey, useWlQueryKey, useWlId } from "./hooks/useAuthQueryKey";
|
|
161
|
+
|
|
154
162
|
// Hooks
|
|
155
163
|
export { default as useCopyToClipboard } from "./hooks/copy-to-clipboard.hook";
|
|
156
164
|
|
|
@@ -354,6 +362,7 @@ export {
|
|
|
354
362
|
useUpdateAccountUserById,
|
|
355
363
|
useDeleteAccountUser,
|
|
356
364
|
useDeleteAccount,
|
|
365
|
+
ACCOUNT_USERS_QUERY_KEY,
|
|
357
366
|
} from "./modules/accounts/hooks/useAccountManagement";
|
|
358
367
|
export { useViaCep } from "./modules/accounts/hooks/useViaCep";
|
|
359
368
|
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
4
|
import { findCurrentAccount } from '../actions/find-current-account.action';
|
|
5
5
|
import { withAction } from '../../../utils/withAction';
|
|
6
|
+
import { useWlQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
6
7
|
|
|
7
|
-
export const ACCOUNT_QUERY_KEY = ['account'];
|
|
8
|
+
export const ACCOUNT_QUERY_KEY = ['account'] as const;
|
|
8
9
|
|
|
9
10
|
export function useCurrentAccount() {
|
|
11
|
+
const queryKey = useWlQueryKey([...ACCOUNT_QUERY_KEY]);
|
|
12
|
+
|
|
10
13
|
return useQuery({
|
|
11
|
-
queryKey
|
|
14
|
+
queryKey,
|
|
12
15
|
queryFn: withAction(findCurrentAccount),
|
|
13
16
|
staleTime: 0,
|
|
14
17
|
gcTime: 10 * 60 * 1000,
|
|
@@ -18,5 +21,6 @@ export function useCurrentAccount() {
|
|
|
18
21
|
|
|
19
22
|
export function useInvalidateAccount() {
|
|
20
23
|
const queryClient = useQueryClient();
|
|
21
|
-
|
|
24
|
+
const accountKey = useWlQueryKey([...ACCOUNT_QUERY_KEY]);
|
|
25
|
+
return () => queryClient.invalidateQueries({ queryKey: accountKey });
|
|
22
26
|
}
|
|
@@ -18,44 +18,52 @@ import {
|
|
|
18
18
|
} from '../actions/account-management.action';
|
|
19
19
|
import { withAction } from '../../../utils/withAction';
|
|
20
20
|
import type { UseMutationOptions } from '@tanstack/react-query';
|
|
21
|
+
import { useAuthQueryKey, useWlQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
21
22
|
|
|
22
|
-
const ACCOUNT_USERS_QUERY_KEY = ['account-users'];
|
|
23
|
+
export const ACCOUNT_USERS_QUERY_KEY = ['account-users'] as const;
|
|
23
24
|
|
|
24
25
|
export function useUpdateAccount() {
|
|
25
26
|
const queryClient = useQueryClient();
|
|
27
|
+
const accountUsersKey = useAuthQueryKey([...ACCOUNT_USERS_QUERY_KEY]);
|
|
28
|
+
const accountKey = useWlQueryKey([...ACCOUNT_QUERY_KEY]);
|
|
29
|
+
const userKey = useWlQueryKey([...USER_QUERY_KEY]);
|
|
26
30
|
|
|
27
31
|
return useMutation({
|
|
28
32
|
mutationFn: withAction(updateAccountAction),
|
|
29
33
|
onSuccess: () => {
|
|
30
|
-
queryClient.invalidateQueries({ queryKey:
|
|
31
|
-
queryClient.invalidateQueries({ queryKey:
|
|
32
|
-
queryClient.invalidateQueries({ queryKey:
|
|
34
|
+
queryClient.invalidateQueries({ queryKey: accountUsersKey });
|
|
35
|
+
queryClient.invalidateQueries({ queryKey: accountKey });
|
|
36
|
+
queryClient.invalidateQueries({ queryKey: userKey });
|
|
33
37
|
},
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
export function useUpdateAccountUser() {
|
|
38
42
|
const queryClient = useQueryClient();
|
|
43
|
+
const accountUsersKey = useAuthQueryKey([...ACCOUNT_USERS_QUERY_KEY]);
|
|
44
|
+
const accountKey = useWlQueryKey([...ACCOUNT_QUERY_KEY]);
|
|
45
|
+
const userKey = useWlQueryKey([...USER_QUERY_KEY]);
|
|
39
46
|
|
|
40
47
|
return useMutation({
|
|
41
48
|
mutationFn: withAction(updateUserAction),
|
|
42
49
|
onSuccess: () => {
|
|
43
|
-
queryClient.invalidateQueries({ queryKey:
|
|
44
|
-
queryClient.invalidateQueries({ queryKey:
|
|
45
|
-
queryClient.invalidateQueries({ queryKey:
|
|
50
|
+
queryClient.invalidateQueries({ queryKey: accountUsersKey });
|
|
51
|
+
queryClient.invalidateQueries({ queryKey: accountKey });
|
|
52
|
+
queryClient.invalidateQueries({ queryKey: userKey });
|
|
46
53
|
},
|
|
47
54
|
});
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
export function useUpdateAccountUserById() {
|
|
51
58
|
const queryClient = useQueryClient();
|
|
59
|
+
const accountUsersKey = useAuthQueryKey([...ACCOUNT_USERS_QUERY_KEY]);
|
|
52
60
|
|
|
53
61
|
return useMutation({
|
|
54
|
-
mutationFn: withAction(({ userId, ...user }: UpdateAccountUserRequest & { userId: number }) =>
|
|
55
|
-
updateAccountUserByIdAction(
|
|
62
|
+
mutationFn: withAction(({ userId: targetUserId, ...user }: UpdateAccountUserRequest & { userId: number }) =>
|
|
63
|
+
updateAccountUserByIdAction(targetUserId, user)
|
|
56
64
|
),
|
|
57
65
|
onSuccess: () => {
|
|
58
|
-
queryClient.invalidateQueries({ queryKey:
|
|
66
|
+
queryClient.invalidateQueries({ queryKey: accountUsersKey });
|
|
59
67
|
},
|
|
60
68
|
});
|
|
61
69
|
}
|
|
@@ -64,13 +72,14 @@ export function useDeleteAccountUser(
|
|
|
64
72
|
options?: UseMutationOptions<DeleteAccountUserResponse, Error, number>
|
|
65
73
|
) {
|
|
66
74
|
const queryClient = useQueryClient();
|
|
75
|
+
const accountUsersKey = useAuthQueryKey([...ACCOUNT_USERS_QUERY_KEY]);
|
|
67
76
|
|
|
68
77
|
return useMutation({
|
|
69
78
|
mutationFn: withAction(deleteAccountUserAction),
|
|
70
79
|
...options,
|
|
71
80
|
onSuccess: (...params) => {
|
|
72
81
|
options?.onSuccess?.(...params);
|
|
73
|
-
queryClient.invalidateQueries({ queryKey:
|
|
82
|
+
queryClient.invalidateQueries({ queryKey: accountUsersKey });
|
|
74
83
|
},
|
|
75
84
|
});
|
|
76
85
|
}
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
import { useQuery } from '@tanstack/react-query';
|
|
4
4
|
import { listCurrenciesAction } from '../actions/list-currencies.action';
|
|
5
5
|
import { withAction } from '../../../utils/withAction';
|
|
6
|
+
import { useWlQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
6
7
|
|
|
7
|
-
export const CURRENCIES_QUERY_KEY = ['currencies'];
|
|
8
|
+
export const CURRENCIES_QUERY_KEY = ['currencies'] as const;
|
|
8
9
|
|
|
9
10
|
export function useCurrencies() {
|
|
11
|
+
const queryKey = useWlQueryKey([...CURRENCIES_QUERY_KEY]);
|
|
12
|
+
|
|
10
13
|
return useQuery({
|
|
11
|
-
queryKey
|
|
14
|
+
queryKey,
|
|
12
15
|
queryFn: withAction(listCurrenciesAction),
|
|
13
16
|
staleTime: Infinity,
|
|
14
17
|
});
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
import { useQuery } from '@tanstack/react-query';
|
|
4
4
|
import { listTimezonesAction } from '../actions/list-timezones.action';
|
|
5
5
|
import { withAction } from '../../../utils/withAction';
|
|
6
|
+
import { useWlQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
6
7
|
|
|
7
|
-
export const TIMEZONES_QUERY_KEY = ['timezones'];
|
|
8
|
+
export const TIMEZONES_QUERY_KEY = ['timezones'] as const;
|
|
8
9
|
|
|
9
10
|
export function useTimezones() {
|
|
11
|
+
const queryKey = useWlQueryKey([...TIMEZONES_QUERY_KEY]);
|
|
12
|
+
|
|
10
13
|
return useQuery({
|
|
11
|
-
queryKey
|
|
14
|
+
queryKey,
|
|
12
15
|
queryFn: withAction(listTimezonesAction),
|
|
13
16
|
staleTime: Infinity,
|
|
14
17
|
});
|
|
@@ -1,65 +1,75 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useMutation, useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query';
|
|
4
|
-
import { User } from '../../users/schema';
|
|
5
|
-
import { withAction } from '../../../utils/withAction';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMutation, useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query';
|
|
4
|
+
import { User } from '../../users/schema';
|
|
5
|
+
import { withAction } from '../../../utils/withAction';
|
|
6
|
+
import { useWlQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
7
|
+
|
|
8
|
+
export const USER_QUERY_KEY = ['user'] as const;
|
|
9
|
+
export const USER_VALIDATE_SESSION_KEY = ['user-validate-session'] as const;
|
|
10
|
+
|
|
11
|
+
async function fetchUser(): Promise<User | null> {
|
|
12
|
+
const { findUserById: getUserDataAction } = await import('../../users/action/find-user-by-id.action');
|
|
13
|
+
const result = await getUserDataAction();
|
|
14
|
+
return result.success && result.data ? result.data : null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function validateUserSession(): Promise<boolean> {
|
|
18
|
+
const { validateSessionAction } = await import('../actions/validate-session.action');
|
|
19
|
+
return await validateSessionAction();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function useUserQuery() {
|
|
23
|
+
const queryKey = useWlQueryKey([...USER_QUERY_KEY]);
|
|
24
|
+
|
|
25
|
+
return useQuery({
|
|
26
|
+
queryKey,
|
|
27
|
+
queryFn: fetchUser,
|
|
28
|
+
staleTime: 5 * 60 * 1000,
|
|
29
|
+
gcTime: 10 * 60 * 1000,
|
|
30
|
+
retry: false,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function useUserValidateSession(options?: UseQueryOptions) {
|
|
35
|
+
const queryKey = useWlQueryKey([...USER_VALIDATE_SESSION_KEY]);
|
|
36
|
+
|
|
37
|
+
return useQuery({
|
|
38
|
+
queryKey,
|
|
39
|
+
queryFn: validateUserSession,
|
|
40
|
+
retry: false,
|
|
41
|
+
staleTime: 5 * 60 * 1000,
|
|
42
|
+
...options,
|
|
43
|
+
refetchOnMount: 'always',
|
|
44
|
+
refetchOnWindowFocus: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function useTwoFactorVerify() {
|
|
49
|
+
const queryClient = useQueryClient();
|
|
50
|
+
const userKey = useWlQueryKey([...USER_QUERY_KEY]);
|
|
51
|
+
const twoFactorKey = useWlQueryKey(['two-factor-pending']);
|
|
52
|
+
|
|
53
|
+
return useMutation({
|
|
54
|
+
mutationFn: async ({ cookie, code, window }: { cookie: string; code: string; window?: number }) => {
|
|
55
|
+
const { verifyTwoFactorAction } = await import('../actions/verify-two-factor.action');
|
|
56
|
+
return withAction(() => verifyTwoFactorAction(cookie, code, window))();
|
|
57
|
+
},
|
|
58
|
+
onSuccess: () => {
|
|
59
|
+
queryClient.invalidateQueries({ queryKey: userKey });
|
|
60
|
+
queryClient.invalidateQueries({ queryKey: twoFactorKey });
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function useInvalidateUser() {
|
|
66
|
+
const queryClient = useQueryClient();
|
|
67
|
+
const userKey = useWlQueryKey([...USER_QUERY_KEY]);
|
|
68
|
+
return () => queryClient.invalidateQueries({ queryKey: userKey });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function useSetUserData() {
|
|
72
|
+
const queryClient = useQueryClient();
|
|
73
|
+
const userKey = useWlQueryKey([...USER_QUERY_KEY]);
|
|
74
|
+
return (user: User | null) => queryClient.setQueryData(userKey, user);
|
|
75
|
+
}
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
import { useQuery } from '@tanstack/react-query';
|
|
4
4
|
import { withAction } from '../../../utils/withAction';
|
|
5
5
|
import { listCardsAction } from '../actions/list-cards.action';
|
|
6
|
+
import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
6
7
|
|
|
7
|
-
export const CARDS_QUERY_KEY = ['cards'];
|
|
8
|
+
export const CARDS_QUERY_KEY = ['cards'] as const;
|
|
8
9
|
|
|
9
10
|
export function useCards() {
|
|
11
|
+
const queryKey = useAuthQueryKey([...CARDS_QUERY_KEY]);
|
|
12
|
+
|
|
10
13
|
return useQuery({
|
|
11
|
-
queryKey
|
|
14
|
+
queryKey,
|
|
12
15
|
queryFn: withAction(listCardsAction),
|
|
13
16
|
});
|
|
14
17
|
}
|
|
@@ -5,14 +5,16 @@ import { withAction } from '../../../utils/withAction';
|
|
|
5
5
|
import { createCardAction } from '../actions/create-card.action';
|
|
6
6
|
import { CreateCardRequest } from '../types';
|
|
7
7
|
import { CARDS_QUERY_KEY } from './cards.hook';
|
|
8
|
+
import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
8
9
|
|
|
9
10
|
export function useCreateCard() {
|
|
10
11
|
const queryClient = useQueryClient();
|
|
12
|
+
const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);
|
|
11
13
|
|
|
12
14
|
return useMutation({
|
|
13
15
|
mutationFn: (data: CreateCardRequest) => withAction(createCardAction)(data),
|
|
14
16
|
onSuccess: () => {
|
|
15
|
-
queryClient.invalidateQueries({ queryKey:
|
|
17
|
+
queryClient.invalidateQueries({ queryKey: cardsKey });
|
|
16
18
|
},
|
|
17
19
|
});
|
|
18
20
|
}
|