hot refactor

This commit is contained in:
burnettk 2022-09-29 18:16:53 -04:00
parent 07afcabeb0
commit 7478164cde
1 changed files with 55 additions and 57 deletions

View File

@ -7,18 +7,10 @@ import HttpService from '../services/HttpService';
import ErrorContext from '../contexts/ErrorContext'; import ErrorContext from '../contexts/ErrorContext';
import { RecentProcessModel } from '../interfaces'; import { RecentProcessModel } from '../interfaces';
export default function ProcessModelShow() { const storeRecentProcessModelInLocalStorage = (
const params = useParams(); processModelForStorage: any,
const setErrorMessage = (useContext as any)(ErrorContext)[1]; params: any
) => {
const [processModel, setProcessModel] = useState({});
const [processInstanceResult, setProcessInstanceResult] = useState(null);
const [reloadModel, setReloadModel] = useState(false);
useEffect(() => {
const storeRecentProcessModelInLocalStorage = (
processModelForStorage: any
) => {
if ( if (
params.process_group_id === undefined || params.process_group_id === undefined ||
params.process_model_id === undefined params.process_model_id === undefined
@ -65,17 +57,23 @@ export default function ProcessModelShow() {
const stringRepresentingArray = JSON.stringify(array); const stringRepresentingArray = JSON.stringify(array);
// and store it in localStorage as "recentProcessModels" // and store it in localStorage as "recentProcessModels"
window.localStorage.setItem( window.localStorage.setItem('recentProcessModels', stringRepresentingArray);
'recentProcessModels',
stringRepresentingArray
);
} }
}; };
export default function ProcessModelShow() {
const params = useParams();
const setErrorMessage = (useContext as any)(ErrorContext)[1];
const [processModel, setProcessModel] = useState({});
const [processInstanceResult, setProcessInstanceResult] = useState(null);
const [reloadModel, setReloadModel] = useState(false);
useEffect(() => {
const processResult = (result: object) => { const processResult = (result: object) => {
setProcessModel(result); setProcessModel(result);
setReloadModel(false); setReloadModel(false);
storeRecentProcessModelInLocalStorage(result); storeRecentProcessModelInLocalStorage(result, params);
}; };
HttpService.makeCallToBackend({ HttpService.makeCallToBackend({
path: `/process-models/${params.process_group_id}/${params.process_model_id}`, path: `/process-models/${params.process_group_id}/${params.process_model_id}`,