Skip to content

Commit

Permalink
fix: refetch task groups after task group creation
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-wasmeier-titanom committed May 20, 2024
1 parent cd151ea commit 3120365
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions frontend/src/screens/create-task-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";

import { zodResolver } from "@hookform/resolvers/zod";
import RNDateTimePicker from "@react-native-community/datetimepicker";
import { useMutation, useQuery } from "@tanstack/react-query";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { Controller, useForm } from "react-hook-form";
import {
Button,
Expand Down Expand Up @@ -66,6 +66,8 @@ export function CreateTaskGroupScreen() {
queryFn: getUsers,
});

const queryClient = useQueryClient();

const [selectedUserIds, setSelectedUserIds] = React.useState<string[]>([]);
const [date, setDate] = React.useState<Date | undefined>(new Date());
const [showDatePicker, setShowDatePicker] = React.useState(false);
Expand All @@ -87,6 +89,7 @@ export function CreateTaskGroupScreen() {
resetForm({ ...defaultValues });
setSelectedUserIds([]);
setDate(new Date());
queryClient.refetchQueries({ queryKey: ["taskGroup"] });
},
onError: (err) => {
console.error(err);
Expand All @@ -99,9 +102,6 @@ export function CreateTaskGroupScreen() {
mutate({
...data,
});

// TODO: refetch taskgroups
// queryClient.refetchQueries({ queryKey: ["tasks"] });
}

if (users === undefined || isLoading) {
Expand Down

0 comments on commit 3120365

Please sign in to comment.