Skip to content

Commit

Permalink
Apply changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Oct 11, 2023
1 parent 0a683a4 commit 7694cb3
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/Components/ExternalResult/ResultItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ import request from "../../Utils/request/request";
const Loading = lazy(() => import("../Common/Loading"));

export default function ResultItem(props: any) {
const initialData: any = {};
const [resultItemData, setResultItemData] = useState(initialData);
const [isLoading, setIsLoading] = useState(true);
const [showDeleteAlert, setShowDeleteAlert] = useState(false);
const { t } = useTranslation();

useQuery(routes.externalResult, {
const { data: resultItemData, loading } = useQuery(routes.externalResult, {
pathParams: { id: props.id },
onResponse: ({ res, data }) => {
if (res?.status === 200 && data) {
setResultItemData(data);
}
setIsLoading(false);
},
});

const handleDelete = async () => {
Expand All @@ -47,7 +38,7 @@ export default function ResultItem(props: any) {
}
};

if (isLoading) {
if (loading || !resultItemData) {
return <Loading />;
}

Expand Down

0 comments on commit 7694cb3

Please sign in to comment.