party-order list ok,
This commit is contained in:
@@ -3,14 +3,14 @@ import type { UseSetStateReturn } from 'minimal-shared/hooks';
|
||||
import { useCallback } from 'react';
|
||||
import type { FiltersResultProps } from 'src/components/filters-result';
|
||||
import { chipProps, FiltersBlock, FiltersResult } from 'src/components/filters-result';
|
||||
import type { IOrderTableFilters } from 'src/types/party-order';
|
||||
import type { IPartyOrderTableFilters } from 'src/types/party-order';
|
||||
import { fDateRangeShortLabel } from 'src/utils/format-time';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type Props = FiltersResultProps & {
|
||||
onResetPage: () => void;
|
||||
filters: UseSetStateReturn<IOrderTableFilters>;
|
||||
filters: UseSetStateReturn<IPartyOrderTableFilters>;
|
||||
};
|
||||
|
||||
export function PartyOrderTableFiltersResult({ filters, totalResults, onResetPage, sx }: Props) {
|
||||
|
@@ -20,14 +20,14 @@ import { CustomPopover } from 'src/components/custom-popover';
|
||||
import { Iconify } from 'src/components/iconify';
|
||||
import { Label } from 'src/components/label';
|
||||
import { RouterLink } from 'src/routes/components';
|
||||
import type { IOrderItem } from 'src/types/party-order';
|
||||
import type { IPartyOrderItem } from 'src/types/party-order';
|
||||
import { fCurrency } from 'src/utils/format-number';
|
||||
import { fDate, fTime } from 'src/utils/format-time';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type Props = {
|
||||
row: IOrderItem;
|
||||
row: IPartyOrderItem;
|
||||
selected: boolean;
|
||||
detailsHref: string;
|
||||
onSelectRow: () => void;
|
||||
|
@@ -13,14 +13,14 @@ import { useTranslation } from 'react-i18next';
|
||||
import { CustomPopover } from 'src/components/custom-popover';
|
||||
import { Iconify } from 'src/components/iconify';
|
||||
import type { IDatePickerControl } from 'src/types/common';
|
||||
import type { IOrderTableFilters } from 'src/types/party-order';
|
||||
import type { IPartyOrderTableFilters } from 'src/types/party-order';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type Props = {
|
||||
dateError: boolean;
|
||||
onResetPage: () => void;
|
||||
filters: UseSetStateReturn<IOrderTableFilters>;
|
||||
filters: UseSetStateReturn<IPartyOrderTableFilters>;
|
||||
};
|
||||
|
||||
export function PartyOrderTableToolbar({ filters, onResetPage, dateError }: Props) {
|
||||
|
@@ -12,7 +12,7 @@ import { changeStatus } from 'src/actions/party-order';
|
||||
import { DashboardContent } from 'src/layouts/dashboard';
|
||||
import { useTranslate } from 'src/locales';
|
||||
import { paths } from 'src/routes/paths';
|
||||
import type { IOrderItem } from 'src/types/party-order';
|
||||
import type { IPartyOrderItem } from 'src/types/party-order';
|
||||
import { OrderDetailsCustomer } from '../party-order-details-customer';
|
||||
import { OrderDetailsDelivery } from '../party-order-details-delivery';
|
||||
import { OrderDetailsHistory } from '../party-order-details-history';
|
||||
@@ -24,7 +24,7 @@ import { OrderDetailsToolbar } from '../party-order-details-toolbar';
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type Props = {
|
||||
order: IOrderItem;
|
||||
order: IPartyOrderItem;
|
||||
};
|
||||
|
||||
export function OrderDetailsView({ order }: Props) {
|
||||
|
@@ -36,7 +36,7 @@ import {
|
||||
import { DashboardContent } from 'src/layouts/dashboard';
|
||||
import { useRouter } from 'src/routes/hooks';
|
||||
import { paths } from 'src/routes/paths';
|
||||
import type { IOrderItem, IOrderTableFilters } from 'src/types/party-order';
|
||||
import type { IPartyOrderItem, IPartyOrderTableFilters } from 'src/types/party-order';
|
||||
import { fIsAfter, fIsBetween } from 'src/utils/format-time';
|
||||
import { PartyOrderTableFiltersResult } from '../party-order-table-filters-result';
|
||||
import { PartyOrderTableRow } from '../party-order-table-row';
|
||||
@@ -50,7 +50,6 @@ const STATUS_OPTIONS = [{ value: 'all', label: 'All' }, ...PARTY_ORDER_STATUS_OP
|
||||
|
||||
export function PartyOrderListView() {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
|
||||
const TABLE_HEAD: TableHeadCellProps[] = [
|
||||
{ id: 'orderNumber', label: t('Order'), width: 88 },
|
||||
@@ -62,19 +61,19 @@ export function PartyOrderListView() {
|
||||
{ id: '', width: 88 },
|
||||
];
|
||||
|
||||
const { orders, mutate, ordersLoading } = useGetPartyOrders();
|
||||
const { partyOrders, partyOrdersLoading } = useGetPartyOrders();
|
||||
|
||||
const table = useTable({ defaultOrderBy: 'orderNumber' });
|
||||
|
||||
const confirmDialog = useBoolean();
|
||||
|
||||
const [tableData, setTableData] = useState<IOrderItem[]>([]);
|
||||
const [tableData, setTableData] = useState<IPartyOrderItem[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
setTableData(orders);
|
||||
}, [orders]);
|
||||
setTableData(partyOrders);
|
||||
}, [partyOrders]);
|
||||
|
||||
const filters = useSetState<IOrderTableFilters>({
|
||||
const filters = useSetState<IPartyOrderTableFilters>({
|
||||
name: '',
|
||||
status: 'all',
|
||||
startDate: null,
|
||||
@@ -107,7 +106,6 @@ export function PartyOrderListView() {
|
||||
try {
|
||||
await deletePartyOrder(id);
|
||||
toast.success('Delete success!');
|
||||
mutate();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error('Delete failed!');
|
||||
@@ -117,7 +115,7 @@ export function PartyOrderListView() {
|
||||
// setTableData(deleteRow);
|
||||
// table.onUpdatePageDeleteRow(dataInPage.length);
|
||||
},
|
||||
[table, tableData, mutate]
|
||||
[table, tableData]
|
||||
);
|
||||
|
||||
const handleDeleteRows = useCallback(() => {
|
||||
@@ -163,12 +161,9 @@ export function PartyOrderListView() {
|
||||
/>
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
mutate();
|
||||
}, []);
|
||||
|
||||
if (!orders) return <>loading</>;
|
||||
if (ordersLoading) return <>loading</>;
|
||||
// TODO: remove below loading screen as mutate is not used
|
||||
if (!partyOrders) return <>loading</>;
|
||||
if (partyOrdersLoading) return <>loading</>;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -324,8 +319,8 @@ export function PartyOrderListView() {
|
||||
|
||||
type ApplyFilterProps = {
|
||||
dateError: boolean;
|
||||
inputData: IOrderItem[];
|
||||
filters: IOrderTableFilters;
|
||||
inputData: IPartyOrderItem[];
|
||||
filters: IPartyOrderTableFilters;
|
||||
comparator: (a: any, b: any) => number;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user