fix: scrolls and context for deal prefilling
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { FC, useEffect } from "react";
|
||||
import { Button, Drawer, Flex, rem, TextInput } from "@mantine/core";
|
||||
import { useDealPageContext } from "../../contexts/DealPageContext.tsx";
|
||||
import DealsTable from "./components/tables/DealsTable/DealsTable.tsx";
|
||||
import Preview from "./components/Preview/Preview.tsx";
|
||||
import styles from "./DealPrefillDrawer.module.css";
|
||||
import BaseMarketplaceSelect from "../../../../components/Selects/BaseMarketplaceSelect/BaseMarketplaceSelect.tsx";
|
||||
import usePrefillDeal from "./hooks/usePrefillDeal.tsx";
|
||||
import { notifications } from "../../../../shared/lib/notifications.ts";
|
||||
import { usePrefillDealContext } from "../../contexts/PrefillDealContext.tsx";
|
||||
|
||||
const DealPrefillDrawer: FC = () => {
|
||||
const { prefillOpened, prefillOnClose, selectedPrefillDeal, setPrefillDeal, prefillDeal } = useDealPageContext();
|
||||
const { prefillOpened, prefillOnClose, selectedPrefillDeal, setPrefillDeal, prefillDeal } = usePrefillDealContext();
|
||||
const { data, form } = usePrefillDeal();
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
.container {
|
||||
display: flex;
|
||||
gap: rem(10);
|
||||
max-height: 95vh;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
@@ -20,6 +19,7 @@
|
||||
}
|
||||
|
||||
.deal-container-wrapper {
|
||||
width: 100%;
|
||||
border: dashed var(--item-border-size) var(--mantine-color-default-border);
|
||||
border-radius: var(--item-border-radius);
|
||||
padding: rem(10);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { FC } from "react";
|
||||
import styles from "./Preview.module.css";
|
||||
import { ScrollArea, Skeleton, Title } from "@mantine/core";
|
||||
import { useDealPageContext } from "../../../../contexts/DealPageContext.tsx";
|
||||
import DealServicesTable from "../tables/DealServicesTable/DealServicesTable.tsx";
|
||||
import ProductPreview from "../ProductPreview/ProductPreview.tsx";
|
||||
import { usePrefillDealContext } from "../../../../contexts/PrefillDealContext.tsx";
|
||||
|
||||
const Preview: FC = () => {
|
||||
const { selectedPrefillDeal } = useDealPageContext();
|
||||
const { selectedPrefillDeal } = usePrefillDealContext();
|
||||
|
||||
const getTotalPrice = () => {
|
||||
if (!selectedPrefillDeal) return 0;
|
||||
@@ -28,27 +28,29 @@ const Preview: FC = () => {
|
||||
|
||||
return (
|
||||
<div className={styles["container"]}>
|
||||
<ScrollArea offsetScrollbars={"y"} w={"100%"}>
|
||||
<Skeleton visible={!selectedPrefillDeal}>
|
||||
<div className={styles["deal-container-wrapper"]}>
|
||||
<Title order={4} mb={18}>
|
||||
Общая стоимость всех услуг:{" "}
|
||||
{getTotalPrice().toLocaleString("ru")}₽
|
||||
</Title>
|
||||
<div className={styles["deal-container-wrapper"]}>
|
||||
<ScrollArea offsetScrollbars={"y"} w={"100%"}>
|
||||
<div style={{ height: "93vh" }}>
|
||||
<Skeleton visible={!selectedPrefillDeal}>
|
||||
<Title order={4} mb={18}>
|
||||
Общая стоимость всех услуг:{" "}
|
||||
{getTotalPrice().toLocaleString("ru")}₽
|
||||
</Title>
|
||||
|
||||
<DealServicesTable items={selectedPrefillDeal?.services} />
|
||||
<DealServicesTable items={selectedPrefillDeal?.services} />
|
||||
|
||||
<div className={styles["products-list"]}>
|
||||
{selectedPrefillDeal?.products.map(product => (
|
||||
<ProductPreview
|
||||
key={product.product.id}
|
||||
product={product}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className={styles["products-list"]}>
|
||||
{selectedPrefillDeal?.products.map(product => (
|
||||
<ProductPreview
|
||||
key={product.product.id}
|
||||
product={product}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Skeleton>
|
||||
</div>
|
||||
</Skeleton>
|
||||
</ScrollArea>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,7 +16,6 @@ const DealServicesTable: FC<Props> = ({ items }) => {
|
||||
<Flex
|
||||
direction={"column"}
|
||||
gap={rem(10)}
|
||||
h={"100%"}
|
||||
mb={10}>
|
||||
<Flex
|
||||
h={"100%"}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { FC, useEffect } from "react";
|
||||
import useDealsTableColumns from "./columns.tsx";
|
||||
import { DealSummary } from "../../../../../../../client";
|
||||
import { useDealPageContext } from "../../../../../contexts/DealPageContext.tsx";
|
||||
import { BaseTable } from "../../../../../../../components/BaseTable/BaseTable.tsx";
|
||||
import { usePrefillDealContext } from "../../../../../contexts/PrefillDealContext.tsx";
|
||||
|
||||
type Props = {
|
||||
items: DealSummary[];
|
||||
};
|
||||
|
||||
const DealsTable: FC<Props> = ({ items }) => {
|
||||
const { selectPrefillDeal } = useDealPageContext();
|
||||
const { selectPrefillDeal } = usePrefillDealContext();
|
||||
const columns = useDealsTableColumns();
|
||||
const defaultSorting = [{ id: "createdAt", desc: false }];
|
||||
|
||||
@@ -36,6 +36,9 @@ const DealsTable: FC<Props> = ({ items }) => {
|
||||
mantinePaginationProps: {
|
||||
showRowsPerPage: false,
|
||||
},
|
||||
enableStickyHeader: true,
|
||||
enableStickyFooter: true,
|
||||
mantineTableContainerProps: { style: { maxHeight: "81vh", height: "81vh" } },
|
||||
}
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMemo } from "react";
|
||||
import { MRT_ColumnDef } from "mantine-react-table";
|
||||
import { ActionIcon, Image, Radio } from "@mantine/core";
|
||||
import { DealSummary } from "../../../../../../../client";
|
||||
import { useDealPageContext } from "../../../../../contexts/DealPageContext.tsx";
|
||||
import { usePrefillDealContext } from "../../../../../contexts/PrefillDealContext.tsx";
|
||||
|
||||
const useDealsTableColumns = () => {
|
||||
return useMemo<MRT_ColumnDef<DealSummary>[]>(
|
||||
@@ -13,7 +13,7 @@ const useDealsTableColumns = () => {
|
||||
size: 5,
|
||||
enableSorting: false,
|
||||
Cell: ({ row }) => {
|
||||
const { selectPrefillDeal, selectedPrefillDeal } = useDealPageContext();
|
||||
const { selectPrefillDeal, selectedPrefillDeal } = usePrefillDealContext();
|
||||
const checked = row.original.id === selectedPrefillDeal?.id;
|
||||
return (
|
||||
<Radio
|
||||
|
||||
Reference in New Issue
Block a user