fix(admin-ui): delete customer group (#4893)
This commit is contained in:
+17
-2
@@ -1,5 +1,8 @@
|
|||||||
import { CustomerGroup } from "@medusajs/medusa"
|
import { CustomerGroup } from "@medusajs/medusa"
|
||||||
import { useAdminCustomerGroups } from "medusa-react"
|
import {
|
||||||
|
useAdminCustomerGroups,
|
||||||
|
useAdminDeleteCustomerGroup,
|
||||||
|
} from "medusa-react"
|
||||||
import { useNavigate } from "react-router-dom"
|
import { useNavigate } from "react-router-dom"
|
||||||
import {
|
import {
|
||||||
HeaderGroup,
|
HeaderGroup,
|
||||||
@@ -18,6 +21,7 @@ import { ActionType } from "../../molecules/actionables"
|
|||||||
import Table from "../../molecules/table"
|
import Table from "../../molecules/table"
|
||||||
import TableContainer from "../../organisms/table-container"
|
import TableContainer from "../../organisms/table-container"
|
||||||
import { CUSTOMER_GROUPS_TABLE_COLUMNS } from "./config"
|
import { CUSTOMER_GROUPS_TABLE_COLUMNS } from "./config"
|
||||||
|
import useNotification from "../../../hooks/use-notification"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default filtering config for querying customer groups endpoint.
|
* Default filtering config for querying customer groups endpoint.
|
||||||
@@ -89,6 +93,8 @@ function CustomerGroupsTableRow(props: CustomerGroupsTableRowProps) {
|
|||||||
const { row } = props
|
const { row } = props
|
||||||
|
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
const notification = useNotification()
|
||||||
|
const { mutate } = useAdminDeleteCustomerGroup(row.original.id)
|
||||||
|
|
||||||
const actions: ActionType[] = [
|
const actions: ActionType[] = [
|
||||||
{
|
{
|
||||||
@@ -98,7 +104,16 @@ function CustomerGroupsTableRow(props: CustomerGroupsTableRowProps) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Delete",
|
label: "Delete",
|
||||||
onClick: () => {},
|
onClick: () => {
|
||||||
|
mutate(undefined, {
|
||||||
|
onSuccess: () => {
|
||||||
|
notification("Success", "Group deleted", "success")
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
notification("Error", "Failed to delete the group", "error")
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
icon: <TrashIcon size={20} />,
|
icon: <TrashIcon size={20} />,
|
||||||
variant: "danger",
|
variant: "danger",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user