Skip to content

Commit 2adc206

Browse files
committed
refactor(DataPoints): removed some spaghetti code
Removed some shit mountain code...
1 parent bc7f9e6 commit 2adc206

2 files changed

Lines changed: 27 additions & 74 deletions

File tree

src/Components/DataPoints/DataPoints.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,16 @@
251251
padding-top: 6px;
252252
}
253253
}
254+
255+
.refresh-button {
256+
position: fixed;
257+
z-index: 20;
258+
bottom: 40px;
259+
right: 20px;
260+
}
261+
262+
@media (max-width: 768px) {
263+
bottom: 20px;
264+
right: 16px;
265+
transform: scale(0.9);
266+
}

src/Components/DataPoints/DataPoints.jsx

Lines changed: 14 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,6 @@ function SearchFilter({ onFilterChange }) {
112112
const theme1 = useTheme();
113113
const isDark = theme1.palette.mode === 'dark';
114114

115-
const applicantRef = useRef()
116-
const programRef = useRef()
117-
const statusRef = useRef()
118-
const finalRef = useRef()
119-
const seasonRef = useRef()
120-
121-
// TODO: FIXME:
122-
// const getCurrentFilters = () => ({
123-
// applicant: applicantRef.current.input?.value ?? applicantRef.current.value,
124-
// program: programRef.current.input?.value ?? programRef.current.value,
125-
// status: statusRef.current.nativeElement?.firstChild?.firstChild?.lastChild?.textContent,
126-
// final: finalRef.current.nativeElement?.firstChild?.firstChild?.lastChild?.textContent,
127-
// season: seasonRef.current.input?.value ?? seasonRef.current.value,
128-
// })
129-
130115
return (
131116
<div className="filter-container">
132117
{/* Using antd's Input and Select elements */}
@@ -135,7 +120,6 @@ function SearchFilter({ onFilterChange }) {
135120
{/* 搜索申请人 */}
136121
<Input
137122
id="applicant"
138-
ref={applicantRef}
139123
size="small"
140124
placeholder="搜索申请人"
141125
value={filters.applicant}
@@ -149,7 +133,6 @@ function SearchFilter({ onFilterChange }) {
149133
{/* 搜索申请项目 */}
150134
<Input
151135
id="program"
152-
ref={programRef}
153136
size="small"
154137
placeholder="搜索申请项目"
155138
value={filters.program}
@@ -163,7 +146,6 @@ function SearchFilter({ onFilterChange }) {
163146
{/* 申请结果 */}
164147
<Select
165148
id="status"
166-
ref={statusRef}
167149
size="small"
168150
value={filters.status || ''}
169151
onChange={value => handleFilterChange('status', value)}
@@ -185,7 +167,6 @@ function SearchFilter({ onFilterChange }) {
185167
{/* 最终去向 */}
186168
<Select
187169
id="final"
188-
ref={finalRef}
189170
size="small"
190171
value={filters.final === null ? '' : filters.final ? 'true' : 'false'}
191172
onChange={value => {
@@ -206,7 +187,6 @@ function SearchFilter({ onFilterChange }) {
206187
{/* 搜索申请季 */}
207188
<Input
208189
id="season"
209-
ref={seasonRef}
210190
size="small"
211191
placeholder="搜索申请季"
212192
value={filters.season}
@@ -252,8 +232,6 @@ function SearchFilter({ onFilterChange }) {
252232
* @constructor
253233
*/
254234
export function DataGrid({records, insideProgramPage, style = {}}) {
255-
console.log("DataGrid is rerendered")
256-
257235
const theme = useTheme();
258236
const themeMap = {
259237
light: "/TableLight.css",
@@ -279,7 +257,6 @@ export function DataGrid({records, insideProgramPage, style = {}}) {
279257

280258
/** @param {Filter} filter */
281259
const handleSearch = (filter) => {
282-
// console.log("handle search with filter: ", filter)
283260
setIsSearching(true)
284261

285262
setTimeout(() => {
@@ -302,9 +279,8 @@ export function DataGrid({records, insideProgramPage, style = {}}) {
302279
return true;
303280
})
304281
setFilteredRecords(filteredRecords)
305-
306282
setIsSearching(false)
307-
})
283+
}, 0)
308284
}
309285

310286
/**
@@ -403,52 +379,18 @@ export function DataGrid({records, insideProgramPage, style = {}}) {
403379
)
404380
}
405381

406-
function FloatingControls() {
407-
const [showGuide, setShowGuide] = useState(false);
408-
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
409-
410-
// Add event listener to track window size changes
411-
useEffect(() => {
412-
const handleResize = () => {
413-
setWindowWidth(window.innerWidth);
414-
};
415-
416-
window.addEventListener('resize', handleResize);
417-
return () => {
418-
window.removeEventListener('resize', handleResize);
419-
};
420-
}, []);
421-
422-
// Determine if we're on mobile
423-
const isMobile = windowWidth <= 768;
424-
425-
const handleToggleGuide = () => {
426-
setShowGuide(prev => !prev);
427-
};
428-
429-
return (
430-
<>
431-
{/* Refresh FAB */}
432-
<Form method="post">
433-
<DraggableFAB
434-
Icon={<Refresh/>}
435-
ActionType="Refresh"
436-
ButtonClassName="HiddenRefreshButton"
437-
color="primary"
438-
style={{
439-
position: 'fixed',
440-
bottom: isMobile ? '20px' : '40px',
441-
right: isMobile ? '16px' : '20px',
442-
zIndex: 20,
443-
transform: isMobile ? 'scale(0.9)' : 'none',
444-
}}
445-
tooltipTitle="刷新表格"
446-
/>
447-
</Form>
448-
</>
449-
);
450-
}
451-
382+
const FloatingControls = () => (
383+
/* Refresh FAB */
384+
<Form method="post" className="refresh-button">
385+
<DraggableFAB
386+
Icon={<Refresh/>}
387+
ActionType="Refresh"
388+
ButtonClassName="HiddenRefreshButton"
389+
color="primary"
390+
tooltipTitle="刷新表格"
391+
/>
392+
</Form>
393+
)
452394

453395
export default function DataPoints() {
454396
const loaderRecords = useLoaderData();
@@ -463,16 +405,14 @@ export default function DataPoints() {
463405
className="DataPointsContent"
464406
sx={{
465407
bgcolor: (theme) => theme.palette.mode === "dark" ? "#1A1E24" : "#FAFAFA",
466-
// padding: '12px',
467408
display: 'flex',
468409
flexDirection: 'column',
469-
// gap: '16px'
470410
}}
471411
>
472412
<DataGrid records={records} insideProgramPage={false}/>
473413
<Outlet/>
414+
<FloatingControls/>
474415
</Paper>
475-
<FloatingControls/>
476416
</div>
477417
)
478418
}

0 commit comments

Comments
 (0)