Skip to content

Commit 37006af

Browse files
authored
Merge pull request #2546 from rushi-tekdi/feat-lead-mapping-new
added bacth and center section component
2 parents 78ea66d + 040d9f0 commit 37006af

File tree

5 files changed

+7190
-4
lines changed

5 files changed

+7190
-4
lines changed

apps/admin-app-repo/src/pages/user-instructor.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import deleteIcon from '../../public/images/deleteIcon.svg';
5454
import restoreIcon from '../../public/images/restore_user.svg';
5555
import CloseIcon from '@mui/icons-material/Close';
5656
import BatchListWidget from '@shared-lib-v2/MapUser/BatchListWidget';
57+
import MultipleBatchListWidget from '@shared-lib-v2/MapUser/MultipleBatchListWidget';
5758
import EmailSearchUser from '@shared-lib-v2/MapUser/EmailSearchUser';
5859
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
5960

@@ -799,6 +800,8 @@ const Facilitator = () => {
799800
const [selectedCenterId, setSelectedCenterId] = useState<
800801
string | string[] | null
801802
>(null);
803+
const [selectedCenterList, setSelectedCenterList] = useState<any[]>([]);
804+
const [selectedBatchList, setSelectedBatchList] = useState<any[]>([]);
802805
const [selectedUserId, setSelectedUserId] = useState<string | null>(null);
803806
const [isMappingInProgress, setIsMappingInProgress] = useState(false);
804807
const [userDetails, setUserDetails] = useState<any>(null);
@@ -812,6 +815,8 @@ const Facilitator = () => {
812815

813816
// Helper function to extract all batch IDs from the nested structure
814817
const extractBatchIds = (nestedStructure: any): string[] => {
818+
return nestedStructure;
819+
815820
const batchIds: string[] = [];
816821

817822
if (!nestedStructure || !Array.isArray(nestedStructure)) {
@@ -1043,6 +1048,8 @@ const Facilitator = () => {
10431048
if (reason !== 'backdropClick') {
10441049
setMapModalOpen(false);
10451050
setSelectedCenterId(null); // Reset center selection when dialog closes
1051+
setSelectedCenterList(null); // Reset center list selection when dialog closes
1052+
setSelectedBatchList(null); // Reset batch selection when dialog closes
10461053
setSelectedUserId(null); // Reset user selection when dialog closes
10471054
setUserDetails(null);
10481055
}
@@ -1132,13 +1139,23 @@ const Facilitator = () => {
11321139
)}
11331140
{formStep === 1 && (
11341141
<Box sx={{ mb: 3 }}>
1135-
<BatchListWidget
1142+
<MultipleBatchListWidget
11361143
value={selectedCenterId}
11371144
onChange={(centerId) => {
11381145
setSelectedCenterId(centerId);
11391146
console.log('Selected Center ID:', centerId);
11401147
}}
1141-
label="Select Center"
1148+
onCenterList={(centerList) => {
1149+
setSelectedCenterList(centerList || []);
1150+
console.log('############# centerList', centerList);
1151+
}}
1152+
selectedCenterList={selectedCenterList}
1153+
onBatchList={(batchList) => {
1154+
setSelectedBatchList(batchList || []);
1155+
console.log('############# batchList', batchList);
1156+
}}
1157+
selectedBatchList={selectedBatchList}
1158+
label="Select Batch"
11421159
required={true}
11431160
multiple={false}
11441161
/>
@@ -1243,6 +1260,8 @@ const Facilitator = () => {
12431260
// Close dialog
12441261
setMapModalOpen(false);
12451262
setSelectedCenterId(null);
1263+
setSelectedCenterList(null);
1264+
setSelectedBatchList(null);
12461265
setSelectedUserId(null);
12471266
// Refresh the data
12481267
searchData(prefilledFormData, 0);

apps/admin-app-repo/src/pages/user-leader.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import CenteredLoader from '@/components/CenteredLoader/CenteredLoader';
6363
import ResetFiltersButton from '@/components/ResetFiltersButton/ResetFiltersButton';
6464
import restoreIcon from '../../public/images/restore_user.svg';
6565
import { showToastMessage } from '@/components/Toastify';
66-
import CenterListWidget from '@shared-lib-v2/MapUser/CenterListWidget';
66+
import MultipleCenterListWidgetNew from '@shared-lib-v2/MapUser/MultipleCenterListWidgetNew';
6767
import EmailSearchUser from '@shared-lib-v2/MapUser/EmailSearchUser';
6868
import { API_ENDPOINTS } from '@/utils/API/APIEndpoints';
6969
import { updateUser } from '@/services/CreateUserService';
@@ -576,6 +576,7 @@ const UserLeader = () => {
576576
const [selectedCenterId, setSelectedCenterId] = useState<
577577
string | string[] | null
578578
>(null);
579+
const [selectedCenterList, setSelectedCenterList] = useState<any[]>([]);
579580
const [selectedUserId, setSelectedUserId] = useState<string | null>(null);
580581
const [isMappingInProgress, setIsMappingInProgress] = useState(false);
581582
const [userDetails, setUserDetails] = useState<any>(null);
@@ -716,6 +717,7 @@ const UserLeader = () => {
716717
if (reason !== 'backdropClick') {
717718
setMapModalOpen(false);
718719
setSelectedCenterId(null); // Reset center selection when dialog closes
720+
setSelectedCenterList([]); // Reset center list when dialog closes
719721
setSelectedUserId(null); // Reset user selection when dialog closes
720722
setUserDetails(null);
721723
}
@@ -805,12 +807,17 @@ const UserLeader = () => {
805807
)}
806808
{formStep === 1 && (
807809
<Box sx={{ mb: 3 }}>
808-
<CenterListWidget
810+
<MultipleCenterListWidgetNew
809811
value={selectedCenterId}
810812
onChange={(centerId) => {
811813
setSelectedCenterId(centerId);
812814
console.log('Selected Center ID:', centerId);
813815
}}
816+
onCenterList={(centerList) => {
817+
setSelectedCenterList(centerList || []);
818+
console.log('############# centerList', centerList);
819+
}}
820+
selectedCenterList={selectedCenterList}
814821
label="Select Center"
815822
required={true}
816823
multiple={false}
@@ -915,6 +922,7 @@ const UserLeader = () => {
915922
// Close dialog
916923
setMapModalOpen(false);
917924
setSelectedCenterId(null);
925+
setSelectedCenterList([]);
918926
setSelectedUserId(null);
919927
// Refresh the data
920928
searchData(prefilledFormData, 0);

0 commit comments

Comments
 (0)