import { Popover, Select, Stack, Text, Switch, Group, UnstyledButton } from "@mantine/core"; import { useTranslation } from "react-i18next"; import { IBase, IBaseView } from "@/ee/base/types/base.types"; import { useUpdateViewMutation } from "@/ee/base/queries/base-view-query"; import { useKanbanColumns } from "@/ee/base/hooks/use-kanban-columns"; import { choiceColor } from "@/ee/base/components/cells/choice-color"; import cellClasses from "@/ee/base/styles/cells.module.css"; type KanbanGroupByPickerProps = { base: IBase; view: IBaseView; pageId: string; children: React.ReactNode; }; export function KanbanGroupByPicker({ base, view, pageId, children }: KanbanGroupByPickerProps) { const { t } = useTranslation(); const updateView = useUpdateViewMutation(); const { allGroups, hasValidGroupBy } = useKanbanColumns(base, view); const data = base.properties .filter((p) => p.type === "select" || p.type === "status") .map((p) => ({ value: p.id, label: p.name })); const handleChange = (value: string | null) => { updateView.mutate({ viewId: view.id, pageId, config: { groupByPropertyId: value ?? null }, }); }; const toggleGroup = (key: string, currentlyHidden: boolean) => { const current = view.config?.hiddenChoiceIds ?? []; const next = currentlyHidden ? current.filter((k) => k !== key) : [...current, key]; updateView.mutate({ viewId: view.id, pageId, config: { hiddenChoiceIds: next } }); }; return ( {children} {t("Group by")}