feat: export services
This commit is contained in:
@@ -15,6 +15,6 @@ export type ServiceSchema = {
|
|||||||
categoryPrices: Array<ServiceCategoryPriceSchema>;
|
categoryPrices: Array<ServiceCategoryPriceSchema>;
|
||||||
cost: (number | null);
|
cost: (number | null);
|
||||||
rank: string;
|
rank: string;
|
||||||
isPlaceholder?: boolean;
|
isPlaceholder?: (boolean | null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,17 @@ export class ServiceService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Get Price List
|
||||||
|
* @returns any Successful Response
|
||||||
|
* @throws ApiError
|
||||||
|
*/
|
||||||
|
public static getPriceList(): CancelablePromise<any> {
|
||||||
|
return __request(OpenAPI, {
|
||||||
|
method: 'GET',
|
||||||
|
url: '/service/price-list',
|
||||||
|
});
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Get All Categories
|
* Get All Categories
|
||||||
* @returns ServiceGetAllCategoriesResponse Successful Response
|
* @returns ServiceGetAllCategoriesResponse Successful Response
|
||||||
@@ -362,4 +373,26 @@ export class ServiceService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Export List Pdf
|
||||||
|
* @returns any Successful Response
|
||||||
|
* @throws ApiError
|
||||||
|
*/
|
||||||
|
public static exportListPdf(): CancelablePromise<any> {
|
||||||
|
return __request(OpenAPI, {
|
||||||
|
method: 'GET',
|
||||||
|
url: '/service/export-list/pdf',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Export List Excel
|
||||||
|
* @returns any Successful Response
|
||||||
|
* @throws ApiError
|
||||||
|
*/
|
||||||
|
public static exportListExcel(): CancelablePromise<any> {
|
||||||
|
return __request(OpenAPI, {
|
||||||
|
method: 'GET',
|
||||||
|
url: '/service/export-list/excel',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { FC, useState } from "react";
|
|||||||
import ServicesTable from "../components/ServicesTable/ServicesTable.tsx";
|
import ServicesTable from "../components/ServicesTable/ServicesTable.tsx";
|
||||||
import PageBlock from "../../../components/PageBlock/PageBlock.tsx";
|
import PageBlock from "../../../components/PageBlock/PageBlock.tsx";
|
||||||
import styles from "./ServicesPage.module.css";
|
import styles from "./ServicesPage.module.css";
|
||||||
import { Button, Flex, rem, Switch } from "@mantine/core";
|
import { Button, Flex, Popover, rem, Switch } from "@mantine/core";
|
||||||
import ServiceTypeSegmentedControl, {
|
import ServiceTypeSegmentedControl, {
|
||||||
ServicesTab,
|
ServicesTab,
|
||||||
} from "../components/ServiceTypeSegmentedControl/ServiceTypeSegmentedControl.tsx";
|
} from "../components/ServiceTypeSegmentedControl/ServiceTypeSegmentedControl.tsx";
|
||||||
@@ -12,6 +12,9 @@ import useServicesState from "../hooks/useServicesState.tsx";
|
|||||||
import useServicesKitsState from "../hooks/useServicesKitsState.tsx";
|
import useServicesKitsState from "../hooks/useServicesKitsState.tsx";
|
||||||
import useServicePriceCategoryState from "../hooks/useServicePriceCategoryState.tsx";
|
import useServicePriceCategoryState from "../hooks/useServicePriceCategoryState.tsx";
|
||||||
import { ObjectStateToTableProps } from "../../../types/utils.ts";
|
import { ObjectStateToTableProps } from "../../../types/utils.ts";
|
||||||
|
import { IconDownload, IconFileExcel, IconFileTypePdf } from "@tabler/icons-react";
|
||||||
|
import FileSaver from "file-saver";
|
||||||
|
import { getCurrentDateTimeForFilename } from "../../../shared/lib/date.ts";
|
||||||
|
|
||||||
export const ServicesPage: FC = () => {
|
export const ServicesPage: FC = () => {
|
||||||
const [serviceType, setServiceType] = useState(ServicesTab.DEAL_SERVICE);
|
const [serviceType, setServiceType] = useState(ServicesTab.DEAL_SERVICE);
|
||||||
@@ -65,7 +68,6 @@ export const ServicesPage: FC = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getControls = () => {
|
const getControls = () => {
|
||||||
switch (serviceType) {
|
switch (serviceType) {
|
||||||
case ServicesTab.SERVICES_KITS:
|
case ServicesTab.SERVICES_KITS:
|
||||||
@@ -80,22 +82,62 @@ export const ServicesPage: FC = () => {
|
|||||||
case ServicesTab.PRODUCT_SERVICE:
|
case ServicesTab.PRODUCT_SERVICE:
|
||||||
return (
|
return (
|
||||||
<Flex align={"center"} gap={rem(10)}>
|
<Flex align={"center"} gap={rem(10)}>
|
||||||
<Button
|
<div style={{
|
||||||
onClick={onCreateClick}
|
display: "grid",
|
||||||
variant={"default"}>
|
gridAutoFlow: "column",
|
||||||
Создать услугу
|
gridAutoColumns: "1fr",
|
||||||
</Button>
|
width: "max-content",
|
||||||
<Button
|
gap: rem(10),
|
||||||
onClick={onCreateCategoryClick}
|
}}>
|
||||||
variant={"default"}>
|
|
||||||
Создать категорию
|
<Button
|
||||||
</Button>
|
onClick={onCreateClick}
|
||||||
|
variant={"default"}>
|
||||||
|
Создать услугу
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
|
||||||
|
onClick={onCreateCategoryClick}
|
||||||
|
variant={"default"}>
|
||||||
|
Создать категорию
|
||||||
|
</Button>
|
||||||
|
<Popover withArrow shadow={"md"}>
|
||||||
|
<Popover.Target>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
leftSection={<IconDownload />}
|
||||||
|
variant={"default"}>
|
||||||
|
Скачать
|
||||||
|
</Button>
|
||||||
|
</Popover.Target>
|
||||||
|
<Popover.Dropdown>
|
||||||
|
<Flex direction={"column"} gap={rem(10)}>
|
||||||
|
<Button
|
||||||
|
onClick={onDownloadPdfClick}
|
||||||
|
variant={"default"}
|
||||||
|
leftSection={<IconFileTypePdf />}
|
||||||
|
>
|
||||||
|
В формате PDF
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={onDownloadExcelClick}
|
||||||
|
variant={"default"}
|
||||||
|
leftSection={<IconFileExcel />}
|
||||||
|
>
|
||||||
|
В формате Excel
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
|
</Popover.Dropdown>
|
||||||
|
</Popover>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
|
|
||||||
variant={"default"}
|
variant={"default"}
|
||||||
label={"Режим редактирования"}
|
label={"Режим редактирования"}
|
||||||
checked={isEditMode}
|
checked={isEditMode}
|
||||||
onChange={() => setIsEditMode(!isEditMode)}
|
onChange={() => setIsEditMode(!isEditMode)}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
@@ -113,6 +155,19 @@ export const ServicesPage: FC = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onDownloadPdfClick = () => {
|
||||||
|
const date = getCurrentDateTimeForFilename();
|
||||||
|
FileSaver.saveAs(`${import.meta.env.VITE_API_URL}/service/export-list/pdf`,
|
||||||
|
`прайс_лист_${date}.pdf`,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const onDownloadExcelClick = () => {
|
||||||
|
const date = getCurrentDateTimeForFilename();
|
||||||
|
FileSaver.saveAs(`${import.meta.env.VITE_API_URL}/service/export-list/excel`,
|
||||||
|
`прайс_лист_${date}.xlsx`,
|
||||||
|
);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div className={styles["container"]}>
|
<div className={styles["container"]}>
|
||||||
<PageBlock>
|
<PageBlock>
|
||||||
|
|||||||
Reference in New Issue
Block a user