|
1 |
| -import { Button, Input, Modal, Typography } from 'antd'; |
| 1 | +import { Button, Input, Typography } from 'antd'; |
2 | 2 | import type React from 'react';
|
3 | 3 | import { useMemo, useState } from 'react';
|
4 | 4 | import CloseOutlined from '../../icons/close.svg';
|
@@ -84,113 +84,73 @@ export const HistorySelector: React.FC<HistorySelectorProps> = ({
|
84 | 84 | <HistoryOutlined width={24} height={24} />
|
85 | 85 | </div>
|
86 | 86 |
|
87 |
| - <Modal |
88 |
| - open={isModalOpen} |
89 |
| - onCancel={() => setIsModalOpen(false)} |
90 |
| - footer={null} |
91 |
| - width="100%" |
92 |
| - closable={false} |
93 |
| - centered={false} |
94 |
| - transitionName="" |
95 |
| - maskTransitionName="" |
96 |
| - style={{ |
97 |
| - margin: 0, |
98 |
| - padding: 0, |
99 |
| - maxWidth: 'none', |
100 |
| - top: 'auto', |
101 |
| - bottom: 0, |
102 |
| - }} |
103 |
| - styles={{ |
104 |
| - wrapper: { |
105 |
| - alignItems: 'flex-end', |
106 |
| - justifyContent: 'center', |
107 |
| - paddingBottom: 0, |
108 |
| - display: 'flex', |
109 |
| - }, |
110 |
| - body: { |
111 |
| - height: '70vh', |
112 |
| - padding: 0, |
113 |
| - margin: 0, |
114 |
| - }, |
115 |
| - content: { |
116 |
| - height: '70vh', |
117 |
| - borderRadius: '12px 12px 0 0', |
118 |
| - margin: 0, |
119 |
| - padding: 0, |
120 |
| - marginBottom: 0, |
121 |
| - position: 'fixed', |
122 |
| - bottom: 0, |
123 |
| - left: 0, |
124 |
| - right: 0, |
125 |
| - }, |
126 |
| - }} |
127 |
| - maskClosable={true} |
128 |
| - destroyOnClose |
129 |
| - > |
130 |
| - <div className="history-modal-container"> |
131 |
| - {/* top title bar */} |
132 |
| - <div className="history-modal-header"> |
133 |
| - <Text strong style={{ fontSize: '16px' }}> |
134 |
| - History ({history.length}) |
135 |
| - </Text> |
136 |
| - <Button |
137 |
| - size="small" |
138 |
| - type="text" |
139 |
| - icon={<CloseOutlined width={16} height={16} />} |
140 |
| - onClick={() => setIsModalOpen(false)} |
141 |
| - className="close-button" |
142 |
| - /> |
143 |
| - </div> |
144 |
| - |
145 |
| - {/* search bar */} |
146 |
| - <div className="history-search-section"> |
147 |
| - <div className="search-input-wrapper"> |
148 |
| - <Input |
149 |
| - placeholder="Search" |
150 |
| - value={searchText} |
151 |
| - onChange={(e) => setSearchText(e.target.value)} |
152 |
| - prefix={<MagnifyingGlass width={18} height={18} />} |
153 |
| - className="search-input" |
154 |
| - allowClear |
155 |
| - /> |
| 87 | + {isModalOpen && ( |
| 88 | + <div className="history-modal-overlay" onClick={() => setIsModalOpen(false)}> |
| 89 | + <div className="history-modal-container" onClick={(e) => e.stopPropagation()}> |
| 90 | + {/* top title bar */} |
| 91 | + <div className="history-modal-header"> |
| 92 | + <Text strong style={{ fontSize: '16px' }}> |
| 93 | + History ({history.length}) |
| 94 | + </Text> |
156 | 95 | <Button
|
157 |
| - type="link" |
158 |
| - onClick={handleClearHistory} |
159 |
| - className="clear-button" |
160 |
| - disabled={history.length === 0} |
161 |
| - > |
162 |
| - Clear |
163 |
| - </Button> |
| 96 | + size="small" |
| 97 | + type="text" |
| 98 | + icon={<CloseOutlined width={16} height={16} />} |
| 99 | + onClick={() => setIsModalOpen(false)} |
| 100 | + className="close-button" |
| 101 | + /> |
164 | 102 | </div>
|
165 |
| - </div> |
166 | 103 |
|
167 |
| - {/* history content */} |
168 |
| - <div className="history-content"> |
169 |
| - {history.length === 0 ? ( |
170 |
| - /* no history record */ |
171 |
| - <div className="no-results"> |
172 |
| - <Text type="secondary">No history record</Text> |
| 104 | + {/* search bar */} |
| 105 | + <div className="history-search-section"> |
| 106 | + <div className="search-input-wrapper"> |
| 107 | + <Input |
| 108 | + placeholder="Search" |
| 109 | + value={searchText} |
| 110 | + onChange={(e) => setSearchText(e.target.value)} |
| 111 | + prefix={<MagnifyingGlass width={18} height={18} />} |
| 112 | + className="search-input" |
| 113 | + allowClear |
| 114 | + /> |
| 115 | + <Button |
| 116 | + type="link" |
| 117 | + onClick={handleClearHistory} |
| 118 | + className="clear-button" |
| 119 | + disabled={history.length === 0} |
| 120 | + > |
| 121 | + Clear |
| 122 | + </Button> |
173 | 123 | </div>
|
174 |
| - ) : ( |
175 |
| - <> |
176 |
| - {renderHistoryGroup('Last 7 days', groupedHistory.recent7Days)} |
177 |
| - {renderHistoryGroup('Last 1 year', groupedHistory.recent1Year)} |
178 |
| - {renderHistoryGroup('Earlier', groupedHistory.older)} |
179 |
| - |
180 |
| - {/* no search result */} |
181 |
| - {searchText && |
182 |
| - groupedHistory.recent7Days.length === 0 && |
183 |
| - groupedHistory.recent1Year.length === 0 && |
184 |
| - groupedHistory.older.length === 0 && ( |
185 |
| - <div className="no-results"> |
186 |
| - <Text type="secondary">No matching history record</Text> |
187 |
| - </div> |
188 |
| - )} |
189 |
| - </> |
190 |
| - )} |
| 124 | + </div> |
| 125 | + |
| 126 | + {/* history content */} |
| 127 | + <div className="history-content"> |
| 128 | + {history.length === 0 ? ( |
| 129 | + /* no history record */ |
| 130 | + <div className="no-results"> |
| 131 | + <Text type="secondary">No history record</Text> |
| 132 | + </div> |
| 133 | + ) : ( |
| 134 | + <> |
| 135 | + {renderHistoryGroup('Last 7 days', groupedHistory.recent7Days)} |
| 136 | + {renderHistoryGroup('Last 1 year', groupedHistory.recent1Year)} |
| 137 | + {renderHistoryGroup('Earlier', groupedHistory.older)} |
| 138 | + |
| 139 | + {/* no search result */} |
| 140 | + {searchText && |
| 141 | + groupedHistory.recent7Days.length === 0 && |
| 142 | + groupedHistory.recent1Year.length === 0 && |
| 143 | + groupedHistory.older.length === 0 && ( |
| 144 | + <div className="no-results"> |
| 145 | + <Text type="secondary">No matching history record</Text> |
| 146 | + </div> |
| 147 | + )} |
| 148 | + </> |
| 149 | + )} |
| 150 | + </div> |
191 | 151 | </div>
|
192 | 152 | </div>
|
193 |
| - </Modal> |
| 153 | + )} |
194 | 154 | </>
|
195 | 155 | );
|
196 | 156 | };
|
0 commit comments