Showing proper name of project in global project dropdown when assigning project for first time

This commit is contained in:
ashutosh.nehete 2025-06-19 14:51:10 +05:30
parent 77f5632506
commit 21e7ca2157
2 changed files with 4 additions and 3 deletions

View File

@ -115,9 +115,6 @@ const Header = () => {
if (projectExist) {
cacheData("hasReceived", false);
}
if(!selectedProject){
dispatch(setProjectId(projectNames[0]?.id));
}
}
},
[fetchData,projectNames,selectedProject]

View File

@ -175,6 +175,7 @@ export const useProjectName = () => {
const [loading, setLoading] = useState(true);
const [projectNames, setProjectName] = useState([]);
const [Error, setError] = useState();
const dispatch = useDispatch();
const fetchData = async () => {
try {
@ -182,6 +183,9 @@ export const useProjectName = () => {
setProjectName(response.data);
cacheData("basicProjectNameList", response.data);
setLoading(false);
if(response.data.length === 1){
dispatch(setProjectId(response.data[0]?.id));
}
} catch (err) {
setError("Failed to fetch data.");
setLoading(false);