LAFU Sales Reports

Extract useManageAction hook — ~1750 duplicated lines across 22 panel components

FeatureOpenView on roadmap· 28 days ago

Imported from GitHub issue El-SaMa/oma#105 by @El-SaMa.


Every `*-panel.tsx` component (ftp-accounts, email-list, databases-list, database-users, domains-list, etc. — 22 files) reimplements the same pattern:

```ts const [pending, startTransition] = useTransition(); const [message, setMessage] = useState<string | null>(null); const [error, setError] = useState<string | null>(null); function run(action) { setMessage(null); setError(null); startTransition(async () => { const result = await action(); if (result.ok) setMessage(result.message ?? "Done."); else setError(result.error ?? "Something went wrong."); }); } ```

Fix: extract to `apps/web/lib/hooks/useManageAction.ts` returning `{ pending, message, error, run }`. Migrate panels incrementally (low risk — pure refactor, behavior-preserving) starting with the most recently touched ones (database-users-panel.tsx, databases-list-panel.tsx).

Comments (0)

No comments yet.

Join the discussion

Sign in to leave a comment on this thread.

HollahoopGet yours