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('حداقل یک شرکت با مصرف معتبر وارد کنید')
return
}
values.dueDays = Number(values.dueDays)
await createBill.mutateAsync(
{ ...values, values: filteredValues },
{
@@ -165,8 +168,8 @@ const CreateBill: FC = () => {
onChange={(e) => setWaterUsage(company.id, Number(e.target.value) || 0)}
error_text={
Array.isArray(formik.errors.values) &&
formik.errors.values[index] &&
(formik.errors.values[index] as { waterUsage?: string })?.waterUsage
formik.errors.values[index] &&
(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 = (
page: number,
search: string,
isActive: string
isActive: string,
) => {
return useQuery({
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 = () => {
return useMutation({
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 = () => {
return useMutation({
mutationFn: (id: string) => api.deleteCompany(id),
+7 -2
View File
@@ -4,7 +4,7 @@ import { CreateCompanyType, CreateIndustryType } from "../types/CompanyTypes";
export const getIndustries = async (
page: number,
search: string,
isActive: string
isActive: string,
) => {
let query = `?page=${page}&q=${search}`;
if (isActive) {
@@ -31,7 +31,7 @@ export const changeStatusIndustry = async (id: string) => {
export const updateIndustry = async (
id: string,
params: CreateIndustryType
params: CreateIndustryType,
) => {
const { data } = await axios.patch(`/industries/${id}`, params);
return data;
@@ -54,6 +54,11 @@ export const getCompanies = async (page: number, perPage?: number) => {
return data;
};
export const getAllCompanies = async () => {
const { data } = await axios.get(`/companies/list/public`);
return data;
};
export const deleteCompany = async (id: string) => {
const { data } = await axios.delete(`/companies/${id}`);
return data;