From f49ace98af69d88453594da62b44515444205007 Mon Sep 17 00:00:00 2001 From: "vluk@2fi-solutions.com.hk" Date: Wed, 14 Jan 2026 19:28:44 +0800 Subject: [PATCH] no message --- .../ClientSearchPage/ClientSearchForm.js | 37 +++++++++-- .../UserInformationCard.js | 62 +++++++++++++++---- src/pages/lionerUserDetailPage/index.js | 2 + 3 files changed, 82 insertions(+), 19 deletions(-) diff --git a/src/pages/client/ClientSearchPage/ClientSearchForm.js b/src/pages/client/ClientSearchPage/ClientSearchForm.js index 06b1750..ad89060 100644 --- a/src/pages/client/ClientSearchPage/ClientSearchForm.js +++ b/src/pages/client/ClientSearchPage/ClientSearchForm.js @@ -6,7 +6,7 @@ import { } from '@mui/material'; import MainCard from "../../../components/MainCard"; import {useForm} from "react-hook-form"; -import {useContext, useState} from "react"; +import {useContext, useState, useEffect} from "react"; // import {useContext, useEffect, useState} from "react"; import Autocomplete from '@mui/material/Autocomplete'; import * as React from "react"; @@ -39,7 +39,7 @@ import {LIONER_FORM_THEME, CARD_MAX_WIDTH} from "../../../themes/themeConst"; import Collapse from '@mui/material/Collapse'; import {ExpandMore} from "@mui/icons-material"; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; -import { isNull } from 'lodash'; +import axios from "axios"; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -53,6 +53,14 @@ const ClientSearchForm = ({applySearch, setExpanded,expanded}) => { // const { setIsUploading } = useContext(UploadContext); const ability = useContext(AbilityContext); + const [consultantList, setConsultantList] = useState([]); + const [selectedConsultant, setSelectedConsultant] = useState(null); + + useEffect(() => { + axios.get(`${apiPath}/consultant/combo`).then(res => { + setConsultantList(res.data.records); + }); + }, []); // const [selectedRegion, setSelectedRegion] = useState(null); // const [selectedType, setSelectedType] = useState(null); @@ -97,10 +105,7 @@ const ClientSearchForm = ({applySearch, setExpanded,expanded}) => { ...data, createDateFrom: createDateFrom === null ? null : dayjs(createDateFrom).format('YYYY-MM-DD'), createDateTo: createDateTo === null ? null : dayjs(createDateTo).format('YYYY-MM-DD'), - // region: selectedRegion === null ? null : selectedRegion.label, - // type: selectedType === null ? null :selectedType.label, - // consultantIdList: getIdList(selectedConsultants), - // caseManagerIdList: getIdList(selectedCaseManager), + consultantId: selectedConsultant ? selectedConsultant.id : null, }; applySearch(criteria); }; @@ -203,6 +208,7 @@ const ClientSearchForm = ({applySearch, setExpanded,expanded}) => { // }, [userConsultant,consultantList]); function resetForm(){ + setSelectedConsultant(null); setCreateDateFrom(null); setCreateDateTo(null); // setToDate(null); @@ -284,6 +290,25 @@ const ClientSearchForm = ({applySearch, setExpanded,expanded}) => { /> + + Consultant + option.name || ""} + value={selectedConsultant} + onChange={(event, newValue) => setSelectedConsultant(newValue)} + renderInput={(params) => ( + + )} + /> + + {/* Case Manager { const params = useParams(); @@ -54,23 +54,28 @@ const UserInformationCard = ({isCollectData, updateUserObject,userData, setLocked(!locked); }; + const [consultantList, setConsultantList] = useState([]); + const [selectedConsultants, setSelectedConsultants] = useState([]); + useEffect(() => { - // axios.get(`${apiPath}${GET_USER_GROUP_COMBO_LIST}`) - // .then((response) => { - // if (response.status === 200) { - // setSubDivisionList(response.data.records); - // } - // }) - // .catch(error => { - // console.log(error); - // return false; - // }); + // Fetch all available consultants for the dropdown + axios.get(`${apiPath}/consultant/combo`).then(res => { + setConsultantList(res.data.records); + }); }, []); useEffect(() => { setErrors(requestError); }, [requestError]); + useEffect(() => { + if (userData && userData.consultantIds && consultantList.length > 0) { + // Find the full objects from the master list based on the user's IDs + const initialSelection = consultantList.filter(c => userData.consultantIds.includes(c.id)); + setSelectedConsultants(initialSelection); + } + }, [userData, consultantList]); + useEffect(() => { //if user data from parent are not null if (Object.keys(userData).length > 0 && userData !== undefined) { @@ -154,6 +159,7 @@ const UserInformationCard = ({isCollectData, updateUserObject,userData, ...values, locked: locked, twoFactorEnabled: twoFactorEnabled, + consultantIds: selectedConsultants.map(c => c.id), } updateUserObject(objectData); } @@ -432,6 +438,36 @@ const UserInformationCard = ({isCollectData, updateUserObject,userData, + + + + Assigned Consultants + + + option.name || ""} + // This ensures the UI reflects what is currently in the userData state + value={consultantList.filter(c => (userData?.consultantIds || []).includes(c.id))} + isOptionEqualToValue={(option, value) => option.id === value.id} + onChange={(event, newValue) => { + // This updates the object that gets sent to the backend + setUserData({ + ...userData, + consultantIds: newValue.map(c => c.id) + }); + }} + renderInput={(params) => ( + + )} + /> + + + + {!isNewRecord && ( diff --git a/src/pages/lionerUserDetailPage/index.js b/src/pages/lionerUserDetailPage/index.js index 2579b50..77df510 100644 --- a/src/pages/lionerUserDetailPage/index.js +++ b/src/pages/lionerUserDetailPage/index.js @@ -156,6 +156,7 @@ const UserMaintainPage = () => { "userGroupId": editedUserData.userGroupId ?? null, "password": editedUserData.password ?? null, "twoFactorEnabled": editedUserData.twoFactorEnabled ?? false, + "consultantIds": editedUserData.consultantIds ?? [], // "addGroupIds": userGroupData, // "removeGroupIds": deletedUserGroup, // "addAuthIds": userAuthData, @@ -204,6 +205,7 @@ const UserMaintainPage = () => {