diff --git a/src/features/plans/lib/api.ts b/src/features/plans/lib/api.ts
index 0fe4c56..c19ae23 100644
--- a/src/features/plans/lib/api.ts
+++ b/src/features/plans/lib/api.ts
@@ -61,4 +61,20 @@ export const plans_api = {
const res = await httpClient.post(API_URLS.Import_Product);
return res;
},
+
+ async update_payment_type({
+ id,
+ body,
+ }: {
+ id: number;
+ body: { payment_type: "cash" | "card" };
+ }) {
+ const res = await httpClient.put(API_URLS.Update_Pyment_Type(id), body);
+ return res;
+ },
+
+ async import_balance() {
+ const res = await httpClient.post(API_URLS.Import_Balance);
+ return res;
+ },
};
diff --git a/src/features/plans/lib/data.ts b/src/features/plans/lib/data.ts
index 218eccf..887033a 100644
--- a/src/features/plans/lib/data.ts
+++ b/src/features/plans/lib/data.ts
@@ -37,6 +37,7 @@ export interface Product {
marketing_group_code: null | string;
inventory_kinds: { id: number; name: string }[];
sector_codes: { id: number; code: string }[];
+ payment_type: "cash" | "card" | null;
}
export interface Category {
diff --git a/src/features/plans/ui/FilterPlans.tsx b/src/features/plans/ui/FilterPlans.tsx
index 7f05aba..79e1d6a 100644
--- a/src/features/plans/ui/FilterPlans.tsx
+++ b/src/features/plans/ui/FilterPlans.tsx
@@ -5,6 +5,7 @@ import { Button } from "@/shared/ui/button";
import { Input } from "@/shared/ui/input";
import { useMutation } from "@tanstack/react-query";
import type { AxiosError } from "axios";
+import { Loader } from "lucide-react";
import type { Dispatch, SetStateAction } from "react";
import { toast } from "sonner";
@@ -46,6 +47,22 @@ const FilterPlans = ({ searchUser, setSearchUser }: Props) => {
},
});
+ const { mutate: balanceMutate, isPending } = useMutation({
+ mutationFn: () => plans_api.import_balance(),
+ onSuccess: () => {
+ toast.success("Mahsulotlar soni import qilindi", {
+ richColors: true,
+ position: "top-center",
+ });
+ },
+ onError: () => {
+ toast.error("Xatolik yuz berdi", {
+ richColors: true,
+ position: "top-center",
+ });
+ },
+ });
+
return (
{
/>
*/}
+
+
);
};
diff --git a/src/features/plans/ui/PalanTable.tsx b/src/features/plans/ui/PalanTable.tsx
index c713604..2f4c610 100644
--- a/src/features/plans/ui/PalanTable.tsx
+++ b/src/features/plans/ui/PalanTable.tsx
@@ -1,7 +1,16 @@
+import { plans_api } from "@/features/plans/lib/api";
import type { Product } from "@/features/plans/lib/data";
import { API_URLS } from "@/shared/config/api/URLs";
import { Button } from "@/shared/ui/button";
import { Checkbox } from "@/shared/ui/checkbox";
+import {
+ Select,
+ SelectContent,
+ SelectGroup,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/shared/ui/select";
import {
Table,
TableBody,
@@ -10,8 +19,10 @@ import {
TableHeader,
TableRow,
} from "@/shared/ui/table";
+import { useMutation, useQueryClient } from "@tanstack/react-query";
import { Eye, Loader2, Trash2 } from "lucide-react";
import type { Dispatch, SetStateAction } from "react";
+import { toast } from "sonner";
interface Props {
products: Product[] | [];
@@ -46,6 +57,29 @@ const ProductTable = ({
handleSelectAllPages,
isAllPagesSelected,
}: Props) => {
+ const queryClient = useQueryClient();
+ const { mutate, isPending } = useMutation({
+ mutationFn: ({
+ id,
+ body,
+ }: {
+ id: number;
+ body: { payment_type: "cash" | "card" };
+ }) => plans_api.update_payment_type({ id, body }),
+ onSuccess: () => {
+ queryClient.refetchQueries({ queryKey: ["product_list"] });
+ toast.success("To‘lov turi yangilandi", {
+ richColors: true,
+ position: "top-center",
+ });
+ },
+ onError: () => {
+ toast.error("Xatolik yuz berdi", {
+ richColors: true,
+ position: "top-center",
+ });
+ },
+ });
if (isLoading || isFetching) {
return (
@@ -63,7 +97,6 @@ const ProductTable = ({
}
const currentPageIds = products.map((p) => p.id);
-
const isAllSelected =
isAllPagesSelected ||
(products.length > 0 &&
@@ -141,6 +174,7 @@ const ProductTable = ({
Rasmi
Nomi
Tavsif
+
Narx turi
Harakatlar
@@ -175,6 +209,31 @@ const ProductTable = ({
{product.name}
{product.short_name?.slice(0, 15)}...
+
+
+