diff --git a/src/pages/observation/[observationId]/index.tsx b/src/pages/observation/[observationId]/index.tsx index d4abb538..b46b7a77 100644 --- a/src/pages/observation/[observationId]/index.tsx +++ b/src/pages/observation/[observationId]/index.tsx @@ -43,6 +43,8 @@ import Entity from '@/components/observations/Entity'; import SearchBar from '@/components/Searchbar'; import { telemetryFactory } from '@/utils/telemetry'; import centers from '@/pages/centers'; +import Loader from '@/components/Loader'; + interface EntityData { cohortId?: string; name?: string; @@ -67,6 +69,7 @@ const ObservationDetails = () => { const [fetchEntityResponse, setFetchEntityResponse] = useState([]); const [entityData, setEntityData] = useState([]); const [filteredEntityData, setFilteredEntityData] = useState([]); + const [loading, setLoading] = React.useState(false); @@ -303,6 +306,7 @@ setFilteredEntityData(result) useEffect(() => { const handleCohortChange = async () => { try { + setLoading(true) console.log('handlecohortChange'); let filters = { cohortId: selectedCohort, @@ -351,6 +355,8 @@ setFilteredEntityData(result) console.error('Error fetching cohort list:', error); } finally { + setLoading(false) + } }; if(selectedCohort && selectedCohort!=='') @@ -421,35 +427,6 @@ setFilteredEntityData(result) }); }; - // const renderEntityData = (data: EntityData[], entityType: string) => - // data?.map((item, index) => ( - // // - // // {toPascalCase(item?.name) } - // // - // // - // entityType!==ObservationEntityType.CENTER?onStartObservation(item?.userId):onStartObservation(item?.cohortId)} - // /> - // )); - const renderEntityData = (data: EntityData[], entityType: string) => { if (!data || data.length === 0) { @@ -685,7 +662,26 @@ setFilteredEntityData(result) - {entityContent} + + {loading ? ( + + ) : Data.length === 0 ? ( + {t('OBSERVATION.NO_DATA_FOUND',{ + entity:entity, + })} + ) : ( + entityContent + )} + + {/* {totalCountForCenter > 6 && entity === ObservationEntityType.CENTER && ( { }; export const getEmailPattern = (): string => { - return '^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}$'; + return '^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}$'; }; export const translateString = (t: any, label: string) => {