Add RECALC button to Roster page to refresh data
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Upload, CheckCircle, Trash2, Clock, Users } from 'lucide-react'
|
||||
import { Upload, CheckCircle, Trash2, Clock, Users, RefreshCw } from 'lucide-react'
|
||||
import api from '../../api'
|
||||
import toast from 'react-hot-toast'
|
||||
|
||||
@@ -63,6 +63,21 @@ export default function RosterPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const handleRecalc = async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
await Promise.all([
|
||||
api.get('/api/roster/info'),
|
||||
api.get('/api/roster/data').catch(() => ({ data: { headers: [], rows: [] } }))
|
||||
])
|
||||
toast.success('已重新計算')
|
||||
} catch {
|
||||
toast.error('重新計算失敗')
|
||||
} finally {
|
||||
loadRosterData()
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return <div className="p-8 text-center">載入中...</div>
|
||||
}
|
||||
@@ -106,10 +121,16 @@ export default function RosterPage() {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button onClick={handleDelete} className="btn-danger">
|
||||
<Trash2 size={16} className="inline mr-1" />
|
||||
刪除
|
||||
</button>
|
||||
<div className="flex gap-2">
|
||||
<button onClick={handleRecalc} className="btn-secondary">
|
||||
<RefreshCw size={16} className="inline mr-1" />
|
||||
RECALC
|
||||
</button>
|
||||
<button onClick={handleDelete} className="btn-danger">
|
||||
<Trash2 size={16} className="inline mr-1" />
|
||||
刪除
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user