72 lines
1.7 KiB
TypeScript
72 lines
1.7 KiB
TypeScript
|
|
import React, { useMemo } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import Actions from "../../Components/Ui/tables/Actions";
|
|
import ColumnsImage from "../../Components/Columns/ColumnsImage";
|
|
import { useNavigate } from "react-router-dom";
|
|
import { useDeleteCoupon } from "../../api/Coupon";
|
|
|
|
function fnDelete(props :any ){}
|
|
|
|
const useTableColumns :any = () => {
|
|
const [t] = useTranslation();
|
|
const deleteMutation = useDeleteCoupon()
|
|
const navigate = useNavigate()
|
|
const language = localStorage.getItem("language") ?? "en"
|
|
|
|
return useMemo(
|
|
() => [
|
|
|
|
{
|
|
name: t("name"),
|
|
sortable: false,
|
|
center: "true",
|
|
cell: (row:any) => row?.name
|
|
},
|
|
{
|
|
name: t("discount_type"),
|
|
sortable: false,
|
|
center: "true",
|
|
cell: (row:any) => row?.discount_type
|
|
},
|
|
{
|
|
name: t("coupon_type"),
|
|
sortable: false,
|
|
center: "true",
|
|
cell: (row:any) => row?.coupon_type
|
|
},
|
|
{
|
|
name: t("code"),
|
|
sortable: false,
|
|
center: "true",
|
|
cell: (row:any) => row?.code
|
|
},
|
|
{
|
|
name: t("coupon_value"),
|
|
sortable: false,
|
|
center: "true",
|
|
cell: (row:any) => row?.coupon_value
|
|
},
|
|
{
|
|
name: "#",
|
|
sortable: false,
|
|
center: true,
|
|
cell: (row:any) => (
|
|
<Actions
|
|
objectToEdit={row}
|
|
showEdit
|
|
onEdit={()=> navigate(`/coupon/${row.id}`) }
|
|
showView={false}
|
|
onDelete={() => deleteMutation.mutate({ id: row.id })}
|
|
/>
|
|
),
|
|
},
|
|
|
|
],
|
|
[t]
|
|
);
|
|
};
|
|
|
|
export default useTableColumns;
|
|
|