Showing proper name of project in global project dropdown when assigning project for first time
This commit is contained in:
parent
77f5632506
commit
21e7ca2157
@ -115,9 +115,6 @@ const Header = () => {
|
|||||||
if (projectExist) {
|
if (projectExist) {
|
||||||
cacheData("hasReceived", false);
|
cacheData("hasReceived", false);
|
||||||
}
|
}
|
||||||
if(!selectedProject){
|
|
||||||
dispatch(setProjectId(projectNames[0]?.id));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[fetchData,projectNames,selectedProject]
|
[fetchData,projectNames,selectedProject]
|
||||||
|
|||||||
@ -175,6 +175,7 @@ export const useProjectName = () => {
|
|||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [projectNames, setProjectName] = useState([]);
|
const [projectNames, setProjectName] = useState([]);
|
||||||
const [Error, setError] = useState();
|
const [Error, setError] = useState();
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
@ -182,6 +183,9 @@ export const useProjectName = () => {
|
|||||||
setProjectName(response.data);
|
setProjectName(response.data);
|
||||||
cacheData("basicProjectNameList", response.data);
|
cacheData("basicProjectNameList", response.data);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
if(response.data.length === 1){
|
||||||
|
dispatch(setProjectId(response.data[0]?.id));
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError("Failed to fetch data.");
|
setError("Failed to fetch data.");
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user