import { PencilSquare, Trash } from "@medusajs/icons" import { HttpTypes } from "@medusajs/types" import { Container, Heading, Text, toast, usePrompt } from "@medusajs/ui" import { useTranslation } from "react-i18next" import { useNavigate } from "react-router-dom" import { ActionMenu } from "../../../../../components/common/action-menu" import { useDeleteCustomerGroup } from "../../../../../hooks/api/customer-groups" type CustomerGroupGeneralSectionProps = { group: HttpTypes.AdminCustomerGroup } export const CustomerGroupGeneralSection = ({ group, }: CustomerGroupGeneralSectionProps) => { const { t } = useTranslation() const prompt = usePrompt() const navigate = useNavigate() const { mutateAsync } = useDeleteCustomerGroup(group.id) const handleDelete = async () => { const res = await prompt({ title: t("customerGroups.delete.title"), description: t("customerGroups.delete.description", { name: group.name, }), confirmText: t("actions.delete"), cancelText: t("actions.cancel"), }) if (!res) { return } await mutateAsync(undefined, { onSuccess: () => { toast.success( t("customerGroups.delete.successToast", { name: group.name, }) ) navigate("/customer-groups", { replace: true }) }, onError: (error) => { toast.error(error.message) }, }) } return (
{group.name} , label: t("actions.edit"), to: `/customer-groups/${group.id}/edit`, }, ], }, { actions: [ { icon: , label: t("actions.delete"), onClick: handleDelete, }, ], }, ]} />
{t("customers.domain")} {group.customers?.length || "-"}
) }