Skip to content

Commit

Permalink
recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ogeobubu committed Oct 22, 2024
1 parent 36cd207 commit 2f4db60
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client/src/pages/upload/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useState } from "react";
import axios from "axios";
import { useMutation, UseMutationResult } from "@tanstack/react-query";
import { useMutation } from "@tanstack/react-query";
import Button from "../../components/button";
import bgImage from "../../assets/leaf-bg.png";
import { LeafResponse } from "../../typings";
Expand All @@ -23,7 +23,7 @@ const ImageUpload: React.FC = () => {
const [modalVisible, setModalVisible] = useState(false);
const [classificationResult, setClassificationResult] = useState<LeafResponse | null>(null);

const { mutate, isLoading } = useMutation({
const { mutate, isLoading, isError, isSuccess } = useMutation({
mutationFn: uploadImage,
onSuccess: (data) => {
console.log("Upload success:", data);
Expand All @@ -43,7 +43,7 @@ const ImageUpload: React.FC = () => {

const handleUpload = () => {
if (selectedFile) {
mutation.mutate(selectedFile);
mutate(selectedFile);
}
};

Expand Down Expand Up @@ -107,10 +107,10 @@ const ImageUpload: React.FC = () => {
{isLoading && (
<p className="mt-2 text-blue-500">Uploading...</p>
)}
{mutation.isError && (
{isError && (
<p className="mt-2 text-red-500">Error uploading image.</p>
)}
{mutation.isSuccess && (
{isSuccess && (
<p className="mt-2 text-green-500">Upload successful!</p>
)}
<p className="mt-6 text-white text-center">
Expand Down

0 comments on commit 2f4db60

Please sign in to comment.