Skip to content

Commit

Permalink
fix: data loading when the user goes back
Browse files Browse the repository at this point in the history
  • Loading branch information
MailineN committed Apr 16, 2024
1 parent 2fe27e1 commit 44aaba0
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ const DataCollectionDetails = () => {
]);
const navigate = useNavigate();
const { idDataCollection } = useParams();
const [dataCollection, setDataCollection] = useState<DataCollection>(
{} as DataCollection
);
const [dataCollection, setDataCollection] = useState<DataCollection>();
const [dataCollectionState, setDataCollectionState] =
useState<DataCollection>({} as DataCollection);
useState<DataCollection>();
const [openDelete, setOpenDelete] = useState(false);
const [openSave, setOpenSave] = useState(false);
const [openPublish, setOpenPublish] = useState(false);
Expand All @@ -62,12 +60,14 @@ const DataCollectionDetails = () => {
queryKey: ["dataCollection", idDataCollection],
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
queryFn: () => getDataCollection(idDataCollection),
refetchOnMount: true,
onSuccess: (data: DataCollectionApi) => {
const parsedData = parseUserAttributeFromDataCollectionApi(data);
setDataCollectionState(parsedData.json);
setDataCollection(parsedData.json);
},
refetchOnWindowFocus: true,
cacheTime: 1000 * 60 * 30,
},
{
queryKey: ["allQuestionnaires"],
Expand Down Expand Up @@ -233,7 +233,7 @@ const DataCollectionDetails = () => {
</Main>
);
}
if (dataCollectionQuery.isSuccess) {
if (dataCollection) {
return (
<Main sx={{ justifyContent: "flex-start" }}>
<DataCollectionDisplay
Expand Down

0 comments on commit 44aaba0

Please sign in to comment.