fix due + all companies

This commit is contained in:
hamid zarghami
2026-02-17 10:05:18 +03:30
parent af718809cb
commit d3f65e90ea
3 changed files with 20 additions and 12 deletions
+5 -2
View File
@@ -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 },
{ {
@@ -165,8 +168,8 @@ const CreateBill: FC = () => {
onChange={(e) => setWaterUsage(company.id, Number(e.target.value) || 0)} onChange={(e) => setWaterUsage(company.id, Number(e.target.value) || 0)}
error_text={ error_text={
Array.isArray(formik.errors.values) && Array.isArray(formik.errors.values) &&
formik.errors.values[index] && formik.errors.values[index] &&
(formik.errors.values[index] as { waterUsage?: string })?.waterUsage (formik.errors.values[index] as { waterUsage?: string })?.waterUsage
? (formik.errors.values[index] as { waterUsage: string }).waterUsage ? (formik.errors.values[index] as { waterUsage: string }).waterUsage
: '' : ''
} }
+8 -8
View File
@@ -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),
+7 -2
View File
@@ -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;