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">Profile</div>
|
||||
</div>
|
||||
|
||||
<div className="col rounded-2 bg-light justify-content-start p-2">
|
||||
{data?.description && (
|
||||
<div className="col rounded-2 bg-light justify-content-start p-2">
|
||||
<p className="m-0">{data?.description}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
<div className="row ">
|
||||
<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 SelectMultiple from "../common/SelectMultiple";
|
||||
import { useIndustries } from "../../hooks/useTenant";
|
||||
import { reference } from "../../utils/constants";
|
||||
import { reference, TENANT_STATUS } from "../../utils/constants";
|
||||
import { DateRangePicker1 } from "../common/DateRangePicker";
|
||||
import moment from "moment";
|
||||
|
||||
@ -22,9 +22,7 @@ const TenantFilterPanel = ({onApply}) => {
|
||||
};
|
||||
const onSubmit = (formData) => {
|
||||
onApply({
|
||||
...formData,
|
||||
startDate: moment.utc(formData.startDate, "DD-MM-YYYY").toISOString(),
|
||||
endDate: moment.utc(formData.endDate, "DD-MM-YYYY").toISOString(),
|
||||
...formData
|
||||
})
|
||||
};
|
||||
const onClear = () => {
|
||||
@ -38,26 +36,42 @@ const TenantFilterPanel = ({onApply}) => {
|
||||
<FormProvider {...method}>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="text-start mb-1">
|
||||
<DateRangePicker1
|
||||
<div className="text-start my-2">
|
||||
<DateRangePicker1
|
||||
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
||||
startField="startDate"
|
||||
endField="endDate"
|
||||
resetSignal={resetKey}
|
||||
/>
|
||||
<SelectMultiple
|
||||
</div>
|
||||
<div className="text-strat mb-2">
|
||||
<SelectMultiple
|
||||
name="industryIds"
|
||||
label="Industries :"
|
||||
label="Industries"
|
||||
options={data}
|
||||
labelKey="name"
|
||||
valueKey="id"
|
||||
/>
|
||||
<SelectMultiple
|
||||
</div>
|
||||
|
||||
<div className="text-start mb-2">
|
||||
<SelectMultiple
|
||||
name="references"
|
||||
label="References :"
|
||||
label="References"
|
||||
options={reference}
|
||||
labelKey="name"
|
||||
valueKey="val"
|
||||
/>
|
||||
</div>
|
||||
<div className="text-start">
|
||||
<SelectMultiple
|
||||
name="tenantStatusIds"
|
||||
label="Tenant Status"
|
||||
options={TENANT_STATUS}
|
||||
labelKey="name"
|
||||
valueKey="id"
|
||||
/>
|
||||
</div>
|
||||
{/* <SelectMultiple
|
||||
name="references"
|
||||
label="Industries :"
|
||||
|
@ -64,11 +64,10 @@ export const subscriptionDefaultValues = {
|
||||
autoRenew: false,
|
||||
};
|
||||
|
||||
|
||||
export const filterSchema = z.object({
|
||||
industryIds: 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(),
|
||||
startDate: z.string().optional(),
|
||||
endDate: z.string().optional(),
|
||||
@ -76,10 +75,10 @@ export const filterSchema = z.object({
|
||||
export const defaultFilterValues = {
|
||||
industryIds: [],
|
||||
// createdByIds: [],
|
||||
// tenantStatusIds: [],
|
||||
tenantStatusIds: [],
|
||||
references: [],
|
||||
startDate: "YYYY-MM-DDTHH:mm:ssZ",
|
||||
endDate: "YYYY-MM-DDTHH:mm:ssZ",
|
||||
startDate:null,
|
||||
endDate:null,
|
||||
};
|
||||
|
||||
export const getStepFields = (stepIndex) => {
|
||||
|
@ -8,16 +8,25 @@ import { TenantTableSkeleton } from "./TenanatSkeleton";
|
||||
import { useTenantContext } from "../../pages/Tenant/TenantPage";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
const TenantsList = ({filters,searchText,setIsRefetching, setRefetchFn}) => {
|
||||
const TenantsList = ({
|
||||
filters,
|
||||
searchText,
|
||||
setIsRefetching,
|
||||
setRefetchFn,
|
||||
}) => {
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const navigate = useNavigate()
|
||||
const { data, isLoading, isError, isInitialLoading, error,refetch, isFetching } = useTenants(
|
||||
currentPage,
|
||||
filters,
|
||||
searchText,
|
||||
);
|
||||
const navigate = useNavigate();
|
||||
const {
|
||||
data,
|
||||
isLoading,
|
||||
isError,
|
||||
isInitialLoading,
|
||||
error,
|
||||
refetch,
|
||||
isFetching,
|
||||
} = useTenants(currentPage, filters, searchText);
|
||||
|
||||
const {setRefetching} = useTenantContext()
|
||||
const { setRefetching } = useTenantContext();
|
||||
|
||||
const paginate = (page) => {
|
||||
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(() => {
|
||||
setRefetchFn(() => refetch); // store in parent
|
||||
}, [setRefetchFn, refetch]);
|
||||
@ -41,12 +49,30 @@ const TenantsList = ({filters,searchText,setIsRefetching, setRefetchFn}) => {
|
||||
key: "name",
|
||||
label: "Organization",
|
||||
getValue: (t) => (
|
||||
<div className="d-flex align-items-center py-1 cursor-pointer" onClick={()=>navigate(`/tenant/${t.id}`)}>
|
||||
<IconButton
|
||||
iconClass="bx bx-sm bx-building"
|
||||
color="warning"
|
||||
size={8}
|
||||
/>
|
||||
<div
|
||||
className="d-flex align-items-center py-1 cursor-pointer"
|
||||
onClick={() => navigate(`/tenant/${t.id}`)}
|
||||
>
|
||||
{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"}
|
||||
</div>
|
||||
),
|
||||
@ -97,10 +123,8 @@ const TenantsList = ({filters,searchText,setIsRefetching, setRefetchFn}) => {
|
||||
),
|
||||
},
|
||||
];
|
||||
if (isInitialLoading)
|
||||
return (
|
||||
<TenantTableSkeleton columns={TenantColumns} rows={13} />
|
||||
);
|
||||
if (isInitialLoading)
|
||||
return <TenantTableSkeleton columns={TenantColumns} rows={13} />;
|
||||
if (isError) return <div>{error.message}</div>;
|
||||
return (
|
||||
<>
|
||||
@ -146,13 +170,13 @@ const TenantsList = ({filters,searchText,setIsRefetching, setRefetchFn}) => {
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
{data?.data?.length > 0 && (
|
||||
<Pagination
|
||||
currentPage={currentPage}
|
||||
totalPages={data.totalPages}
|
||||
onPageChange={paginate}
|
||||
/>
|
||||
)}
|
||||
{data?.data?.length > 0 && (
|
||||
<Pagination
|
||||
currentPage={currentPage}
|
||||
totalPages={data.totalPages}
|
||||
onPageChange={paginate}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
@ -5,21 +5,45 @@ import showToast from "../services/toastService";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setCurrentTenant } from "../slices/globalVariablesSlice";
|
||||
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({
|
||||
queryKey: ["Tenants", pageNumber, JSON.stringify(filter), searchString],
|
||||
queryKey: ["Tenants", pageNumber, filter, searchString],
|
||||
queryFn: async () => {
|
||||
const cleanedFilter = cleanFilter(filter);
|
||||
const response = await TenantRepository.getTenantList(
|
||||
ITEMS_PER_PAGE,
|
||||
pageNumber,
|
||||
filter,
|
||||
cleanedFilter,
|
||||
searchString
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
keepPreviousData: true,
|
||||
staleTime: 60_000
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1,17 +1,10 @@
|
||||
import { api } from "../utils/axiosClient";
|
||||
|
||||
export const TenantRepository = {
|
||||
getTenantList: (pageSize, pageNumber, filter, searchString) => {
|
||||
const params = new URLSearchParams();
|
||||
getTenantList: ( pageSize, pageNumber, filter,searchString) => {
|
||||
const payloadJsonString = JSON.stringify(filter);
|
||||
|
||||
if (pageSize) params.append("pageSize", pageSize);
|
||||
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()}`);
|
||||
return api.get(`/api/Tenant/list?pageSize=${pageSize}&pageNumber=${pageNumber}&filter=${payloadJsonString}&searchString=${searchString}`);
|
||||
},
|
||||
|
||||
getTenantDetails:(id)=>api.get(`/api/Tenant/details/${id}`),
|
||||
|
@ -67,6 +67,11 @@ export const ActiveTenant = "297e0d8f-f668-41b5-bfea-e03b354251c8"
|
||||
// 1 - Expense Manage
|
||||
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 = {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user