prevent to display description if data not have
This commit is contained in:
parent
d25cc3531e
commit
e466fd27be
@ -31,10 +31,12 @@ const Profile = ({ data }) => {
|
|||||||
<div className="divider text-start">
|
<div className="divider text-start">
|
||||||
<div className="divider-text">Profile</div>
|
<div className="divider-text">Profile</div>
|
||||||
</div>
|
</div>
|
||||||
|
{data?.description && (
|
||||||
<div className="col rounded-2 bg-light justify-content-start p-2">
|
<div className="col rounded-2 bg-light justify-content-start p-2">
|
||||||
<p className="m-0">{data?.description}</p>
|
<p className="m-0">{data?.description}</p>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
|
||||||
<div className="row ">
|
<div className="row ">
|
||||||
<div className="col-12 col-md-6 d-flex align-items-center">
|
<div className="col-12 col-md-6 d-flex align-items-center">
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { defaultFilterValues, filterSchema } from "./TenantSchema";
|
|||||||
import Label from "../common/Label";
|
import Label from "../common/Label";
|
||||||
import SelectMultiple from "../common/SelectMultiple";
|
import SelectMultiple from "../common/SelectMultiple";
|
||||||
import { useIndustries } from "../../hooks/useTenant";
|
import { useIndustries } from "../../hooks/useTenant";
|
||||||
import { reference } from "../../utils/constants";
|
import { reference, TENANT_STATUS } from "../../utils/constants";
|
||||||
import { DateRangePicker1 } from "../common/DateRangePicker";
|
import { DateRangePicker1 } from "../common/DateRangePicker";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
|
||||||
@ -22,9 +22,7 @@ const TenantFilterPanel = ({onApply}) => {
|
|||||||
};
|
};
|
||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
onApply({
|
onApply({
|
||||||
...formData,
|
...formData
|
||||||
startDate: moment.utc(formData.startDate, "DD-MM-YYYY").toISOString(),
|
|
||||||
endDate: moment.utc(formData.endDate, "DD-MM-YYYY").toISOString(),
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
const onClear = () => {
|
const onClear = () => {
|
||||||
@ -38,26 +36,42 @@ const TenantFilterPanel = ({onApply}) => {
|
|||||||
<FormProvider {...method}>
|
<FormProvider {...method}>
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<div className="text-start mb-1">
|
<div className="text-start mb-1">
|
||||||
<DateRangePicker1
|
<div className="text-start my-2">
|
||||||
|
<DateRangePicker1
|
||||||
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
||||||
startField="startDate"
|
startField="startDate"
|
||||||
endField="endDate"
|
endField="endDate"
|
||||||
resetSignal={resetKey}
|
resetSignal={resetKey}
|
||||||
/>
|
/>
|
||||||
<SelectMultiple
|
</div>
|
||||||
|
<div className="text-strat mb-2">
|
||||||
|
<SelectMultiple
|
||||||
name="industryIds"
|
name="industryIds"
|
||||||
label="Industries :"
|
label="Industries"
|
||||||
options={data}
|
options={data}
|
||||||
labelKey="name"
|
labelKey="name"
|
||||||
valueKey="id"
|
valueKey="id"
|
||||||
/>
|
/>
|
||||||
<SelectMultiple
|
</div>
|
||||||
|
|
||||||
|
<div className="text-start mb-2">
|
||||||
|
<SelectMultiple
|
||||||
name="references"
|
name="references"
|
||||||
label="References :"
|
label="References"
|
||||||
options={reference}
|
options={reference}
|
||||||
labelKey="name"
|
labelKey="name"
|
||||||
valueKey="val"
|
valueKey="val"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="text-start">
|
||||||
|
<SelectMultiple
|
||||||
|
name="tenantStatusIds"
|
||||||
|
label="Tenant Status"
|
||||||
|
options={TENANT_STATUS}
|
||||||
|
labelKey="name"
|
||||||
|
valueKey="id"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
{/* <SelectMultiple
|
{/* <SelectMultiple
|
||||||
name="references"
|
name="references"
|
||||||
label="Industries :"
|
label="Industries :"
|
||||||
|
|||||||
@ -64,11 +64,10 @@ export const subscriptionDefaultValues = {
|
|||||||
autoRenew: false,
|
autoRenew: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const filterSchema = z.object({
|
export const filterSchema = z.object({
|
||||||
industryIds: z.array(z.string()).optional(),
|
industryIds: z.array(z.string()).optional(),
|
||||||
// createdByIds: z.array(z.string()).optional(),
|
// createdByIds: z.array(z.string()).optional(),
|
||||||
// tenantStatusIds: z.array(z.string()).optional(),
|
tenantStatusIds: z.array(z.string()).optional(),
|
||||||
references: z.array(z.string()).optional(),
|
references: z.array(z.string()).optional(),
|
||||||
startDate: z.string().optional(),
|
startDate: z.string().optional(),
|
||||||
endDate: z.string().optional(),
|
endDate: z.string().optional(),
|
||||||
@ -76,10 +75,10 @@ export const filterSchema = z.object({
|
|||||||
export const defaultFilterValues = {
|
export const defaultFilterValues = {
|
||||||
industryIds: [],
|
industryIds: [],
|
||||||
// createdByIds: [],
|
// createdByIds: [],
|
||||||
// tenantStatusIds: [],
|
tenantStatusIds: [],
|
||||||
references: [],
|
references: [],
|
||||||
startDate: "YYYY-MM-DDTHH:mm:ssZ",
|
startDate:null,
|
||||||
endDate: "YYYY-MM-DDTHH:mm:ssZ",
|
endDate:null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getStepFields = (stepIndex) => {
|
export const getStepFields = (stepIndex) => {
|
||||||
|
|||||||
@ -8,16 +8,25 @@ import { TenantTableSkeleton } from "./TenanatSkeleton";
|
|||||||
import { useTenantContext } from "../../pages/Tenant/TenantPage";
|
import { useTenantContext } from "../../pages/Tenant/TenantPage";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
const TenantsList = ({filters,searchText,setIsRefetching, setRefetchFn}) => {
|
const TenantsList = ({
|
||||||
|
filters,
|
||||||
|
searchText,
|
||||||
|
setIsRefetching,
|
||||||
|
setRefetchFn,
|
||||||
|
}) => {
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
const { data, isLoading, isError, isInitialLoading, error,refetch, isFetching } = useTenants(
|
const {
|
||||||
currentPage,
|
data,
|
||||||
filters,
|
isLoading,
|
||||||
searchText,
|
isError,
|
||||||
);
|
isInitialLoading,
|
||||||
|
error,
|
||||||
|
refetch,
|
||||||
|
isFetching,
|
||||||
|
} = useTenants(currentPage, filters, searchText);
|
||||||
|
|
||||||
const {setRefetching} = useTenantContext()
|
const { setRefetching } = useTenantContext();
|
||||||
|
|
||||||
const paginate = (page) => {
|
const paginate = (page) => {
|
||||||
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
|
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
|
||||||
@ -25,8 +34,7 @@ const TenantsList = ({filters,searchText,setIsRefetching, setRefetchFn}) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Pass the refetch function to parent when component mounts
|
||||||
// Pass the refetch function to parent when component mounts
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRefetchFn(() => refetch); // store in parent
|
setRefetchFn(() => refetch); // store in parent
|
||||||
}, [setRefetchFn, refetch]);
|
}, [setRefetchFn, refetch]);
|
||||||
@ -41,12 +49,30 @@ const TenantsList = ({filters,searchText,setIsRefetching, setRefetchFn}) => {
|
|||||||
key: "name",
|
key: "name",
|
||||||
label: "Organization",
|
label: "Organization",
|
||||||
getValue: (t) => (
|
getValue: (t) => (
|
||||||
<div className="d-flex align-items-center py-1 cursor-pointer" onClick={()=>navigate(`/tenant/${t.id}`)}>
|
<div
|
||||||
<IconButton
|
className="d-flex align-items-center py-1 cursor-pointer"
|
||||||
iconClass="bx bx-sm bx-building"
|
onClick={() => navigate(`/tenant/${t.id}`)}
|
||||||
color="warning"
|
>
|
||||||
size={8}
|
{t.logoImage ? (
|
||||||
/>
|
<img
|
||||||
|
src={t.logoImage}
|
||||||
|
alt={`${t.name} Logo`}
|
||||||
|
style={{
|
||||||
|
height: "25px",
|
||||||
|
width: "25px",
|
||||||
|
objectFit: "contain",
|
||||||
|
borderRadius: "4px",
|
||||||
|
}}
|
||||||
|
className="me-2"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<IconButton
|
||||||
|
iconClass="bx bx-sm bx-building"
|
||||||
|
color="warning"
|
||||||
|
size={8}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{t.name || "N/A"}
|
{t.name || "N/A"}
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
@ -97,10 +123,8 @@ const TenantsList = ({filters,searchText,setIsRefetching, setRefetchFn}) => {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
if (isInitialLoading)
|
if (isInitialLoading)
|
||||||
return (
|
return <TenantTableSkeleton columns={TenantColumns} rows={13} />;
|
||||||
<TenantTableSkeleton columns={TenantColumns} rows={13} />
|
|
||||||
);
|
|
||||||
if (isError) return <div>{error.message}</div>;
|
if (isError) return <div>{error.message}</div>;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -146,13 +170,13 @@ const TenantsList = ({filters,searchText,setIsRefetching, setRefetchFn}) => {
|
|||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{data?.data?.length > 0 && (
|
{data?.data?.length > 0 && (
|
||||||
<Pagination
|
<Pagination
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
totalPages={data.totalPages}
|
totalPages={data.totalPages}
|
||||||
onPageChange={paginate}
|
onPageChange={paginate}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -5,21 +5,45 @@ import showToast from "../services/toastService";
|
|||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { setCurrentTenant } from "../slices/globalVariablesSlice";
|
import { setCurrentTenant } from "../slices/globalVariablesSlice";
|
||||||
import { ITEMS_PER_PAGE } from "../utils/constants";
|
import { ITEMS_PER_PAGE } from "../utils/constants";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
export const useTenants = (pageNumber, filter = {}, searchString = "") => {
|
|
||||||
|
|
||||||
|
const cleanFilter = (filter) => {
|
||||||
|
const cleaned = { ...filter };
|
||||||
|
|
||||||
|
["industryIds", "references"].forEach((key) => {
|
||||||
|
if (Array.isArray(cleaned[key]) && cleaned[key].length === 0) {
|
||||||
|
delete cleaned[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// moment.utc() to get consistent UTC ISO strings
|
||||||
|
if (!cleaned.startDate) {
|
||||||
|
cleaned.startDate = moment.utc().subtract(7, "days").startOf("day").toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cleaned.endDate) {
|
||||||
|
cleaned.endDate = moment.utc().startOf("day").toISOString();
|
||||||
|
}
|
||||||
|
return cleaned;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const useTenants = (pageNumber, filter, searchString = "") => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ["Tenants", pageNumber, JSON.stringify(filter), searchString],
|
queryKey: ["Tenants", pageNumber, filter, searchString],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
const cleanedFilter = cleanFilter(filter);
|
||||||
const response = await TenantRepository.getTenantList(
|
const response = await TenantRepository.getTenantList(
|
||||||
ITEMS_PER_PAGE,
|
ITEMS_PER_PAGE,
|
||||||
pageNumber,
|
pageNumber,
|
||||||
filter,
|
cleanedFilter,
|
||||||
searchString
|
searchString
|
||||||
);
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
staleTime: 60_000
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,10 @@
|
|||||||
import { api } from "../utils/axiosClient";
|
import { api } from "../utils/axiosClient";
|
||||||
|
|
||||||
export const TenantRepository = {
|
export const TenantRepository = {
|
||||||
getTenantList: (pageSize, pageNumber, filter, searchString) => {
|
getTenantList: ( pageSize, pageNumber, filter,searchString) => {
|
||||||
const params = new URLSearchParams();
|
const payloadJsonString = JSON.stringify(filter);
|
||||||
|
|
||||||
if (pageSize) params.append("pageSize", pageSize);
|
return api.get(`/api/Tenant/list?pageSize=${pageSize}&pageNumber=${pageNumber}&filter=${payloadJsonString}&searchString=${searchString}`);
|
||||||
if (pageNumber) params.append("pageNumber", pageNumber);
|
|
||||||
if (filter && Object.keys(filter).length > 0) {
|
|
||||||
params.append("filter", JSON.stringify(filter));
|
|
||||||
}
|
|
||||||
if (searchString) params.append("searchString", searchString);
|
|
||||||
|
|
||||||
return api.get(`/api/Tenant/list?${params.toString()}`);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getTenantDetails:(id)=>api.get(`/api/Tenant/details/${id}`),
|
getTenantDetails:(id)=>api.get(`/api/Tenant/details/${id}`),
|
||||||
|
|||||||
@ -67,6 +67,11 @@ export const ActiveTenant = "297e0d8f-f668-41b5-bfea-e03b354251c8"
|
|||||||
// 1 - Expense Manage
|
// 1 - Expense Manage
|
||||||
export const EXPENSE_MANAGEMENT = "a4e25142-449b-4334-a6e5-22f70e4732d7"
|
export const EXPENSE_MANAGEMENT = "a4e25142-449b-4334-a6e5-22f70e4732d7"
|
||||||
|
|
||||||
|
export const TENANT_STATUS = [
|
||||||
|
{id:"62b05792-5115-4f99-8ff5-e8374859b191",name:"Active"},
|
||||||
|
{id:"c0b5def8-087e-4235-b3a4-8e2f0ed91b94",name:"In Active"},
|
||||||
|
{id:"35d7840a-164a-448b-95e6-efb2ec84a751",name:"Supspended"}
|
||||||
|
]
|
||||||
|
|
||||||
export const CONSTANT_TEXT = {
|
export const CONSTANT_TEXT = {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user