birthday through qr, deleteFam function

This commit is contained in:
ivic00
2025-02-12 00:05:39 +01:00
parent 6ada9470c3
commit a8957c7ac7
6 changed files with 247 additions and 196 deletions

View File

@ -26,11 +26,13 @@ import { useDeleteUser } from "@/hooks/firebase/useDeleteUser";
import { useUpdateHouseholdName } from "@/hooks/firebase/useUpdateHouseholdName";
import { useGetHouseholdName } from "@/hooks/firebase/useGetHouseholdName";
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers";
import { useDeleteFamily } from "@/hooks/firebase/useDeleteFamily";
const MyProfile = () => {
const { user, profileData } = useAuthContext();
const { data: familyMembers } = useGetFamilyMembers();
const [takenColors, setTakenColors] = useState<string[]>([]);
const { mutate: deleteFamily, isLoading } = useDeleteFamily();
const { data: hhName, refetch: refetchHHName } = useGetHouseholdName(
profileData.familyId
@ -181,6 +183,19 @@ const MyProfile = () => {
debouncedUpdateUserData(color);
};
const handleDeleteFamily = () => {
if(profileData?.familyId){
deleteFamily({familyId: profileData?.familyId}, {
onSuccess: () => {
},
onError: (error) => {
console.log("from delete fam:\n" + error);
}
})
}
}
const debouncedUpdateUserData = useCallback(
debounce(async (color: string) => {
try {
@ -568,7 +583,8 @@ const MyProfile = () => {
onDismiss={handleHideDeleteDialog}
onConfirm={() => {
if(isDeleteFamily)
console.log('put delete family func here');
//deletes family
handleDeleteFamily();
else
{
//deletes profile