Commit 35b4e88a authored by Merekeyev Dias's avatar Merekeyev Dias

fixed syncBtn in Homepage when isError

parent c49b494d
......@@ -15,7 +15,7 @@ const HomePage: React.FC = () => {
const navigate = useNavigate();
const dispatch = useDispatch();
const tableRef = createRef<TableRef>();
const [updateDictionary] = useUpdateDictionaryMutation();
const [updateDictionary, {isError: isUpdateError}] = useUpdateDictionaryMutation();
const totalOrgNumber = useSelector((state: any) => state.mainPagination.totalOrgNumber);
const currentPage = useSelector((state: any) => state.mainPagination.currentPage);
......@@ -30,16 +30,12 @@ const HomePage: React.FC = () => {
};
const handleSyncClick = async () => {
setIsSyncLoading(true);
console.log(checkedCodes);
await updateDictionary(checkedCodes).unwrap();
message.success('Организации успешны синхронизированы!')
dispatch(clearCheckedCodes());
setIsSyncLoading(false);
};
};
const handlePaginationChange = (page: number) => {
dispatch(setCurrentPage(page));
......@@ -53,15 +49,13 @@ const HomePage: React.FC = () => {
const {
data: orgs = [],
isLoading,
isSuccess,
isError,
error
isLoading: isGetLoading,
isSuccess: isGetSuccess,
} = useGetOrganizationsQuery();
let table;
if (isSuccess) {
if (isGetSuccess) {
table = <Table
dataSource={paginatedData(orgs)}
columns={columns}
......@@ -85,18 +79,22 @@ const HomePage: React.FC = () => {
showSizeChanger: false
}}
/>
} else if (isError) {
table = <div>{error.toString()}</div>
}
useEffect(() => {
if (isLoading) {
if (isGetLoading) {
setIsTableLoading(true);
} else if (isSuccess) {
} else if (isGetSuccess) {
setIsTableLoading(false);
dispatch(setTotalOrgNumber(orgs.length));
}
}, [isSuccess, orgs]);
}, [isGetLoading, isGetSuccess, dispatch, orgs]);
useEffect(() => {
if (isUpdateError) {
setIsSyncLoading(false);
}
}, [isUpdateError]);
useEffect(() => {
if (checkedCodes.length > 0) {
......
......@@ -24,13 +24,13 @@ export const columns: TableProps<DataType>['columns'] = [
title: "ID",
dataIndex: "id",
key: "id",
width: '1%'
width: '2%'
},
{
title: "XML",
dataIndex: "xml",
key: "xml",
width: '1%',
width: '4%',
render: (_, record) => (
<div className={styles.data_interchange_btnGroup}>
<Button
......@@ -73,13 +73,13 @@ export const columns: TableProps<DataType>['columns'] = [
title: "Метод",
dataIndex: "requestType",
key: "requestType",
width: '1%'
width: '2.5%'
},
{
title: "Статус",
dataIndex: "status",
key: "status",
width: '1%',
width: '3%',
render: (_, record) => (
<Tag color={getStatusColor(record.status)}>
{getStatusText(record.status)}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment