Request get exos

This commit is contained in:
Kilton937342 2022-06-24 19:51:47 +02:00
parent bf62ac718b
commit 58646f7cd9
2 changed files with 9 additions and 3 deletions

View File

@ -70,7 +70,11 @@ class ExerciceAPI(APIView):
userExosListSorted = userExos
if code != 'all' and code != 'pdf' and code != "web":
exo = Exercice.objects.get(id_code=code)
try:
exo = Exercice.objects.get(id_code=code)
except:
exo = None
return Response({'error': "Not found"}, status= status.HTTP_404_NOT_FOUND)
isUser = False
if request.user == exo.author:
isUser = True

View File

@ -29,14 +29,16 @@ export default function ModalCard({ step, onClose, onDelete, tags, queryKey }) {
const alert = useAlert();
const [edit, setEdit] = useState(false);
const queryClient = useQueryClient();
const {
isLoading: isUpdating,
isFetching,
data: step_data,
} = useQuery(
["exo-data", step.id_code],
async () => await getExos(step.id_code),
async () => await getExos(step.id_code).catch(() => {
notificationService.error('Erreur', "Exercice introuvable")
}),
{ initialData: step, refetchOnWindowFocus: !edit }
);
const [selected, setSelected] = useState([]);