feat: deal tags
This commit is contained in:
@ -9,6 +9,7 @@ import useIsMobile from "@/hooks/utils/useIsMobile";
|
|||||||
import { DealSchema } from "@/lib/client";
|
import { DealSchema } from "@/lib/client";
|
||||||
import { ModuleNames } from "@/modules/modules";
|
import { ModuleNames } from "@/modules/modules";
|
||||||
import styles from "./DealCard.module.css";
|
import styles from "./DealCard.module.css";
|
||||||
|
import DealTags from "@/components/ui/DealTags/DealTags";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
deal: DealSchema;
|
deal: DealSchema;
|
||||||
@ -100,6 +101,7 @@ const DealCard = ({ deal, isInGroup = false }: Props) => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
{!deal.group && <DealTags dealId={deal.id} tags={deal.tags} />}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import { useDebouncedValue } from "@mantine/hooks";
|
|||||||
import GroupMenu from "@/app/deals/components/mobile/GroupMenu/GroupMenu";
|
import GroupMenu from "@/app/deals/components/mobile/GroupMenu/GroupMenu";
|
||||||
import DealCard from "@/app/deals/components/shared/DealCard/DealCard";
|
import DealCard from "@/app/deals/components/shared/DealCard/DealCard";
|
||||||
import { useDealsContext } from "@/app/deals/contexts/DealsContext";
|
import { useDealsContext } from "@/app/deals/contexts/DealsContext";
|
||||||
|
import DealTags from "@/components/ui/DealTags/DealTags";
|
||||||
import useIsMobile from "@/hooks/utils/useIsMobile";
|
import useIsMobile from "@/hooks/utils/useIsMobile";
|
||||||
import GroupWithDealsSchema from "@/types/GroupWithDealsSchema";
|
import GroupWithDealsSchema from "@/types/GroupWithDealsSchema";
|
||||||
import styles from "./DealsGroup.module.css";
|
import styles from "./DealsGroup.module.css";
|
||||||
@ -87,6 +88,12 @@ const DealsGroup: FC<Props> = ({ group }) => {
|
|||||||
key={deal.id}
|
key={deal.id}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
{group.items.length > 0 && (
|
||||||
|
<DealTags
|
||||||
|
groupId={group.id}
|
||||||
|
tags={group.items[0].tags}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -33,6 +33,8 @@ const useProjectsContextState = (): ProjectsContextState => {
|
|||||||
[projects, selectedProjectId]
|
[projects, selectedProjectId]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(selectedProject);
|
||||||
|
|
||||||
const modulesSet = useMemo(
|
const modulesSet = useMemo(
|
||||||
() =>
|
() =>
|
||||||
new Set(
|
new Set(
|
||||||
|
|||||||
@ -3,7 +3,8 @@ import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
|
|||||||
import { useDrawersContext } from "@/drawers/DrawersContext";
|
import { useDrawersContext } from "@/drawers/DrawersContext";
|
||||||
|
|
||||||
const useProjectActions = () => {
|
const useProjectActions = () => {
|
||||||
const { selectedProject, projectsCrud } = useProjectsContext();
|
const { selectedProject, projectsCrud, refetchProjects } =
|
||||||
|
useProjectsContext();
|
||||||
const { openDrawer } = useDrawersContext();
|
const { openDrawer } = useDrawersContext();
|
||||||
|
|
||||||
const onCreateClick = () => {
|
const onCreateClick = () => {
|
||||||
@ -27,6 +28,7 @@ const useProjectActions = () => {
|
|||||||
onChange: value => projectsCrud.onUpdate(value.id, value),
|
onChange: value => projectsCrud.onUpdate(value.id, value),
|
||||||
onDelete: projectsCrud.onDelete,
|
onDelete: projectsCrud.onDelete,
|
||||||
},
|
},
|
||||||
|
onClose: refetchProjects,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
34
src/components/ui/DealTag/DealTag.tsx
Normal file
34
src/components/ui/DealTag/DealTag.tsx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { lighten, Pill, useMantineColorScheme } from "@mantine/core";
|
||||||
|
import { DealTagSchema } from "@/lib/client";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
tag: Partial<DealTagSchema>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const DealTag = ({ tag }: Props) => {
|
||||||
|
const theme = useMantineColorScheme();
|
||||||
|
const isInherit = tag.tagColor!.backgroundColor === "inherit";
|
||||||
|
|
||||||
|
let color = tag.tagColor!.color;
|
||||||
|
const backgroundColor = tag.tagColor!.backgroundColor;
|
||||||
|
|
||||||
|
if (!(theme.colorScheme === "dark" || isInherit)) {
|
||||||
|
color = lighten(color, 0.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Pill
|
||||||
|
key={tag.id}
|
||||||
|
style={{
|
||||||
|
opacity: 0.7,
|
||||||
|
color,
|
||||||
|
backgroundColor,
|
||||||
|
border: "1px solid",
|
||||||
|
borderColor: color,
|
||||||
|
}}>
|
||||||
|
{tag.name}
|
||||||
|
</Pill>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DealTag;
|
||||||
30
src/components/ui/DealTags/DealTags.module.css
Normal file
30
src/components/ui/DealTags/DealTags.module.css
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
.add-tag-button {
|
||||||
|
@mixin light {
|
||||||
|
background-color: var(--mantine-color-gray-1);
|
||||||
|
}
|
||||||
|
@mixin dark {
|
||||||
|
background-color: var(--mantine-color-dark-6);
|
||||||
|
}
|
||||||
|
color: gray;
|
||||||
|
border: 1px gray dashed;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 1.5rem;
|
||||||
|
height: 1.5rem;
|
||||||
|
padding: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-tag-button:hover {
|
||||||
|
@mixin light {
|
||||||
|
border-color: black;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
@mixin dark {
|
||||||
|
border-color: white;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-tag-button-icon {
|
||||||
|
color: inherit !important;
|
||||||
|
}
|
||||||
93
src/components/ui/DealTags/DealTags.tsx
Normal file
93
src/components/ui/DealTags/DealTags.tsx
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import React, { useMemo } from "react";
|
||||||
|
import { IconPlus } from "@tabler/icons-react";
|
||||||
|
import classNames from "classnames";
|
||||||
|
import { Button, Center, Checkbox, Group, Menu, Stack } from "@mantine/core";
|
||||||
|
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
|
||||||
|
import DealTag from "@/components/ui/DealTag/DealTag";
|
||||||
|
import useDealTags from "@/components/ui/DealTags/hooks/useDealTags";
|
||||||
|
import { DealTagSchema } from "@/lib/client";
|
||||||
|
import styles from "./DealTags.module.css";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
dealId?: number;
|
||||||
|
groupId?: number;
|
||||||
|
tags: DealTagSchema[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const DealTags = ({ tags, dealId, groupId }: Props) => {
|
||||||
|
const { selectedProject } = useProjectsContext();
|
||||||
|
const { switchTag } = useDealTags();
|
||||||
|
const tagIdsSet = useMemo(() => new Set(tags.map(t => t.id)), [tags]);
|
||||||
|
|
||||||
|
if (selectedProject?.tags.length === 0) return;
|
||||||
|
|
||||||
|
const onTagClick = (tagId: number, event: MouseEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
switchTag({ dealId, groupId, tagId });
|
||||||
|
};
|
||||||
|
|
||||||
|
const addTagButton = useMemo(
|
||||||
|
() => (
|
||||||
|
<Menu withArrow>
|
||||||
|
<Menu.Target>
|
||||||
|
<Button
|
||||||
|
onClick={e => e.stopPropagation()}
|
||||||
|
unstyled
|
||||||
|
className={classNames(styles["add-tag-button"])}>
|
||||||
|
<Center>
|
||||||
|
<IconPlus
|
||||||
|
size={"1.2em"}
|
||||||
|
className={classNames(
|
||||||
|
styles["add-tag-button-icon"]
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
</Button>
|
||||||
|
</Menu.Target>
|
||||||
|
<Menu.Dropdown>
|
||||||
|
<Stack
|
||||||
|
p={"xs"}
|
||||||
|
gap={"sm"}
|
||||||
|
onClick={e => e.stopPropagation()}>
|
||||||
|
{selectedProject?.tags.map(tag => (
|
||||||
|
<Group
|
||||||
|
key={tag.id}
|
||||||
|
wrap={"nowrap"}>
|
||||||
|
<Checkbox
|
||||||
|
checked={tagIdsSet.has(tag.id)}
|
||||||
|
onChange={event =>
|
||||||
|
onTagClick(
|
||||||
|
tag.id,
|
||||||
|
event as unknown as any
|
||||||
|
)
|
||||||
|
}
|
||||||
|
label={tag.name}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
</Menu.Dropdown>
|
||||||
|
</Menu>
|
||||||
|
),
|
||||||
|
[selectedProject?.tags, tags]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group gap={"xs"}>
|
||||||
|
{addTagButton}
|
||||||
|
{selectedProject?.tags.map(
|
||||||
|
tag =>
|
||||||
|
tagIdsSet.has(tag.id) && (
|
||||||
|
<DealTag
|
||||||
|
key={tag.id}
|
||||||
|
tag={tag}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DealTags;
|
||||||
25
src/components/ui/DealTags/hooks/useDealTags.ts
Normal file
25
src/components/ui/DealTags/hooks/useDealTags.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
import { useDealsContext } from "@/app/deals/contexts/DealsContext";
|
||||||
|
import { SwitchDealTagRequest } from "@/lib/client";
|
||||||
|
import { switchDealTagMutation } from "@/lib/client/@tanstack/react-query.gen";
|
||||||
|
|
||||||
|
const useDealTags = () => {
|
||||||
|
const { refetchDeals } = useDealsContext();
|
||||||
|
|
||||||
|
const switchTagMutation = useMutation({
|
||||||
|
...switchDealTagMutation(),
|
||||||
|
onSettled: refetchDeals,
|
||||||
|
});
|
||||||
|
|
||||||
|
const switchTag = (data: SwitchDealTagRequest) => {
|
||||||
|
switchTagMutation.mutate({
|
||||||
|
body: data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
switchTag,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useDealTags;
|
||||||
@ -1,9 +1,13 @@
|
|||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { IconBlocks, IconEdit } from "@tabler/icons-react";
|
import { IconBlocks, IconEdit, IconTags } from "@tabler/icons-react";
|
||||||
import { Tabs } from "@mantine/core";
|
import { Tabs } from "@mantine/core";
|
||||||
|
import {
|
||||||
|
GeneralTab,
|
||||||
|
ModulesTab,
|
||||||
|
} from "@/drawers/common/ProjectEditorDrawer/tabs";
|
||||||
|
import TagsTab from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/TagsTab";
|
||||||
import { ProjectSchema } from "@/lib/client";
|
import { ProjectSchema } from "@/lib/client";
|
||||||
import styles from "../ProjectEditorDrawer.module.css";
|
import styles from "../ProjectEditorDrawer.module.css";
|
||||||
import { GeneralTab, ModulesTab } from "@/drawers/common/ProjectEditorDrawer/tabs";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
value: ProjectSchema;
|
value: ProjectSchema;
|
||||||
@ -27,13 +31,21 @@ const ProjectEditorBody: FC<Props> = props => {
|
|||||||
leftSection={<IconBlocks />}>
|
leftSection={<IconBlocks />}>
|
||||||
Модули
|
Модули
|
||||||
</Tabs.Tab>
|
</Tabs.Tab>
|
||||||
|
<Tabs.Tab
|
||||||
|
value={"tags"}
|
||||||
|
leftSection={<IconTags />}>
|
||||||
|
Теги
|
||||||
|
</Tabs.Tab>
|
||||||
</Tabs.List>
|
</Tabs.List>
|
||||||
<Tabs.Panel value="general">
|
<Tabs.Panel value={"general"}>
|
||||||
<GeneralTab {...props} />
|
<GeneralTab {...props} />
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
<Tabs.Panel value="modules">
|
<Tabs.Panel value={"modules"}>
|
||||||
<ModulesTab {...props} />
|
<ModulesTab {...props} />
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
|
<Tabs.Panel value={"tags"}>
|
||||||
|
<TagsTab {...props} />
|
||||||
|
</Tabs.Panel>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,26 @@
|
|||||||
|
import { FC } from "react";
|
||||||
|
import { Flex } from "@mantine/core";
|
||||||
|
import TagsTabHeader from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/components/TagsTabHeader";
|
||||||
|
import TagsTable from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/components/TagsTable";
|
||||||
|
import { DealTagsContextProvider } from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/contexts/DealTagsContext";
|
||||||
|
import { ProjectSchema } from "@/lib/client";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
value: ProjectSchema;
|
||||||
|
};
|
||||||
|
|
||||||
|
const TagsTab: FC<Props> = ({ value }) => {
|
||||||
|
return (
|
||||||
|
<Flex
|
||||||
|
h={"100%"}
|
||||||
|
direction={"column"}
|
||||||
|
gap={"xs"}>
|
||||||
|
<DealTagsContextProvider project={value}>
|
||||||
|
<TagsTabHeader />
|
||||||
|
<TagsTable />
|
||||||
|
</DealTagsContextProvider>
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TagsTab;
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { IconCheck } from "@tabler/icons-react";
|
||||||
|
import { Group, SelectProps } from "@mantine/core";
|
||||||
|
import ObjectSelect, {
|
||||||
|
ObjectSelectProps,
|
||||||
|
} from "@/components/selects/ObjectSelect/ObjectSelect";
|
||||||
|
import DealTag from "@/components/ui/DealTag/DealTag";
|
||||||
|
import { DealTagColorSchema } from "@/lib/client";
|
||||||
|
import useTagColorList from "../hooks/useTagColorList";
|
||||||
|
|
||||||
|
type Props = Omit<
|
||||||
|
ObjectSelectProps<DealTagColorSchema>,
|
||||||
|
"data" | "getValueFn" | "getLabelFn"
|
||||||
|
>;
|
||||||
|
|
||||||
|
const TagColorInput = (props: Props) => {
|
||||||
|
const { colors } = useTagColorList();
|
||||||
|
const colorsMap = new Map<string, DealTagColorSchema>(
|
||||||
|
colors.map(
|
||||||
|
color =>
|
||||||
|
[color.id.toString(), color] as [string, DealTagColorSchema]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const renderSelectOption: SelectProps["renderOption"] = ({
|
||||||
|
option,
|
||||||
|
checked,
|
||||||
|
}) => {
|
||||||
|
const tag = {
|
||||||
|
id: Number(option.value),
|
||||||
|
name: "Тег-пример",
|
||||||
|
tagColor: colorsMap.get(option.value),
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group
|
||||||
|
flex="1"
|
||||||
|
gap="md">
|
||||||
|
<DealTag tag={tag} />
|
||||||
|
{option.label}
|
||||||
|
{checked && <IconCheck style={{ marginInlineStart: "auto" }} />}
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ObjectSelect
|
||||||
|
label={"Цвет"}
|
||||||
|
renderOption={renderSelectOption}
|
||||||
|
data={colors}
|
||||||
|
getValueFn={color => color.id.toString()}
|
||||||
|
getLabelFn={color => color.label}
|
||||||
|
searchable
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TagColorInput;
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
import { IconPlus } from "@tabler/icons-react";
|
||||||
|
import { Group } from "@mantine/core";
|
||||||
|
import InlineButton from "@/components/ui/InlineButton/InlineButton";
|
||||||
|
import useDealTagActions from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/hooks/useDealTagActions";
|
||||||
|
|
||||||
|
const TagsTabHeader = () => {
|
||||||
|
const { onCreateClick } = useDealTagActions();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group
|
||||||
|
pt={"xs"}
|
||||||
|
px={"xs"}>
|
||||||
|
<InlineButton onClick={onCreateClick}>
|
||||||
|
<IconPlus />
|
||||||
|
Создать
|
||||||
|
</InlineButton>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TagsTabHeader;
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
import { IconMoodSad } from "@tabler/icons-react";
|
||||||
|
import { Group, Text } from "@mantine/core";
|
||||||
|
import BaseTable from "@/components/ui/BaseTable/BaseTable";
|
||||||
|
import { useDealTagsContext } from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/contexts/DealTagsContext";
|
||||||
|
import tagsTableColumns from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/hooks/tagsTableColumns";
|
||||||
|
import useDealTagActions from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/hooks/useDealTagActions";
|
||||||
|
|
||||||
|
const TagsTable = () => {
|
||||||
|
const { dealTags, dealTagsCrud } = useDealTagsContext();
|
||||||
|
const { onChangeClick } = useDealTagActions();
|
||||||
|
|
||||||
|
const columns = tagsTableColumns({
|
||||||
|
onDelete: dealTagsCrud.onDelete,
|
||||||
|
onChange: onChangeClick,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseTable
|
||||||
|
withTableBorder
|
||||||
|
records={dealTags}
|
||||||
|
columns={columns}
|
||||||
|
groups={undefined}
|
||||||
|
style={{
|
||||||
|
marginInline: "var(--mantine-spacing-xs)",
|
||||||
|
minHeight: 200,
|
||||||
|
}}
|
||||||
|
verticalSpacing={"xs"}
|
||||||
|
emptyState={
|
||||||
|
<Group mt={dealTags.length === 0 ? "xl" : 0}>
|
||||||
|
<Text>Нет тегов</Text>
|
||||||
|
<IconMoodSad />
|
||||||
|
</Group>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TagsTable;
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
"use dealTag";
|
||||||
|
|
||||||
|
import { DealTagsCrud, useDealTagsCrud } from "@/hooks/cruds/useDealTagsCrud";
|
||||||
|
import useDealTagsList from "@/hooks/lists/useDealTagsList";
|
||||||
|
import { DealTagSchema, ProjectSchema } from "@/lib/client";
|
||||||
|
import makeContext from "@/lib/contextFactory/contextFactory";
|
||||||
|
|
||||||
|
type DealTagsContextState = {
|
||||||
|
dealTags: DealTagSchema[];
|
||||||
|
refetchDealTags: () => void;
|
||||||
|
project: ProjectSchema;
|
||||||
|
dealTagsCrud: DealTagsCrud;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
project: ProjectSchema;
|
||||||
|
};
|
||||||
|
|
||||||
|
const useDealTagsContextState = ({ project }: Props): DealTagsContextState => {
|
||||||
|
const dealTagsList = useDealTagsList({ projectId: project.id });
|
||||||
|
|
||||||
|
const dealTagsCrud = useDealTagsCrud({
|
||||||
|
...dealTagsList,
|
||||||
|
projectId: project.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
dealTags: dealTagsList.dealTags,
|
||||||
|
refetchDealTags: dealTagsList.refetch,
|
||||||
|
project,
|
||||||
|
dealTagsCrud,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const [DealTagsContextProvider, useDealTagsContext] = makeContext<
|
||||||
|
DealTagsContextState,
|
||||||
|
Props
|
||||||
|
>(useDealTagsContextState, "DealTags");
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
import { useMemo } from "react";
|
||||||
|
import { DataTableColumn } from "mantine-datatable";
|
||||||
|
import { Center } from "@mantine/core";
|
||||||
|
import UpdateDeleteTableActions from "@/components/ui/BaseTable/components/UpdateDeleteTableActions";
|
||||||
|
import DealTag from "@/components/ui/DealTag/DealTag";
|
||||||
|
import { DealTagSchema } from "@/lib/client";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
onDelete: (tag: DealTagSchema) => void;
|
||||||
|
onChange: (tag: DealTagSchema) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const useTagsTableColumns = ({ onDelete, onChange }: Props) => {
|
||||||
|
return useMemo(
|
||||||
|
() =>
|
||||||
|
[
|
||||||
|
{
|
||||||
|
accessor: "actions",
|
||||||
|
title: <Center>Действия</Center>,
|
||||||
|
width: "0%",
|
||||||
|
render: tag => (
|
||||||
|
<UpdateDeleteTableActions
|
||||||
|
onDelete={() => onDelete(tag)}
|
||||||
|
onChange={() => onChange(tag)}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Название",
|
||||||
|
accessor: "name",
|
||||||
|
width: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Цвет",
|
||||||
|
accessor: "tagColor.label",
|
||||||
|
width: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Пример",
|
||||||
|
accessor: "tagColor",
|
||||||
|
width: 3,
|
||||||
|
render: tag => <DealTag tag={tag} />,
|
||||||
|
},
|
||||||
|
] as DataTableColumn<DealTagSchema>[],
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useTagsTableColumns;
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
import { modals } from "@mantine/modals";
|
||||||
|
import { useDealTagsContext } from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/contexts/DealTagsContext";
|
||||||
|
import { DealTagSchema } from "@/lib/client";
|
||||||
|
|
||||||
|
const useDealTagActions = () => {
|
||||||
|
const { dealTagsCrud } = useDealTagsContext();
|
||||||
|
|
||||||
|
const onChangeClick = (tag: DealTagSchema) => {
|
||||||
|
modals.openContextModal({
|
||||||
|
modal: "dealTagModal",
|
||||||
|
innerProps: {
|
||||||
|
entity: tag,
|
||||||
|
onChange: data => dealTagsCrud.onUpdate(tag.id, data),
|
||||||
|
isEditing: true,
|
||||||
|
},
|
||||||
|
withCloseButton: false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onCreateClick = () => {
|
||||||
|
modals.openContextModal({
|
||||||
|
modal: "dealTagModal",
|
||||||
|
innerProps: {
|
||||||
|
onCreate: dealTagsCrud.onCreate,
|
||||||
|
isEditing: false,
|
||||||
|
},
|
||||||
|
withCloseButton: false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
onChangeClick,
|
||||||
|
onCreateClick,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useDealTagActions;
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { getDealTagColorsOptions } from "@/lib/client/@tanstack/react-query.gen";
|
||||||
|
|
||||||
|
const useTagColorList = () => {
|
||||||
|
const { data, refetch } = useQuery(getDealTagColorsOptions());
|
||||||
|
|
||||||
|
return {
|
||||||
|
colors: data?.items ?? [],
|
||||||
|
refetch,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useTagColorList;
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { Stack, TextInput } from "@mantine/core";
|
||||||
|
import { useForm } from "@mantine/form";
|
||||||
|
import { ContextModalProps } from "@mantine/modals";
|
||||||
|
import TagColorInput from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/components/TagColorInput";
|
||||||
|
import {
|
||||||
|
CreateDealTagSchema,
|
||||||
|
DealTagSchema,
|
||||||
|
UpdateDealTagSchema,
|
||||||
|
} from "@/lib/client";
|
||||||
|
import BaseFormModal, {
|
||||||
|
CreateEditFormProps,
|
||||||
|
} from "@/modals/base/BaseFormModal/BaseFormModal";
|
||||||
|
|
||||||
|
type Props = CreateEditFormProps<
|
||||||
|
CreateDealTagSchema,
|
||||||
|
UpdateDealTagSchema,
|
||||||
|
DealTagSchema
|
||||||
|
>;
|
||||||
|
|
||||||
|
const DealTagModal = ({
|
||||||
|
context,
|
||||||
|
id,
|
||||||
|
innerProps,
|
||||||
|
}: ContextModalProps<Props>) => {
|
||||||
|
const initialValues: Partial<DealTagSchema> = innerProps.isEditing
|
||||||
|
? innerProps.entity
|
||||||
|
: {
|
||||||
|
name: "",
|
||||||
|
tagColor: undefined,
|
||||||
|
tagColorId: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
const form = useForm<Partial<DealTagSchema>>({
|
||||||
|
initialValues,
|
||||||
|
validate: {
|
||||||
|
name: name => !name && "Необходимо указать название тега",
|
||||||
|
tagColor: tagColor => !tagColor && "Необходимо указать цвет тега",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseFormModal
|
||||||
|
form={form}
|
||||||
|
closeOnSubmit
|
||||||
|
onClose={() => context.closeContextModal(id)}
|
||||||
|
{...innerProps}>
|
||||||
|
<Stack>
|
||||||
|
<TextInput
|
||||||
|
label={"Название"}
|
||||||
|
placeholder={"Введите название тега"}
|
||||||
|
{...form.getInputProps("name")}
|
||||||
|
/>
|
||||||
|
<TagColorInput
|
||||||
|
placeholder={"Укажите цвет"}
|
||||||
|
{...form.getInputProps("tagColor")}
|
||||||
|
onChange={tag => {
|
||||||
|
form.setFieldValue("tagColor", tag);
|
||||||
|
form.setFieldValue("tagColorId", tag.id);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</BaseFormModal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DealTagModal;
|
||||||
53
src/hooks/cruds/useDealTagsCrud.tsx
Normal file
53
src/hooks/cruds/useDealTagsCrud.tsx
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { useCrudOperations } from "@/hooks/cruds/baseCrud";
|
||||||
|
import {
|
||||||
|
CreateDealTagSchema,
|
||||||
|
DealTagSchema,
|
||||||
|
UpdateDealTagSchema,
|
||||||
|
} from "@/lib/client";
|
||||||
|
import {
|
||||||
|
createDealTagMutation,
|
||||||
|
deleteDealTagMutation,
|
||||||
|
updateDealTagMutation,
|
||||||
|
} from "@/lib/client/@tanstack/react-query.gen";
|
||||||
|
|
||||||
|
type UseDealTagsOperationsProps = {
|
||||||
|
queryKey: any[];
|
||||||
|
projectId: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DealTagsCrud = {
|
||||||
|
onCreate: (data: CreateDealTagSchema) => void;
|
||||||
|
onUpdate: (dealTagId: number, dealTag: UpdateDealTagSchema) => void;
|
||||||
|
onDelete: (dealTag: DealTagSchema) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useDealTagsCrud = ({
|
||||||
|
queryKey,
|
||||||
|
projectId,
|
||||||
|
}: UseDealTagsOperationsProps): DealTagsCrud => {
|
||||||
|
return useCrudOperations<
|
||||||
|
DealTagSchema,
|
||||||
|
UpdateDealTagSchema,
|
||||||
|
CreateDealTagSchema
|
||||||
|
>({
|
||||||
|
key: "getDealTags",
|
||||||
|
queryKey,
|
||||||
|
mutations: {
|
||||||
|
create: createDealTagMutation(),
|
||||||
|
update: updateDealTagMutation(),
|
||||||
|
delete: deleteDealTagMutation(),
|
||||||
|
},
|
||||||
|
getCreateEntity: data => ({
|
||||||
|
tagColorId: data.tagColorId!,
|
||||||
|
name: data.name!,
|
||||||
|
projectId,
|
||||||
|
}),
|
||||||
|
getUpdateEntity: (old, update) => ({
|
||||||
|
...old,
|
||||||
|
name: update.name ?? old.name,
|
||||||
|
tagColor: update.tagColor ?? old.tagColor,
|
||||||
|
tagColorId: update.tagColor?.id ?? old.tagColorId,
|
||||||
|
}),
|
||||||
|
getDeleteConfirmTitle: () => "Удаление доски",
|
||||||
|
});
|
||||||
|
};
|
||||||
39
src/hooks/lists/useDealTagsList.ts
Normal file
39
src/hooks/lists/useDealTagsList.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { DealTagSchema } from "@/lib/client";
|
||||||
|
import {
|
||||||
|
getDealTagsOptions,
|
||||||
|
getDealTagsQueryKey,
|
||||||
|
} from "@/lib/client/@tanstack/react-query.gen";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
projectId: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const useDealTagsList = ({ projectId }: Props) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const options = {
|
||||||
|
path: { projectId },
|
||||||
|
};
|
||||||
|
const { data, refetch } = useQuery(getDealTagsOptions(options));
|
||||||
|
|
||||||
|
const queryKey = getDealTagsQueryKey(options);
|
||||||
|
|
||||||
|
const setDealTags = (dealTags: DealTagSchema[]) => {
|
||||||
|
queryClient.setQueryData(
|
||||||
|
queryKey,
|
||||||
|
(old: { items: DealTagSchema[] }) => ({
|
||||||
|
...old,
|
||||||
|
items: dealTags,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
dealTags: data?.items ?? [],
|
||||||
|
setDealTags,
|
||||||
|
refetch,
|
||||||
|
queryKey,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useDealTagsList;
|
||||||
@ -3,6 +3,7 @@
|
|||||||
import {
|
import {
|
||||||
infiniteQueryOptions,
|
infiniteQueryOptions,
|
||||||
queryOptions,
|
queryOptions,
|
||||||
|
type DefaultError,
|
||||||
type InfiniteData,
|
type InfiniteData,
|
||||||
type UseMutationOptions,
|
type UseMutationOptions,
|
||||||
} from "@tanstack/react-query";
|
} from "@tanstack/react-query";
|
||||||
@ -19,6 +20,7 @@ import {
|
|||||||
createDealProduct,
|
createDealProduct,
|
||||||
createDealProductService,
|
createDealProductService,
|
||||||
createDealService,
|
createDealService,
|
||||||
|
createDealTag,
|
||||||
createMarketplace,
|
createMarketplace,
|
||||||
createProduct,
|
createProduct,
|
||||||
createProject,
|
createProject,
|
||||||
@ -26,7 +28,6 @@ import {
|
|||||||
createServiceCategory,
|
createServiceCategory,
|
||||||
createServicesKit,
|
createServicesKit,
|
||||||
createStatus,
|
createStatus,
|
||||||
createTag,
|
|
||||||
deleteBarcodeTemplate,
|
deleteBarcodeTemplate,
|
||||||
deleteBoard,
|
deleteBoard,
|
||||||
deleteClient,
|
deleteClient,
|
||||||
@ -35,6 +36,7 @@ import {
|
|||||||
deleteDealProduct,
|
deleteDealProduct,
|
||||||
deleteDealProductService,
|
deleteDealProductService,
|
||||||
deleteDealService,
|
deleteDealService,
|
||||||
|
deleteDealTag,
|
||||||
deleteMarketplace,
|
deleteMarketplace,
|
||||||
deleteProduct,
|
deleteProduct,
|
||||||
deleteProject,
|
deleteProject,
|
||||||
@ -42,7 +44,6 @@ import {
|
|||||||
deleteServiceCategory,
|
deleteServiceCategory,
|
||||||
deleteServicesKit,
|
deleteServicesKit,
|
||||||
deleteStatus,
|
deleteStatus,
|
||||||
deleteTag,
|
|
||||||
duplicateProductServices,
|
duplicateProductServices,
|
||||||
getBarcodeTemplateAttributes,
|
getBarcodeTemplateAttributes,
|
||||||
getBarcodeTemplates,
|
getBarcodeTemplates,
|
||||||
@ -55,6 +56,7 @@ import {
|
|||||||
getDeals,
|
getDeals,
|
||||||
getDealServices,
|
getDealServices,
|
||||||
getDealTagColors,
|
getDealTagColors,
|
||||||
|
getDealTags,
|
||||||
getMarketplaces,
|
getMarketplaces,
|
||||||
getProductBarcodePdf,
|
getProductBarcodePdf,
|
||||||
getProducts,
|
getProducts,
|
||||||
@ -74,6 +76,7 @@ import {
|
|||||||
updateDealProductService,
|
updateDealProductService,
|
||||||
updateDealService,
|
updateDealService,
|
||||||
updateDealsInGroup,
|
updateDealsInGroup,
|
||||||
|
updateDealTag,
|
||||||
updateMarketplace,
|
updateMarketplace,
|
||||||
updateProduct,
|
updateProduct,
|
||||||
updateProject,
|
updateProject,
|
||||||
@ -81,7 +84,6 @@ import {
|
|||||||
updateServiceCategory,
|
updateServiceCategory,
|
||||||
updateServicesKit,
|
updateServicesKit,
|
||||||
updateStatus,
|
updateStatus,
|
||||||
updateTag,
|
|
||||||
type Options,
|
type Options,
|
||||||
} from "../sdk.gen";
|
} from "../sdk.gen";
|
||||||
import type {
|
import type {
|
||||||
@ -115,6 +117,9 @@ import type {
|
|||||||
CreateDealServiceData,
|
CreateDealServiceData,
|
||||||
CreateDealServiceError,
|
CreateDealServiceError,
|
||||||
CreateDealServiceResponse2,
|
CreateDealServiceResponse2,
|
||||||
|
CreateDealTagData,
|
||||||
|
CreateDealTagError,
|
||||||
|
CreateDealTagResponse2,
|
||||||
CreateMarketplaceData,
|
CreateMarketplaceData,
|
||||||
CreateMarketplaceError,
|
CreateMarketplaceError,
|
||||||
CreateMarketplaceResponse2,
|
CreateMarketplaceResponse2,
|
||||||
@ -136,9 +141,6 @@ import type {
|
|||||||
CreateStatusData,
|
CreateStatusData,
|
||||||
CreateStatusError,
|
CreateStatusError,
|
||||||
CreateStatusResponse2,
|
CreateStatusResponse2,
|
||||||
CreateTagData,
|
|
||||||
CreateTagError,
|
|
||||||
CreateTagResponse,
|
|
||||||
DeleteBarcodeTemplateData,
|
DeleteBarcodeTemplateData,
|
||||||
DeleteBarcodeTemplateError,
|
DeleteBarcodeTemplateError,
|
||||||
DeleteBarcodeTemplateResponse2,
|
DeleteBarcodeTemplateResponse2,
|
||||||
@ -163,6 +165,9 @@ import type {
|
|||||||
DeleteDealServiceData,
|
DeleteDealServiceData,
|
||||||
DeleteDealServiceError,
|
DeleteDealServiceError,
|
||||||
DeleteDealServiceResponse2,
|
DeleteDealServiceResponse2,
|
||||||
|
DeleteDealTagData,
|
||||||
|
DeleteDealTagError,
|
||||||
|
DeleteDealTagResponse2,
|
||||||
DeleteMarketplaceData,
|
DeleteMarketplaceData,
|
||||||
DeleteMarketplaceError,
|
DeleteMarketplaceError,
|
||||||
DeleteMarketplaceResponse2,
|
DeleteMarketplaceResponse2,
|
||||||
@ -184,9 +189,6 @@ import type {
|
|||||||
DeleteStatusData,
|
DeleteStatusData,
|
||||||
DeleteStatusError,
|
DeleteStatusError,
|
||||||
DeleteStatusResponse2,
|
DeleteStatusResponse2,
|
||||||
DeleteTagData,
|
|
||||||
DeleteTagError,
|
|
||||||
DeleteTagResponse,
|
|
||||||
DuplicateProductServicesData,
|
DuplicateProductServicesData,
|
||||||
DuplicateProductServicesError,
|
DuplicateProductServicesError,
|
||||||
DuplicateProductServicesResponse,
|
DuplicateProductServicesResponse,
|
||||||
@ -203,6 +205,8 @@ import type {
|
|||||||
GetDealServicesData,
|
GetDealServicesData,
|
||||||
GetDealsResponse2,
|
GetDealsResponse2,
|
||||||
GetDealTagColorsData,
|
GetDealTagColorsData,
|
||||||
|
GetDealTagColorsResponse,
|
||||||
|
GetDealTagsData,
|
||||||
GetMarketplacesData,
|
GetMarketplacesData,
|
||||||
GetProductBarcodePdfData,
|
GetProductBarcodePdfData,
|
||||||
GetProductBarcodePdfError,
|
GetProductBarcodePdfError,
|
||||||
@ -246,6 +250,9 @@ import type {
|
|||||||
UpdateDealsInGroupData,
|
UpdateDealsInGroupData,
|
||||||
UpdateDealsInGroupError,
|
UpdateDealsInGroupError,
|
||||||
UpdateDealsInGroupResponse2,
|
UpdateDealsInGroupResponse2,
|
||||||
|
UpdateDealTagData,
|
||||||
|
UpdateDealTagError,
|
||||||
|
UpdateDealTagResponse2,
|
||||||
UpdateMarketplaceData,
|
UpdateMarketplaceData,
|
||||||
UpdateMarketplaceError,
|
UpdateMarketplaceError,
|
||||||
UpdateMarketplaceResponse2,
|
UpdateMarketplaceResponse2,
|
||||||
@ -267,9 +274,6 @@ import type {
|
|||||||
UpdateStatusData,
|
UpdateStatusData,
|
||||||
UpdateStatusError,
|
UpdateStatusError,
|
||||||
UpdateStatusResponse2,
|
UpdateStatusResponse2,
|
||||||
UpdateTagData,
|
|
||||||
UpdateTagError,
|
|
||||||
UpdateTagResponse,
|
|
||||||
} from "../types.gen";
|
} from "../types.gen";
|
||||||
|
|
||||||
export type QueryKey<TOptions extends Options> = [
|
export type QueryKey<TOptions extends Options> = [
|
||||||
@ -795,43 +799,16 @@ export const updateDealsInGroupMutation = (
|
|||||||
return mutationOptions;
|
return mutationOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
export const getDealTagsQueryKey = (options: Options<GetDealTagsData>) =>
|
||||||
* Update Tag
|
createQueryKey("getDealTags", options);
|
||||||
*/
|
|
||||||
export const updateTagMutation = (
|
|
||||||
options?: Partial<Options<UpdateTagData>>
|
|
||||||
): UseMutationOptions<
|
|
||||||
UpdateTagResponse,
|
|
||||||
AxiosError<UpdateTagError>,
|
|
||||||
Options<UpdateTagData>
|
|
||||||
> => {
|
|
||||||
const mutationOptions: UseMutationOptions<
|
|
||||||
UpdateTagResponse,
|
|
||||||
AxiosError<UpdateTagError>,
|
|
||||||
Options<UpdateTagData>
|
|
||||||
> = {
|
|
||||||
mutationFn: async localOptions => {
|
|
||||||
const { data } = await updateTag({
|
|
||||||
...options,
|
|
||||||
...localOptions,
|
|
||||||
throwOnError: true,
|
|
||||||
});
|
|
||||||
return data;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return mutationOptions;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const createTagQueryKey = (options: Options<CreateTagData>) =>
|
|
||||||
createQueryKey("createTag", options);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Tag
|
* Get Deal Tags
|
||||||
*/
|
*/
|
||||||
export const createTagOptions = (options: Options<CreateTagData>) => {
|
export const getDealTagsOptions = (options: Options<GetDealTagsData>) => {
|
||||||
return queryOptions({
|
return queryOptions({
|
||||||
queryFn: async ({ queryKey, signal }) => {
|
queryFn: async ({ queryKey, signal }) => {
|
||||||
const { data } = await createTag({
|
const { data } = await getDealTags({
|
||||||
...options,
|
...options,
|
||||||
...queryKey[0],
|
...queryKey[0],
|
||||||
signal,
|
signal,
|
||||||
@ -839,27 +816,48 @@ export const createTagOptions = (options: Options<CreateTagData>) => {
|
|||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
queryKey: createTagQueryKey(options),
|
queryKey: getDealTagsQueryKey(options),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createDealTagQueryKey = (options: Options<CreateDealTagData>) =>
|
||||||
|
createQueryKey("createDealTag", options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Deal Tag
|
||||||
|
*/
|
||||||
|
export const createDealTagOptions = (options: Options<CreateDealTagData>) => {
|
||||||
|
return queryOptions({
|
||||||
|
queryFn: async ({ queryKey, signal }) => {
|
||||||
|
const { data } = await createDealTag({
|
||||||
|
...options,
|
||||||
|
...queryKey[0],
|
||||||
|
signal,
|
||||||
|
throwOnError: true,
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
queryKey: createDealTagQueryKey(options),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Tag
|
* Create Deal Tag
|
||||||
*/
|
*/
|
||||||
export const createTagMutation = (
|
export const createDealTagMutation = (
|
||||||
options?: Partial<Options<CreateTagData>>
|
options?: Partial<Options<CreateDealTagData>>
|
||||||
): UseMutationOptions<
|
): UseMutationOptions<
|
||||||
CreateTagResponse,
|
CreateDealTagResponse2,
|
||||||
AxiosError<CreateTagError>,
|
AxiosError<CreateDealTagError>,
|
||||||
Options<CreateTagData>
|
Options<CreateDealTagData>
|
||||||
> => {
|
> => {
|
||||||
const mutationOptions: UseMutationOptions<
|
const mutationOptions: UseMutationOptions<
|
||||||
CreateTagResponse,
|
CreateDealTagResponse2,
|
||||||
AxiosError<CreateTagError>,
|
AxiosError<CreateDealTagError>,
|
||||||
Options<CreateTagData>
|
Options<CreateDealTagData>
|
||||||
> = {
|
> = {
|
||||||
mutationFn: async localOptions => {
|
mutationFn: async localOptions => {
|
||||||
const { data } = await createTag({
|
const { data } = await createDealTag({
|
||||||
...options,
|
...options,
|
||||||
...localOptions,
|
...localOptions,
|
||||||
throwOnError: true,
|
throwOnError: true,
|
||||||
@ -871,22 +869,49 @@ export const createTagMutation = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete Tag
|
* Delete Deal Tag
|
||||||
*/
|
*/
|
||||||
export const deleteTagMutation = (
|
export const deleteDealTagMutation = (
|
||||||
options?: Partial<Options<DeleteTagData>>
|
options?: Partial<Options<DeleteDealTagData>>
|
||||||
): UseMutationOptions<
|
): UseMutationOptions<
|
||||||
DeleteTagResponse,
|
DeleteDealTagResponse2,
|
||||||
AxiosError<DeleteTagError>,
|
AxiosError<DeleteDealTagError>,
|
||||||
Options<DeleteTagData>
|
Options<DeleteDealTagData>
|
||||||
> => {
|
> => {
|
||||||
const mutationOptions: UseMutationOptions<
|
const mutationOptions: UseMutationOptions<
|
||||||
DeleteTagResponse,
|
DeleteDealTagResponse2,
|
||||||
AxiosError<DeleteTagError>,
|
AxiosError<DeleteDealTagError>,
|
||||||
Options<DeleteTagData>
|
Options<DeleteDealTagData>
|
||||||
> = {
|
> = {
|
||||||
mutationFn: async localOptions => {
|
mutationFn: async localOptions => {
|
||||||
const { data } = await deleteTag({
|
const { data } = await deleteDealTag({
|
||||||
|
...options,
|
||||||
|
...localOptions,
|
||||||
|
throwOnError: true,
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return mutationOptions;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Deal Tag
|
||||||
|
*/
|
||||||
|
export const updateDealTagMutation = (
|
||||||
|
options?: Partial<Options<UpdateDealTagData>>
|
||||||
|
): UseMutationOptions<
|
||||||
|
UpdateDealTagResponse2,
|
||||||
|
AxiosError<UpdateDealTagError>,
|
||||||
|
Options<UpdateDealTagData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
UpdateDealTagResponse2,
|
||||||
|
AxiosError<UpdateDealTagError>,
|
||||||
|
Options<UpdateDealTagData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
|
const { data } = await updateDealTag({
|
||||||
...options,
|
...options,
|
||||||
...localOptions,
|
...localOptions,
|
||||||
throwOnError: true,
|
throwOnError: true,
|
||||||
@ -969,6 +994,33 @@ export const getDealTagColorsOptions = (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Deal Tag Colors
|
||||||
|
*/
|
||||||
|
export const getDealTagColorsMutation = (
|
||||||
|
options?: Partial<Options<GetDealTagColorsData>>
|
||||||
|
): UseMutationOptions<
|
||||||
|
GetDealTagColorsResponse,
|
||||||
|
AxiosError<DefaultError>,
|
||||||
|
Options<GetDealTagColorsData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
GetDealTagColorsResponse,
|
||||||
|
AxiosError<DefaultError>,
|
||||||
|
Options<GetDealTagColorsData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
|
const { data } = await getDealTagColors({
|
||||||
|
...options,
|
||||||
|
...localOptions,
|
||||||
|
throwOnError: true,
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return mutationOptions;
|
||||||
|
};
|
||||||
|
|
||||||
export const getBuiltInModulesQueryKey = (
|
export const getBuiltInModulesQueryKey = (
|
||||||
options?: Options<GetBuiltInModulesData>
|
options?: Options<GetBuiltInModulesData>
|
||||||
) => createQueryKey("getBuiltInModules", options);
|
) => createQueryKey("getBuiltInModules", options);
|
||||||
|
|||||||
@ -33,6 +33,9 @@ import type {
|
|||||||
CreateDealServiceData,
|
CreateDealServiceData,
|
||||||
CreateDealServiceErrors,
|
CreateDealServiceErrors,
|
||||||
CreateDealServiceResponses,
|
CreateDealServiceResponses,
|
||||||
|
CreateDealTagData,
|
||||||
|
CreateDealTagErrors,
|
||||||
|
CreateDealTagResponses,
|
||||||
CreateMarketplaceData,
|
CreateMarketplaceData,
|
||||||
CreateMarketplaceErrors,
|
CreateMarketplaceErrors,
|
||||||
CreateMarketplaceResponses,
|
CreateMarketplaceResponses,
|
||||||
@ -54,9 +57,6 @@ import type {
|
|||||||
CreateStatusData,
|
CreateStatusData,
|
||||||
CreateStatusErrors,
|
CreateStatusErrors,
|
||||||
CreateStatusResponses,
|
CreateStatusResponses,
|
||||||
CreateTagData,
|
|
||||||
CreateTagErrors,
|
|
||||||
CreateTagResponses,
|
|
||||||
DeleteBarcodeTemplateData,
|
DeleteBarcodeTemplateData,
|
||||||
DeleteBarcodeTemplateErrors,
|
DeleteBarcodeTemplateErrors,
|
||||||
DeleteBarcodeTemplateResponses,
|
DeleteBarcodeTemplateResponses,
|
||||||
@ -81,6 +81,9 @@ import type {
|
|||||||
DeleteDealServiceData,
|
DeleteDealServiceData,
|
||||||
DeleteDealServiceErrors,
|
DeleteDealServiceErrors,
|
||||||
DeleteDealServiceResponses,
|
DeleteDealServiceResponses,
|
||||||
|
DeleteDealTagData,
|
||||||
|
DeleteDealTagErrors,
|
||||||
|
DeleteDealTagResponses,
|
||||||
DeleteMarketplaceData,
|
DeleteMarketplaceData,
|
||||||
DeleteMarketplaceErrors,
|
DeleteMarketplaceErrors,
|
||||||
DeleteMarketplaceResponses,
|
DeleteMarketplaceResponses,
|
||||||
@ -102,9 +105,6 @@ import type {
|
|||||||
DeleteStatusData,
|
DeleteStatusData,
|
||||||
DeleteStatusErrors,
|
DeleteStatusErrors,
|
||||||
DeleteStatusResponses,
|
DeleteStatusResponses,
|
||||||
DeleteTagData,
|
|
||||||
DeleteTagErrors,
|
|
||||||
DeleteTagResponses,
|
|
||||||
DuplicateProductServicesData,
|
DuplicateProductServicesData,
|
||||||
DuplicateProductServicesErrors,
|
DuplicateProductServicesErrors,
|
||||||
DuplicateProductServicesResponses,
|
DuplicateProductServicesResponses,
|
||||||
@ -135,6 +135,9 @@ import type {
|
|||||||
GetDealsResponses,
|
GetDealsResponses,
|
||||||
GetDealTagColorsData,
|
GetDealTagColorsData,
|
||||||
GetDealTagColorsResponses,
|
GetDealTagColorsResponses,
|
||||||
|
GetDealTagsData,
|
||||||
|
GetDealTagsErrors,
|
||||||
|
GetDealTagsResponses,
|
||||||
GetMarketplacesData,
|
GetMarketplacesData,
|
||||||
GetMarketplacesErrors,
|
GetMarketplacesErrors,
|
||||||
GetMarketplacesResponses,
|
GetMarketplacesResponses,
|
||||||
@ -188,6 +191,9 @@ import type {
|
|||||||
UpdateDealsInGroupData,
|
UpdateDealsInGroupData,
|
||||||
UpdateDealsInGroupErrors,
|
UpdateDealsInGroupErrors,
|
||||||
UpdateDealsInGroupResponses,
|
UpdateDealsInGroupResponses,
|
||||||
|
UpdateDealTagData,
|
||||||
|
UpdateDealTagErrors,
|
||||||
|
UpdateDealTagResponses,
|
||||||
UpdateMarketplaceData,
|
UpdateMarketplaceData,
|
||||||
UpdateMarketplaceErrors,
|
UpdateMarketplaceErrors,
|
||||||
UpdateMarketplaceResponses,
|
UpdateMarketplaceResponses,
|
||||||
@ -209,9 +215,6 @@ import type {
|
|||||||
UpdateStatusData,
|
UpdateStatusData,
|
||||||
UpdateStatusErrors,
|
UpdateStatusErrors,
|
||||||
UpdateStatusResponses,
|
UpdateStatusResponses,
|
||||||
UpdateTagData,
|
|
||||||
UpdateTagErrors,
|
|
||||||
UpdateTagResponses,
|
|
||||||
} from "./types.gen";
|
} from "./types.gen";
|
||||||
import {
|
import {
|
||||||
zAddKitToDealData,
|
zAddKitToDealData,
|
||||||
@ -234,6 +237,8 @@ import {
|
|||||||
zCreateDealResponse2,
|
zCreateDealResponse2,
|
||||||
zCreateDealServiceData,
|
zCreateDealServiceData,
|
||||||
zCreateDealServiceResponse2,
|
zCreateDealServiceResponse2,
|
||||||
|
zCreateDealTagData,
|
||||||
|
zCreateDealTagResponse2,
|
||||||
zCreateMarketplaceData,
|
zCreateMarketplaceData,
|
||||||
zCreateMarketplaceResponse2,
|
zCreateMarketplaceResponse2,
|
||||||
zCreateProductData,
|
zCreateProductData,
|
||||||
@ -248,8 +253,6 @@ import {
|
|||||||
zCreateServicesKitResponse2,
|
zCreateServicesKitResponse2,
|
||||||
zCreateStatusData,
|
zCreateStatusData,
|
||||||
zCreateStatusResponse2,
|
zCreateStatusResponse2,
|
||||||
zCreateTagData,
|
|
||||||
zCreateTagResponse,
|
|
||||||
zDeleteBarcodeTemplateData,
|
zDeleteBarcodeTemplateData,
|
||||||
zDeleteBarcodeTemplateResponse2,
|
zDeleteBarcodeTemplateResponse2,
|
||||||
zDeleteBoardData,
|
zDeleteBoardData,
|
||||||
@ -266,6 +269,8 @@ import {
|
|||||||
zDeleteDealResponse2,
|
zDeleteDealResponse2,
|
||||||
zDeleteDealServiceData,
|
zDeleteDealServiceData,
|
||||||
zDeleteDealServiceResponse2,
|
zDeleteDealServiceResponse2,
|
||||||
|
zDeleteDealTagData,
|
||||||
|
zDeleteDealTagResponse2,
|
||||||
zDeleteMarketplaceData,
|
zDeleteMarketplaceData,
|
||||||
zDeleteMarketplaceResponse2,
|
zDeleteMarketplaceResponse2,
|
||||||
zDeleteProductData,
|
zDeleteProductData,
|
||||||
@ -280,8 +285,6 @@ import {
|
|||||||
zDeleteServicesKitResponse2,
|
zDeleteServicesKitResponse2,
|
||||||
zDeleteStatusData,
|
zDeleteStatusData,
|
||||||
zDeleteStatusResponse2,
|
zDeleteStatusResponse2,
|
||||||
zDeleteTagData,
|
|
||||||
zDeleteTagResponse,
|
|
||||||
zDuplicateProductServicesData,
|
zDuplicateProductServicesData,
|
||||||
zDuplicateProductServicesResponse,
|
zDuplicateProductServicesResponse,
|
||||||
zGetBarcodeTemplateAttributesData,
|
zGetBarcodeTemplateAttributesData,
|
||||||
@ -306,6 +309,8 @@ import {
|
|||||||
zGetDealsResponse2,
|
zGetDealsResponse2,
|
||||||
zGetDealTagColorsData,
|
zGetDealTagColorsData,
|
||||||
zGetDealTagColorsResponse,
|
zGetDealTagColorsResponse,
|
||||||
|
zGetDealTagsData,
|
||||||
|
zGetDealTagsResponse2,
|
||||||
zGetMarketplacesData,
|
zGetMarketplacesData,
|
||||||
zGetMarketplacesResponse2,
|
zGetMarketplacesResponse2,
|
||||||
zGetProductBarcodePdfData,
|
zGetProductBarcodePdfData,
|
||||||
@ -344,6 +349,8 @@ import {
|
|||||||
zUpdateDealServiceResponse2,
|
zUpdateDealServiceResponse2,
|
||||||
zUpdateDealsInGroupData,
|
zUpdateDealsInGroupData,
|
||||||
zUpdateDealsInGroupResponse2,
|
zUpdateDealsInGroupResponse2,
|
||||||
|
zUpdateDealTagData,
|
||||||
|
zUpdateDealTagResponse2,
|
||||||
zUpdateMarketplaceData,
|
zUpdateMarketplaceData,
|
||||||
zUpdateMarketplaceResponse2,
|
zUpdateMarketplaceResponse2,
|
||||||
zUpdateProductData,
|
zUpdateProductData,
|
||||||
@ -358,8 +365,6 @@ import {
|
|||||||
zUpdateServicesKitResponse2,
|
zUpdateServicesKitResponse2,
|
||||||
zUpdateStatusData,
|
zUpdateStatusData,
|
||||||
zUpdateStatusResponse2,
|
zUpdateStatusResponse2,
|
||||||
zUpdateTagData,
|
|
||||||
zUpdateTagResponse,
|
|
||||||
} from "./zod.gen";
|
} from "./zod.gen";
|
||||||
|
|
||||||
export type Options<
|
export type Options<
|
||||||
@ -684,49 +689,45 @@ export const updateDealsInGroup = <ThrowOnError extends boolean = false>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Tag
|
* Get Deal Tags
|
||||||
*/
|
*/
|
||||||
export const updateTag = <ThrowOnError extends boolean = false>(
|
export const getDealTags = <ThrowOnError extends boolean = false>(
|
||||||
options: Options<UpdateTagData, ThrowOnError>
|
options: Options<GetDealTagsData, ThrowOnError>
|
||||||
) => {
|
) => {
|
||||||
return (options.client ?? _heyApiClient).patch<
|
return (options.client ?? _heyApiClient).get<
|
||||||
UpdateTagResponses,
|
GetDealTagsResponses,
|
||||||
UpdateTagErrors,
|
GetDealTagsErrors,
|
||||||
ThrowOnError
|
ThrowOnError
|
||||||
>({
|
>({
|
||||||
requestValidator: async data => {
|
requestValidator: async data => {
|
||||||
return await zUpdateTagData.parseAsync(data);
|
return await zGetDealTagsData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: "json",
|
responseType: "json",
|
||||||
responseValidator: async data => {
|
responseValidator: async data => {
|
||||||
return await zUpdateTagResponse.parseAsync(data);
|
return await zGetDealTagsResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: "/crm/v1/deal-tag/",
|
url: "/crm/v1/deal-tag/{projectId}",
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
...options.headers,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Tag
|
* Create Deal Tag
|
||||||
*/
|
*/
|
||||||
export const createTag = <ThrowOnError extends boolean = false>(
|
export const createDealTag = <ThrowOnError extends boolean = false>(
|
||||||
options: Options<CreateTagData, ThrowOnError>
|
options: Options<CreateDealTagData, ThrowOnError>
|
||||||
) => {
|
) => {
|
||||||
return (options.client ?? _heyApiClient).post<
|
return (options.client ?? _heyApiClient).post<
|
||||||
CreateTagResponses,
|
CreateDealTagResponses,
|
||||||
CreateTagErrors,
|
CreateDealTagErrors,
|
||||||
ThrowOnError
|
ThrowOnError
|
||||||
>({
|
>({
|
||||||
requestValidator: async data => {
|
requestValidator: async data => {
|
||||||
return await zCreateTagData.parseAsync(data);
|
return await zCreateDealTagData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: "json",
|
responseType: "json",
|
||||||
responseValidator: async data => {
|
responseValidator: async data => {
|
||||||
return await zCreateTagResponse.parseAsync(data);
|
return await zCreateDealTagResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: "/crm/v1/deal-tag/",
|
url: "/crm/v1/deal-tag/",
|
||||||
...options,
|
...options,
|
||||||
@ -738,28 +739,55 @@ export const createTag = <ThrowOnError extends boolean = false>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete Tag
|
* Delete Deal Tag
|
||||||
*/
|
*/
|
||||||
export const deleteTag = <ThrowOnError extends boolean = false>(
|
export const deleteDealTag = <ThrowOnError extends boolean = false>(
|
||||||
options: Options<DeleteTagData, ThrowOnError>
|
options: Options<DeleteDealTagData, ThrowOnError>
|
||||||
) => {
|
) => {
|
||||||
return (options.client ?? _heyApiClient).delete<
|
return (options.client ?? _heyApiClient).delete<
|
||||||
DeleteTagResponses,
|
DeleteDealTagResponses,
|
||||||
DeleteTagErrors,
|
DeleteDealTagErrors,
|
||||||
ThrowOnError
|
ThrowOnError
|
||||||
>({
|
>({
|
||||||
requestValidator: async data => {
|
requestValidator: async data => {
|
||||||
return await zDeleteTagData.parseAsync(data);
|
return await zDeleteDealTagData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: "json",
|
responseType: "json",
|
||||||
responseValidator: async data => {
|
responseValidator: async data => {
|
||||||
return await zDeleteTagResponse.parseAsync(data);
|
return await zDeleteDealTagResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: "/crm/v1/deal-tag/{deal_tag_id}",
|
url: "/crm/v1/deal-tag/{pk}",
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Deal Tag
|
||||||
|
*/
|
||||||
|
export const updateDealTag = <ThrowOnError extends boolean = false>(
|
||||||
|
options: Options<UpdateDealTagData, ThrowOnError>
|
||||||
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).patch<
|
||||||
|
UpdateDealTagResponses,
|
||||||
|
UpdateDealTagErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
|
return await zUpdateDealTagData.parseAsync(data);
|
||||||
|
},
|
||||||
|
responseType: "json",
|
||||||
|
responseValidator: async data => {
|
||||||
|
return await zUpdateDealTagResponse2.parseAsync(data);
|
||||||
|
},
|
||||||
|
url: "/crm/v1/deal-tag/{pk}",
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
...options.headers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch Deal Tag
|
* Switch Deal Tag
|
||||||
*/
|
*/
|
||||||
@ -793,7 +821,7 @@ export const switchDealTag = <ThrowOnError extends boolean = false>(
|
|||||||
export const getDealTagColors = <ThrowOnError extends boolean = false>(
|
export const getDealTagColors = <ThrowOnError extends boolean = false>(
|
||||||
options?: Options<GetDealTagColorsData, ThrowOnError>
|
options?: Options<GetDealTagColorsData, ThrowOnError>
|
||||||
) => {
|
) => {
|
||||||
return (options?.client ?? _heyApiClient).get<
|
return (options?.client ?? _heyApiClient).post<
|
||||||
GetDealTagColorsResponses,
|
GetDealTagColorsResponses,
|
||||||
unknown,
|
unknown,
|
||||||
ThrowOnError
|
ThrowOnError
|
||||||
|
|||||||
@ -985,6 +985,10 @@ export type DealSchema = {
|
|||||||
*/
|
*/
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
group: DealGroupSchema | null;
|
group: DealGroupSchema | null;
|
||||||
|
/**
|
||||||
|
* Tags
|
||||||
|
*/
|
||||||
|
tags: Array<DealTagSchema>;
|
||||||
/**
|
/**
|
||||||
* Productsquantity
|
* Productsquantity
|
||||||
*/
|
*/
|
||||||
@ -1318,6 +1322,16 @@ export type GetDealServicesResponse = {
|
|||||||
items: Array<DealServiceSchema>;
|
items: Array<DealServiceSchema>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetDealTagsResponse
|
||||||
|
*/
|
||||||
|
export type GetDealTagsResponse = {
|
||||||
|
/**
|
||||||
|
* Items
|
||||||
|
*/
|
||||||
|
items: Array<DealTagSchema>;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetDealsResponse
|
* GetDealsResponse
|
||||||
*/
|
*/
|
||||||
@ -1650,6 +1664,10 @@ export type ProjectSchema = {
|
|||||||
* Builtinmodules
|
* Builtinmodules
|
||||||
*/
|
*/
|
||||||
builtInModules: Array<BuiltInModuleSchemaOutput>;
|
builtInModules: Array<BuiltInModuleSchemaOutput>;
|
||||||
|
/**
|
||||||
|
* Tags
|
||||||
|
*/
|
||||||
|
tags: Array<DealTagSchema>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2851,85 +2869,124 @@ export type UpdateDealsInGroupResponses = {
|
|||||||
export type UpdateDealsInGroupResponse2 =
|
export type UpdateDealsInGroupResponse2 =
|
||||||
UpdateDealsInGroupResponses[keyof UpdateDealsInGroupResponses];
|
UpdateDealsInGroupResponses[keyof UpdateDealsInGroupResponses];
|
||||||
|
|
||||||
export type UpdateTagData = {
|
export type GetDealTagsData = {
|
||||||
body: UpdateDealTagRequest;
|
body?: never;
|
||||||
path?: never;
|
path: {
|
||||||
|
/**
|
||||||
|
* Projectid
|
||||||
|
*/
|
||||||
|
projectId: number;
|
||||||
|
};
|
||||||
query?: never;
|
query?: never;
|
||||||
url: "/crm/v1/deal-tag/";
|
url: "/crm/v1/deal-tag/{projectId}";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateTagErrors = {
|
export type GetDealTagsErrors = {
|
||||||
/**
|
/**
|
||||||
* Validation Error
|
* Validation Error
|
||||||
*/
|
*/
|
||||||
422: HttpValidationError;
|
422: HttpValidationError;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateTagError = UpdateTagErrors[keyof UpdateTagErrors];
|
export type GetDealTagsError = GetDealTagsErrors[keyof GetDealTagsErrors];
|
||||||
|
|
||||||
export type UpdateTagResponses = {
|
export type GetDealTagsResponses = {
|
||||||
/**
|
/**
|
||||||
* Successful Response
|
* Successful Response
|
||||||
*/
|
*/
|
||||||
200: UpdateDealTagResponse;
|
200: GetDealTagsResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateTagResponse = UpdateTagResponses[keyof UpdateTagResponses];
|
export type GetDealTagsResponse2 =
|
||||||
|
GetDealTagsResponses[keyof GetDealTagsResponses];
|
||||||
|
|
||||||
export type CreateTagData = {
|
export type CreateDealTagData = {
|
||||||
body: CreateDealTagRequest;
|
body: CreateDealTagRequest;
|
||||||
path?: never;
|
path?: never;
|
||||||
query?: never;
|
query?: never;
|
||||||
url: "/crm/v1/deal-tag/";
|
url: "/crm/v1/deal-tag/";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateTagErrors = {
|
export type CreateDealTagErrors = {
|
||||||
/**
|
/**
|
||||||
* Validation Error
|
* Validation Error
|
||||||
*/
|
*/
|
||||||
422: HttpValidationError;
|
422: HttpValidationError;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateTagError = CreateTagErrors[keyof CreateTagErrors];
|
export type CreateDealTagError = CreateDealTagErrors[keyof CreateDealTagErrors];
|
||||||
|
|
||||||
export type CreateTagResponses = {
|
export type CreateDealTagResponses = {
|
||||||
/**
|
/**
|
||||||
* Successful Response
|
* Successful Response
|
||||||
*/
|
*/
|
||||||
200: CreateDealTagResponse;
|
200: CreateDealTagResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateTagResponse = CreateTagResponses[keyof CreateTagResponses];
|
export type CreateDealTagResponse2 =
|
||||||
|
CreateDealTagResponses[keyof CreateDealTagResponses];
|
||||||
|
|
||||||
export type DeleteTagData = {
|
export type DeleteDealTagData = {
|
||||||
body?: never;
|
body?: never;
|
||||||
path: {
|
path: {
|
||||||
/**
|
/**
|
||||||
* Deal Tag Id
|
* Pk
|
||||||
*/
|
*/
|
||||||
deal_tag_id: number;
|
pk: number;
|
||||||
};
|
};
|
||||||
query?: never;
|
query?: never;
|
||||||
url: "/crm/v1/deal-tag/{deal_tag_id}";
|
url: "/crm/v1/deal-tag/{pk}";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DeleteTagErrors = {
|
export type DeleteDealTagErrors = {
|
||||||
/**
|
/**
|
||||||
* Validation Error
|
* Validation Error
|
||||||
*/
|
*/
|
||||||
422: HttpValidationError;
|
422: HttpValidationError;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DeleteTagError = DeleteTagErrors[keyof DeleteTagErrors];
|
export type DeleteDealTagError = DeleteDealTagErrors[keyof DeleteDealTagErrors];
|
||||||
|
|
||||||
export type DeleteTagResponses = {
|
export type DeleteDealTagResponses = {
|
||||||
/**
|
/**
|
||||||
* Successful Response
|
* Successful Response
|
||||||
*/
|
*/
|
||||||
200: DeleteDealTagResponse;
|
200: DeleteDealTagResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DeleteTagResponse = DeleteTagResponses[keyof DeleteTagResponses];
|
export type DeleteDealTagResponse2 =
|
||||||
|
DeleteDealTagResponses[keyof DeleteDealTagResponses];
|
||||||
|
|
||||||
|
export type UpdateDealTagData = {
|
||||||
|
body: UpdateDealTagRequest;
|
||||||
|
path: {
|
||||||
|
/**
|
||||||
|
* Pk
|
||||||
|
*/
|
||||||
|
pk: number;
|
||||||
|
};
|
||||||
|
query?: never;
|
||||||
|
url: "/crm/v1/deal-tag/{pk}";
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UpdateDealTagErrors = {
|
||||||
|
/**
|
||||||
|
* Validation Error
|
||||||
|
*/
|
||||||
|
422: HttpValidationError;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UpdateDealTagError = UpdateDealTagErrors[keyof UpdateDealTagErrors];
|
||||||
|
|
||||||
|
export type UpdateDealTagResponses = {
|
||||||
|
/**
|
||||||
|
* Successful Response
|
||||||
|
*/
|
||||||
|
200: UpdateDealTagResponse;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UpdateDealTagResponse2 =
|
||||||
|
UpdateDealTagResponses[keyof UpdateDealTagResponses];
|
||||||
|
|
||||||
export type SwitchDealTagData = {
|
export type SwitchDealTagData = {
|
||||||
body: SwitchDealTagRequest;
|
body: SwitchDealTagRequest;
|
||||||
|
|||||||
@ -348,6 +348,27 @@ export const zStatusSchema = z.object({
|
|||||||
color: z.string(),
|
color: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DealTagColorSchema
|
||||||
|
*/
|
||||||
|
export const zDealTagColorSchema = z.object({
|
||||||
|
id: z.int(),
|
||||||
|
color: z.string(),
|
||||||
|
backgroundColor: z.string(),
|
||||||
|
label: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DealTagSchema
|
||||||
|
*/
|
||||||
|
export const zDealTagSchema = z.object({
|
||||||
|
name: z.string(),
|
||||||
|
projectId: z.int(),
|
||||||
|
tagColorId: z.int(),
|
||||||
|
id: z.int(),
|
||||||
|
tagColor: zDealTagColorSchema,
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DealSchema
|
* DealSchema
|
||||||
*/
|
*/
|
||||||
@ -361,6 +382,7 @@ export const zDealSchema = z.object({
|
|||||||
offset: true,
|
offset: true,
|
||||||
}),
|
}),
|
||||||
group: z.union([zDealGroupSchema, z.null()]),
|
group: z.union([zDealGroupSchema, z.null()]),
|
||||||
|
tags: z.array(zDealTagSchema),
|
||||||
productsQuantity: z.optional(z.int()).default(0),
|
productsQuantity: z.optional(z.int()).default(0),
|
||||||
totalPrice: z.optional(z.number()).default(0),
|
totalPrice: z.optional(z.number()).default(0),
|
||||||
client: z.optional(z.union([zClientSchema, z.null()])),
|
client: z.optional(z.union([zClientSchema, z.null()])),
|
||||||
@ -427,27 +449,6 @@ export const zCreateDealTagRequest = z.object({
|
|||||||
entity: zCreateDealTagSchema,
|
entity: zCreateDealTagSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* DealTagColorSchema
|
|
||||||
*/
|
|
||||||
export const zDealTagColorSchema = z.object({
|
|
||||||
id: z.int(),
|
|
||||||
color: z.string(),
|
|
||||||
backgroundColor: z.string(),
|
|
||||||
label: z.string(),
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DealTagSchema
|
|
||||||
*/
|
|
||||||
export const zDealTagSchema = z.object({
|
|
||||||
name: z.string(),
|
|
||||||
projectId: z.int(),
|
|
||||||
tagColorId: z.int(),
|
|
||||||
id: z.int(),
|
|
||||||
tagColor: zDealTagColorSchema,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateDealTagResponse
|
* CreateDealTagResponse
|
||||||
*/
|
*/
|
||||||
@ -571,6 +572,7 @@ export const zProjectSchema = z.object({
|
|||||||
id: z.int(),
|
id: z.int(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
builtInModules: z.array(zBuiltInModuleSchemaOutput),
|
builtInModules: z.array(zBuiltInModuleSchemaOutput),
|
||||||
|
tags: z.array(zDealTagSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -899,6 +901,13 @@ export const zGetDealServicesResponse = z.object({
|
|||||||
items: z.array(zDealServiceSchema),
|
items: z.array(zDealServiceSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetDealTagsResponse
|
||||||
|
*/
|
||||||
|
export const zGetDealTagsResponse = z.object({
|
||||||
|
items: z.array(zDealTagSchema),
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PaginationInfoSchema
|
* PaginationInfoSchema
|
||||||
*/
|
*/
|
||||||
@ -1628,18 +1637,20 @@ export const zUpdateDealsInGroupData = z.object({
|
|||||||
*/
|
*/
|
||||||
export const zUpdateDealsInGroupResponse2 = zUpdateDealsInGroupResponse;
|
export const zUpdateDealsInGroupResponse2 = zUpdateDealsInGroupResponse;
|
||||||
|
|
||||||
export const zUpdateTagData = z.object({
|
export const zGetDealTagsData = z.object({
|
||||||
body: zUpdateDealTagRequest,
|
body: z.optional(z.never()),
|
||||||
path: z.optional(z.never()),
|
path: z.object({
|
||||||
|
projectId: z.int(),
|
||||||
|
}),
|
||||||
query: z.optional(z.never()),
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Successful Response
|
* Successful Response
|
||||||
*/
|
*/
|
||||||
export const zUpdateTagResponse = zUpdateDealTagResponse;
|
export const zGetDealTagsResponse2 = zGetDealTagsResponse;
|
||||||
|
|
||||||
export const zCreateTagData = z.object({
|
export const zCreateDealTagData = z.object({
|
||||||
body: zCreateDealTagRequest,
|
body: zCreateDealTagRequest,
|
||||||
path: z.optional(z.never()),
|
path: z.optional(z.never()),
|
||||||
query: z.optional(z.never()),
|
query: z.optional(z.never()),
|
||||||
@ -1648,12 +1659,12 @@ export const zCreateTagData = z.object({
|
|||||||
/**
|
/**
|
||||||
* Successful Response
|
* Successful Response
|
||||||
*/
|
*/
|
||||||
export const zCreateTagResponse = zCreateDealTagResponse;
|
export const zCreateDealTagResponse2 = zCreateDealTagResponse;
|
||||||
|
|
||||||
export const zDeleteTagData = z.object({
|
export const zDeleteDealTagData = z.object({
|
||||||
body: z.optional(z.never()),
|
body: z.optional(z.never()),
|
||||||
path: z.object({
|
path: z.object({
|
||||||
deal_tag_id: z.int(),
|
pk: z.int(),
|
||||||
}),
|
}),
|
||||||
query: z.optional(z.never()),
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
@ -1661,7 +1672,20 @@ export const zDeleteTagData = z.object({
|
|||||||
/**
|
/**
|
||||||
* Successful Response
|
* Successful Response
|
||||||
*/
|
*/
|
||||||
export const zDeleteTagResponse = zDeleteDealTagResponse;
|
export const zDeleteDealTagResponse2 = zDeleteDealTagResponse;
|
||||||
|
|
||||||
|
export const zUpdateDealTagData = z.object({
|
||||||
|
body: zUpdateDealTagRequest,
|
||||||
|
path: z.object({
|
||||||
|
pk: z.int(),
|
||||||
|
}),
|
||||||
|
query: z.optional(z.never()),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Successful Response
|
||||||
|
*/
|
||||||
|
export const zUpdateDealTagResponse2 = zUpdateDealTagResponse;
|
||||||
|
|
||||||
export const zSwitchDealTagData = z.object({
|
export const zSwitchDealTagData = z.object({
|
||||||
body: zSwitchDealTagRequest,
|
body: zSwitchDealTagRequest,
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import {
|
|||||||
ProductServiceEditorModal,
|
ProductServiceEditorModal,
|
||||||
ServicesKitSelectModal,
|
ServicesKitSelectModal,
|
||||||
} from "@/modules/dealModularEditorTabs/FulfillmentBase/shared/modals";
|
} from "@/modules/dealModularEditorTabs/FulfillmentBase/shared/modals";
|
||||||
|
import DealTagModal from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/modals/DealTagModal";
|
||||||
|
|
||||||
export const modals = {
|
export const modals = {
|
||||||
enterNameModal: EnterNameModal,
|
enterNameModal: EnterNameModal,
|
||||||
@ -40,4 +41,5 @@ export const modals = {
|
|||||||
printBarcodeModal: PrintBarcodeModal,
|
printBarcodeModal: PrintBarcodeModal,
|
||||||
statusColorPickerModal: ColorPickerModal,
|
statusColorPickerModal: ColorPickerModal,
|
||||||
marketplaceEditorModal: MarketplaceEditorModal,
|
marketplaceEditorModal: MarketplaceEditorModal,
|
||||||
|
dealTagModal: DealTagModal,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user