Squash merge feat/expo-app: app-expo, .cursor, workflows, package.json, .husky; remove app-android, app-ios, react-app

This commit is contained in:
Kevin
2026-03-19 01:12:17 +08:00
parent 9e4f301ab9
commit b4f4369b7d
544 changed files with 23707 additions and 67151 deletions

View File

@@ -0,0 +1,93 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { profileApi } from './api';
import type {
LegalDocType,
SubmitFeedbackRequest,
UpdateProfileRequest,
} from './types';
const profileKeys = {
all: ['profile'] as const,
detail: () => [...profileKeys.all, 'detail'] as const,
plans: () => [...profileKeys.all, 'plans'] as const,
currentPlan: () => [...profileKeys.all, 'current-plan'] as const,
quota: () => [...profileKeys.all, 'quota'] as const,
faqs: () => [...profileKeys.all, 'faqs'] as const,
legal: (type: LegalDocType) => [...profileKeys.all, 'legal', type] as const,
} as const;
// ─── Profile ───
export function useProfile() {
return useQuery({
queryKey: profileKeys.detail(),
queryFn: () => profileApi.fetchProfile(),
});
}
export function useUpdateProfile() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (body: UpdateProfileRequest) => profileApi.updateProfile(body),
onSuccess: (data) => {
queryClient.setQueryData(profileKeys.detail(), data);
},
});
}
// ─── Plans ───
export function usePlans() {
return useQuery({
queryKey: profileKeys.plans(),
queryFn: () => profileApi.fetchPlans(),
staleTime: 10 * 60 * 1000,
});
}
export function useCurrentPlan() {
return useQuery({
queryKey: profileKeys.currentPlan(),
queryFn: () => profileApi.fetchCurrentPlan(),
});
}
// ─── Quota ───
export function useQuota() {
return useQuery({
queryKey: profileKeys.quota(),
queryFn: () => profileApi.checkQuota(),
});
}
// ─── FAQ ───
export function useFaqs() {
return useQuery({
queryKey: profileKeys.faqs(),
queryFn: () => profileApi.fetchFaqs(),
staleTime: 30 * 60 * 1000,
});
}
// ─── Feedback ───
export function useSubmitFeedback() {
return useMutation({
mutationFn: (body: SubmitFeedbackRequest) =>
profileApi.submitFeedback(body),
});
}
// ─── Legal ───
export function useLegalDoc(type: LegalDocType) {
return useQuery({
queryKey: profileKeys.legal(type),
queryFn: () => profileApi.fetchLegalDoc(type),
staleTime: Infinity,
});
}