|
1 | | -import { useEventLists } from '../../../../store/store.ts'; |
2 | 1 | import * as Styled from './Callstack.styled.ts'; |
3 | | -import InfoIcon from '../../../../components/InfoIcon/InfoIcon.tsx'; |
4 | | -import InfoModal from '../../../../components/Modal/Modal.tsx'; |
5 | | -import useBoolean from '../../../../utils/useBoolean.tsx'; |
| 2 | +import InfoIcon from 'components/InfoIcon/InfoIcon.tsx'; |
| 3 | +import useBoolean from 'utils/hooks/useBoolean.ts'; |
6 | 4 | import { Zoom } from '@mui/material'; |
7 | 5 | import { List } from '../../Home.styled.ts'; |
| 6 | +import CallStackModal from './Callstack.modal.tsx'; |
| 7 | +import { useQueueManagerStore } from 'store/store.ts'; |
8 | 8 |
|
9 | 9 | function CallStack({ className }: { className?: string }) { |
10 | | - const tasks = useEventLists((state) => state.callstack); |
11 | | - const [open, setOpen, setClose] = useBoolean(false); |
| 10 | + const tasks = useQueueManagerStore((state) => state.callstack); |
| 11 | + const [isOpened, toggle] = useBoolean(false); |
12 | 12 |
|
13 | 13 | return ( |
14 | 14 | <List className={className}> |
15 | 15 | <span>CallStack</span> |
16 | 16 | <Styled.Callstack> |
17 | | - <InfoIcon onClick={setOpen} /> |
18 | | - {tasks.map(({ display: stack }) => ( |
19 | | - <Zoom in key={stack}> |
20 | | - <Styled.CallstackElement>{stack}</Styled.CallstackElement> |
| 17 | + <InfoIcon onClick={toggle} /> |
| 18 | + {tasks.map((task) => ( |
| 19 | + <Zoom in key={task}> |
| 20 | + <Styled.CallstackElement>{task}</Styled.CallstackElement> |
21 | 21 | </Zoom> |
22 | 22 | ))} |
23 | | - <InfoModal isOpen={open} onClose={setClose}> |
24 | | - <h2>Call stack</h2> |
25 | | - <Styled.CloseIcon onClick={setClose} /> |
26 | | - <p> |
27 | | - A call stack is a mechanism for an interpreter to keep track of its |
28 | | - place in a script that calls multiple functions — what function is |
29 | | - currently being run and what functions are called from within that |
30 | | - function, etc. |
31 | | - </p> |
32 | | - <ul> |
33 | | - <li> |
34 | | - When a script calls a function, the interpreter adds it to the |
35 | | - call stack and then starts carrying out the function. |
36 | | - </li> |
37 | | - <li> |
38 | | - Any functions that are called by that function are added to the |
39 | | - call stack further up, and run where their calls are reached. |
40 | | - </li> |
41 | | - <li> |
42 | | - When the current function is finished, the interpreter takes it |
43 | | - off the stack and resumes execution where it left off in the last |
44 | | - code listing. |
45 | | - </li> |
46 | | - <li> |
47 | | - If the stack takes up more space than it was assigned, a "stack |
48 | | - overflow" error is thrown. |
49 | | - </li> |
50 | | - </ul> |
51 | | - </InfoModal> |
| 23 | + <CallStackModal isOpened={isOpened} toggle={toggle} /> |
52 | 24 | </Styled.Callstack> |
53 | 25 | </List> |
54 | 26 | ); |
|
0 commit comments