|
1 | | -import { SplitLayout } from "layouts/SplitLayout/SplitLayout"; |
2 | | -import { Orientation } from "hooks/useSplit/Orientation"; |
| 1 | +import { useState } from "react"; |
| 2 | +// import { SplitLayout } from "layouts/SplitLayout/SplitLayout"; |
| 3 | +// import { Orientation } from "hooks/useSplit/Orientation"; |
3 | 4 | import { ReceiveColumn } from "pages/TestingPage/ReceiveColumn/ReceiveColumn"; |
4 | 5 | import { OrderColumn } from "pages/TestingPage/OrderColumn/OrderColumn"; |
5 | 6 | import { MessagesColumn } from "pages/TestingPage/MessagesColumn/MessagesColumn"; |
6 | 7 | import { ChartsColumn } from "./ChartsColumn/ChartsColumn"; |
7 | 8 | import styles from "pages/TestingPage/TestingPage.module.scss"; |
8 | | -import incomingMessage from "assets/svg/incoming-message.svg" |
9 | | -import paperAirplane from "assets/svg/paper-airplane.svg" |
10 | | -import outgoingMessage from "assets/svg/outgoing-message.svg" |
11 | | -import chart from "assets/svg/chart.svg" |
| 9 | +import incomingMessage from "assets/svg/incoming-message.svg"; |
| 10 | +import paperAirplane from "assets/svg/paper-airplane.svg"; |
| 11 | +import outgoingMessage from "assets/svg/outgoing-message.svg"; |
| 12 | +import chart from "assets/svg/chart.svg"; |
12 | 13 |
|
13 | 14 | export const TestingPage = () => { |
14 | | - return ( |
15 | | - <div id={styles.wrapper}> |
16 | | - <div id={styles.body}> |
17 | | - <SplitLayout |
18 | | - components={[ |
19 | | - { |
20 | | - component: <ChartsColumn />, |
21 | | - collapsedIcon: chart |
22 | | - }, |
23 | | - { |
24 | | - component: <ReceiveColumn />, |
25 | | - collapsedIcon: incomingMessage |
26 | | - }, |
27 | | - { |
28 | | - component: <OrderColumn />, |
29 | | - collapsedIcon: paperAirplane |
30 | | - }, |
31 | | - { |
32 | | - component: <MessagesColumn />, |
33 | | - collapsedIcon: outgoingMessage |
34 | | - }, |
35 | | - ]} |
36 | | - orientation={Orientation.HORIZONTAL} |
37 | | - ></SplitLayout> |
| 15 | + const [collapsed, setCollapsed] = useState({ |
| 16 | + charts: false, |
| 17 | + receive: false, |
| 18 | + order: false, |
| 19 | + messages: false, |
| 20 | + }); |
| 21 | + |
| 22 | + const toggleCollapse = (key: keyof typeof collapsed) => { |
| 23 | + setCollapsed((prev) => ({ ...prev, [key]: !prev[key] })); |
| 24 | + }; |
| 25 | + |
| 26 | + const components = [ |
| 27 | + { |
| 28 | + key: "charts" as const, |
| 29 | + icon: chart, |
| 30 | + component: <ChartsColumn />, |
| 31 | + collapsed: collapsed.charts, |
| 32 | + }, |
| 33 | + { |
| 34 | + key: "receive" as const, |
| 35 | + icon: incomingMessage, |
| 36 | + component: <ReceiveColumn />, |
| 37 | + collapsed: collapsed.receive, |
| 38 | + }, |
| 39 | + { |
| 40 | + key: "order" as const, |
| 41 | + icon: paperAirplane, |
| 42 | + component: <OrderColumn />, |
| 43 | + collapsed: collapsed.order, |
| 44 | + }, |
| 45 | + { |
| 46 | + key: "messages" as const, |
| 47 | + icon: outgoingMessage, |
| 48 | + component: <MessagesColumn />, |
| 49 | + collapsed: collapsed.messages, |
| 50 | + }, |
| 51 | + ]; |
| 52 | + |
| 53 | + const visibleComponents = components.filter(c => !c.collapsed); |
| 54 | + |
| 55 | + return ( |
| 56 | + <div id={styles.wrapper}> |
| 57 | + <div id={styles.body}> |
| 58 | + <div className="d-flex flex-row gap-2 p-2"> |
| 59 | + {components.map(({ key }) => ( |
| 60 | + <button |
| 61 | + key={key} |
| 62 | + className={`btn btn-sm btn-${collapsed[key] ? "outline-primary" : "primary"}`} |
| 63 | + onClick={() => toggleCollapse(key)} |
| 64 | + > |
| 65 | + {collapsed[key] ? `Mostrar ${key}` : `Ocultar ${key}`} |
| 66 | + </button> |
| 67 | + ))} |
| 68 | + </div> |
| 69 | + <div style={{ display: "flex", height: "100%", gap: "1rem" }}> |
| 70 | + {visibleComponents.map(({ key, component }) => ( |
| 71 | + <div key={key} style={{ flex: `1 1 ${100 / visibleComponents.length}%`, overflow: "auto" }}> |
| 72 | + {component} |
38 | 73 | </div> |
| 74 | + ))} |
39 | 75 | </div> |
40 | | - ); |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + ); |
41 | 79 | }; |
0 commit comments