MCPcopy Create free account
hub / github.com/dailydotdev/apps / useRemoveExperience

Function useRemoveExperience

packages/shared/src/hooks/useRemoveExperience.ts:14–46  ·  view source on GitHub ↗
({ type }: { type: UserExperienceType })

Source from the content-addressed store, hash-verified

12import { LogEvent } from '../lib/log';
13
14const useRemoveExperience = ({ type }: { type: UserExperienceType }) => {
15 const { user } = useAuthContext();
16 const { logEvent } = useLogContext();
17 const router = useRouter();
18 const { displayToast } = useToastNotification();
19 const userId = user?.id ?? '';
20 const { queryKey: experienceQueryKey } = useUserExperiencesByType(
21 type,
22 userId,
23 );
24 const qc = useQueryClient();
25 const { mutate, isPending } = useMutation({
26 mutationFn: (id: string) => removeUserExperience(id),
27 onSuccess: (_, id) => {
28 logEvent({
29 event_name: LogEvent.RemoveExperience,
30 target_type: type,
31 target_id: id,
32 });
33 router.push(`${webappUrl}settings/profile/experience/${type}`);
34 qc.invalidateQueries({ queryKey: experienceQueryKey });
35 qc.invalidateQueries({
36 queryKey: generateQueryKey(RequestKey.UserExperience, user, 'profile'),
37 exact: false,
38 });
39 },
40 onError: () => {
41 displayToast(labels.error.generic || 'Failed to delete experience');
42 },
43 });
44
45 return { removeExperience: mutate, isPending };
46};
47
48export default useRemoveExperience;

Callers 1

DeleteExperienceButtonFunction · 0.85

Calls 10

useAuthContextFunction · 0.90
useLogContextFunction · 0.90
useToastNotificationFunction · 0.90
useUserExperiencesByTypeFunction · 0.90
removeUserExperienceFunction · 0.90
generateQueryKeyFunction · 0.90
logEventFunction · 0.85
displayToastFunction · 0.85
pushMethod · 0.80
useRouterFunction · 0.50

Tested by

no test coverage detected