fix officer replacement
This commit is contained in:
parent
a714891543
commit
ad8abf9eaa
1 changed files with 28 additions and 10 deletions
|
@ -234,8 +234,17 @@ export default function OfficerManagement() {
|
||||||
const modal = document.getElementById("replaceOfficerModal") as HTMLDialogElement;
|
const modal = document.getElementById("replaceOfficerModal") as HTMLDialogElement;
|
||||||
if (modal) modal.close();
|
if (modal) modal.close();
|
||||||
|
|
||||||
// Reset the state
|
// Reset the state and form completely
|
||||||
setOfficerToReplace(null);
|
setOfficerToReplace(null);
|
||||||
|
setSelectedUsers([]);
|
||||||
|
setUserSearchTerm('');
|
||||||
|
setUserSearchResults([]);
|
||||||
|
setNewOfficerRole('');
|
||||||
|
setNewOfficerType(OfficerTypes.GENERAL);
|
||||||
|
|
||||||
|
// Force clear any input fields
|
||||||
|
const roleInput = document.getElementById('role') as HTMLInputElement;
|
||||||
|
if (roleInput) roleInput.value = '';
|
||||||
|
|
||||||
// Refresh officers list
|
// Refresh officers list
|
||||||
fetchOfficers();
|
fetchOfficers();
|
||||||
|
@ -270,9 +279,20 @@ export default function OfficerManagement() {
|
||||||
const modal = document.getElementById("replaceOfficerModal") as HTMLDialogElement;
|
const modal = document.getElementById("replaceOfficerModal") as HTMLDialogElement;
|
||||||
if (modal) modal.close();
|
if (modal) modal.close();
|
||||||
|
|
||||||
// Reset the state
|
// Reset the state and form
|
||||||
setOfficerToReplace(null);
|
setOfficerToReplace(null);
|
||||||
|
|
||||||
|
// Clear form completely
|
||||||
|
setSelectedUsers([]);
|
||||||
|
setUserSearchTerm('');
|
||||||
|
setUserSearchResults([]);
|
||||||
|
setNewOfficerRole('');
|
||||||
|
setNewOfficerType(OfficerTypes.GENERAL);
|
||||||
|
|
||||||
|
// Force clear any input fields
|
||||||
|
const roleInput = document.getElementById('role') as HTMLInputElement;
|
||||||
|
if (roleInput) roleInput.value = '';
|
||||||
|
|
||||||
// Show a toast message
|
// Show a toast message
|
||||||
toast(`${user.name} added to selection. Submit the form to update their role.`);
|
toast(`${user.name} added to selection. Submit the form to update their role.`);
|
||||||
};
|
};
|
||||||
|
@ -406,12 +426,17 @@ export default function OfficerManagement() {
|
||||||
throw new Error(`Failed to add or update any officers. Please check user permissions and try again.`);
|
throw new Error(`Failed to add or update any officers. Please check user permissions and try again.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset form
|
// Reset form completely
|
||||||
setSelectedUsers([]);
|
setSelectedUsers([]);
|
||||||
setUserSearchTerm('');
|
setUserSearchTerm('');
|
||||||
|
setUserSearchResults([]);
|
||||||
setNewOfficerRole('');
|
setNewOfficerRole('');
|
||||||
setNewOfficerType(OfficerTypes.GENERAL);
|
setNewOfficerType(OfficerTypes.GENERAL);
|
||||||
|
|
||||||
|
// Force clear any input fields
|
||||||
|
const roleInput = document.getElementById('role') as HTMLInputElement;
|
||||||
|
if (roleInput) roleInput.value = '';
|
||||||
|
|
||||||
toast.success(`${successfulCreations.length} officer(s) added and ${successfulUpdates.length} updated successfully${failedOperations.length > 0 ? ` (${failedOperations.length} failed)` : ''}`);
|
toast.success(`${successfulCreations.length} officer(s) added and ${successfulUpdates.length} updated successfully${failedOperations.length > 0 ? ` (${failedOperations.length} failed)` : ''}`);
|
||||||
|
|
||||||
// Refresh officers list
|
// Refresh officers list
|
||||||
|
@ -743,7 +768,6 @@ export default function OfficerManagement() {
|
||||||
onClick={() => handleSelectUser(user)}
|
onClick={() => handleSelectUser(user)}
|
||||||
className={`px-4 py-2 hover:bg-base-100 cursor-pointer
|
className={`px-4 py-2 hover:bg-base-100 cursor-pointer
|
||||||
${isSelected ? 'bg-primary/10' : ''}
|
${isSelected ? 'bg-primary/10' : ''}
|
||||||
${isAlreadyOfficer ? 'opacity-50' : ''}
|
|
||||||
${isHighlighted ? 'bg-base-content/10' : ''}`}
|
${isHighlighted ? 'bg-base-content/10' : ''}`}
|
||||||
>
|
>
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
|
@ -1155,12 +1179,6 @@ export default function OfficerManagement() {
|
||||||
>
|
>
|
||||||
Update Now
|
Update Now
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
className="btn btn-secondary"
|
|
||||||
onClick={handleAddExistingOfficer}
|
|
||||||
>
|
|
||||||
Add to Selection
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-base-content/60 mt-4">
|
<p className="text-xs text-base-content/60 mt-4">
|
||||||
<strong>Update Now:</strong> Immediately update the officer's role.<br />
|
<strong>Update Now:</strong> Immediately update the officer's role.<br />
|
||||||
|
|
Loading…
Reference in a new issue