MCPcopy Create free account
hub / github.com/FeatureProbe/FeatureProbe / Project

Function Project

ui/src/pages/project/index.tsx:67–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65];
66
67const Project = () => {
68 const [ projectList, saveProjectList ] = useState<IProject[]>([]);
69 const [ isAdd, setIsAdd ] = useState<boolean>(true);
70 const [ visible, setVisible ] = useState<boolean>(false);
71 const [ projectKey, setProjectKey ] = useState<string>('');
72 const [ isLoading, saveIsLoading ] = useState<boolean>(true);
73 const [run, saveRun] = useState<boolean>(false);
74 const [stepIndex, saveStepIndex] = useState<number>(0);
75
76 const intl = useIntl();
77 const { userInfo } = HeaderContainer.useContainer();
78
79 const getUserGuide = useCallback(() => {
80 getFromDictionary<IDictionary>(USER_GUIDE_PROJECT).then(res => {
81 const { success, data } = res;
82 if (success && data) {
83 const savedData = JSON.parse(data.value);
84 if (parseInt(savedData) !== STEPS.length) {
85 setTimeout(() => {
86 saveRun(true);
87 }, 500);
88 saveStepIndex(parseInt(savedData));
89 }
90 } else {
91 setTimeout(() => {
92 saveRun(true);
93 }, 500);
94 }
95 });
96 }, []);
97
98 const init = useCallback(async () => {
99 saveIsLoading(true);
100 const res = await getProjectList<IProject[]>();
101 const { data } = res;
102 saveIsLoading(false);
103 if (res.success && data) {
104 saveProjectList(data);
105 if (data.length > 0) {
106 getUserGuide();
107 }
108 } else {
109 message.error(res.message || intl.formatMessage({id: 'projects.list.error.text'}));
110 }
111 }, [getUserGuide, intl]);
112
113 useEffect(() => {
114 init();
115 }, [init]);
116
117 const handleAddProject = useCallback(() => {
118 setIsAdd(true);
119 setVisible(true);
120 }, []);
121
122 const handleEditProject = useCallback((projectKey: string) => {
123 setIsAdd(false);
124 setVisible(true);

Callers

nothing calls this directly

Calls 3

getFromDictionaryFunction · 0.90
saveDictionaryFunction · 0.90
initFunction · 0.50

Tested by

no test coverage detected