fix due + all companies
This commit is contained in:
@@ -47,6 +47,9 @@ const CreateBill: FC = () => {
|
|||||||
toast.error('حداقل یک شرکت با مصرف معتبر وارد کنید')
|
toast.error('حداقل یک شرکت با مصرف معتبر وارد کنید')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
values.dueDays = Number(values.dueDays)
|
||||||
|
|
||||||
await createBill.mutateAsync(
|
await createBill.mutateAsync(
|
||||||
{ ...values, values: filteredValues },
|
{ ...values, values: filteredValues },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { CreateIndustryType, CreateCompanyType } from "../types/CompanyTypes";
|
|||||||
export const useGetIndustries = (
|
export const useGetIndustries = (
|
||||||
page: number,
|
page: number,
|
||||||
search: string,
|
search: string,
|
||||||
isActive: string
|
isActive: string,
|
||||||
) => {
|
) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ["industries", page, search, isActive],
|
queryKey: ["industries", page, search, isActive],
|
||||||
@@ -44,6 +44,13 @@ export const useGetIndustryDetail = (id: string) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useGetAllCompanies = () => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["all-companies"],
|
||||||
|
queryFn: () => api.getAllCompanies(),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const useCreateCompany = () => {
|
export const useCreateCompany = () => {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (params: CreateCompanyType) => api.createCompany(params),
|
mutationFn: (params: CreateCompanyType) => api.createCompany(params),
|
||||||
@@ -57,13 +64,6 @@ export const useGetCompanies = (page: number, perPage?: number) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetAllCompanies = () => {
|
|
||||||
return useQuery({
|
|
||||||
queryKey: ["companies", "all"],
|
|
||||||
queryFn: () => api.getCompanies(1, 1000),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useDeleteCompany = () => {
|
export const useDeleteCompany = () => {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (id: string) => api.deleteCompany(id),
|
mutationFn: (id: string) => api.deleteCompany(id),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { CreateCompanyType, CreateIndustryType } from "../types/CompanyTypes";
|
|||||||
export const getIndustries = async (
|
export const getIndustries = async (
|
||||||
page: number,
|
page: number,
|
||||||
search: string,
|
search: string,
|
||||||
isActive: string
|
isActive: string,
|
||||||
) => {
|
) => {
|
||||||
let query = `?page=${page}&q=${search}`;
|
let query = `?page=${page}&q=${search}`;
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
@@ -31,7 +31,7 @@ export const changeStatusIndustry = async (id: string) => {
|
|||||||
|
|
||||||
export const updateIndustry = async (
|
export const updateIndustry = async (
|
||||||
id: string,
|
id: string,
|
||||||
params: CreateIndustryType
|
params: CreateIndustryType,
|
||||||
) => {
|
) => {
|
||||||
const { data } = await axios.patch(`/industries/${id}`, params);
|
const { data } = await axios.patch(`/industries/${id}`, params);
|
||||||
return data;
|
return data;
|
||||||
@@ -54,6 +54,11 @@ export const getCompanies = async (page: number, perPage?: number) => {
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getAllCompanies = async () => {
|
||||||
|
const { data } = await axios.get(`/companies/list/public`);
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
export const deleteCompany = async (id: string) => {
|
export const deleteCompany = async (id: string) => {
|
||||||
const { data } = await axios.delete(`/companies/${id}`);
|
const { data } = await axios.delete(`/companies/${id}`);
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
Reference in New Issue
Block a user