docs: add task-7 fix report
This commit is contained in:
23
.superpowers/sdd/task-7-report.md
Normal file
23
.superpowers/sdd/task-7-report.md
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
## Fix Task 7 — Build-breaking issues in RoomsPage
|
||||
|
||||
### Changes made to `apps/admin/src/pages/Rooms/index.tsx`
|
||||
|
||||
1. **Restored `const RoomsPage: React.FC = () => {` wrapper** — was accidentally removed, leaving state hooks dangling at module scope. Added at line 66.
|
||||
|
||||
2. **Restored `const [data, setData] = useState<any[]>([]);`** — was removed but referenced by `buildings` useMemo and `fetchData`. Added right after the component opener.
|
||||
|
||||
3. **Added `useCallback` to React import** (line 1) — needed for wrapping fetchBeds/fetchLockers.
|
||||
|
||||
4. **Fixed `handleSave` function** — its closing `};` was accidentally overwritten by the fetchBeds edit. Restored at line 160.
|
||||
|
||||
5. **Wrapped `fetchBeds` and `fetchLockers` in `useCallback`** — they're in the `columns` useMemo deps array, but as plain `const` functions they'd be recreated every render, causing unnecessary re-renders. Now wrapped with `[]` deps since they only reference stable `api` and state setters.
|
||||
|
||||
6. **Deleted orphaned leftover code** — old `} catch (e) { console.error(e); }\n };` from the pre-useCallback fetchBeds definition was still present after the replacement.
|
||||
|
||||
7. **Fixed broken action column JSX** — the ternary for archived/non-archived rows had mixed branches: the archived=true branch contained ALL buttons (恢复, 查看, 编辑, 归档) instead of only 恢复, with a dangling `</>` closing a non-existent fragment. Restructured to: archived branch → just `<Popconfirm>恢复</Popconfirm>`; else branch → fragment-wrapped `<查看/编辑/归档>`. Also fixed missing `]: [deps]` useMemo closing after the action column array member.
|
||||
|
||||
8. **Removed Tooltip** — not imported/unused. (Already clean; no action needed.)
|
||||
|
||||
### Verification
|
||||
- `npx tsc --noEmit` passes with zero errors.
|
||||
Reference in New Issue
Block a user