Expose Approve, Reject, Block, and Remove Account buttons unconditionally on Seller Detail page
This commit is contained in:
parent
07193f78c0
commit
2d13768234
1 changed files with 32 additions and 21 deletions
|
|
@ -86,31 +86,42 @@ const SellerDetail = () => {
|
|||
<h1 className="page-title" style={{ margin: 0 }}>{seller.name}</h1>
|
||||
<p style={{ color: 'var(--text-secondary)' }}>Seller ID: {seller.id} • Joined: {seller.joined_at ? new Date(seller.joined_at).toLocaleDateString() : 'N/A'}</p>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '10px' }}>
|
||||
{seller.status === 'pending_approval' && (
|
||||
<>
|
||||
<button className="btn btn-primary" onClick={() => handleAction('approve')}>Approve Seller</button>
|
||||
<button className="btn btn-danger" onClick={() => {
|
||||
const reason = prompt("Enter rejection reason:");
|
||||
if (reason) handleAction('reject', { reason });
|
||||
}}>Reject Seller</button>
|
||||
</>
|
||||
<div style={{ display: 'flex', gap: '10px', flexWrap: 'wrap' }}>
|
||||
{seller.status !== 'approved' && (
|
||||
<button className="btn btn-primary" onClick={() => handleAction('approve')}>Approve Seller</button>
|
||||
)}
|
||||
{seller.status === 'approved' && (
|
||||
{seller.status !== 'rejected' && (
|
||||
<button className="btn btn-danger" onClick={() => {
|
||||
const reason = prompt("Enter suspension reason:");
|
||||
const reason = prompt("Enter rejection reason:");
|
||||
if (reason) handleAction('reject', { reason });
|
||||
}}>Reject Seller</button>
|
||||
)}
|
||||
{seller.status !== 'suspended' ? (
|
||||
<button className="btn btn-warning" style={{ background: '#d97706', borderColor: '#d97706', color: 'white' }} onClick={() => {
|
||||
const reason = prompt("Enter suspension/blocking reason:");
|
||||
if (reason) handleAction('suspend', { reason });
|
||||
}}>Suspend Seller</button>
|
||||
)}
|
||||
{seller.status === 'suspended' && (
|
||||
<>
|
||||
<button className="btn btn-primary" onClick={() => handleAction('reinstate')}>Reinstate Seller</button>
|
||||
<button className="btn btn-danger" onClick={() => {
|
||||
const reason = prompt("Enter reason to BAN seller:");
|
||||
if (reason) handleAction('suspend', { reason }); // bans map to suspend/restrict status
|
||||
}}>Ban Seller</button>
|
||||
</>
|
||||
}}>Suspend/Block Seller</button>
|
||||
) : (
|
||||
<button className="btn btn-primary" onClick={() => handleAction('reinstate')}>Reinstate Seller</button>
|
||||
)}
|
||||
<button className="btn btn-danger" style={{ background: 'var(--color-danger)' }} onClick={async () => {
|
||||
if (confirm("Are you sure you want to permanently delete this seller account and all associated user logins? This cannot be undone.")) {
|
||||
try {
|
||||
const res = await fetch(`${API_BASE_URL}/sellers/${id}/delete/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
if (!res.ok) throw new Error("Failed to delete seller");
|
||||
alert("Seller account permanently deleted");
|
||||
window.location.href = '/sellers';
|
||||
} catch (err) {
|
||||
alert(`Error deleting seller: ${err.message}`);
|
||||
}
|
||||
}
|
||||
}}>Remove Account</button>
|
||||
<button className="btn btn-secondary" onClick={handleResetPassword}>Reset Password</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue