updates
This commit is contained in:
@@ -21,6 +21,7 @@ import 'react-datepicker/dist/react-datepicker.css';
|
||||
const HousekeepingManagement: React.FC = () => {
|
||||
const { userInfo } = useAuthStore();
|
||||
const isAdmin = userInfo?.role === 'admin';
|
||||
const isHousekeeping = userInfo?.role === 'housekeeping';
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [tasks, setTasks] = useState<HousekeepingTask[]>([]);
|
||||
const [rooms, setRooms] = useState<Room[]>([]);
|
||||
@@ -227,8 +228,8 @@ const HousekeepingManagement: React.FC = () => {
|
||||
}
|
||||
toast.success('Housekeeping task updated successfully');
|
||||
} else {
|
||||
// Only admin can create tasks
|
||||
if (!isAdmin) {
|
||||
// Only admin and staff can create tasks
|
||||
if (!isAdmin && userInfo?.role !== 'staff') {
|
||||
toast.error('You do not have permission to create tasks');
|
||||
return;
|
||||
}
|
||||
@@ -321,7 +322,7 @@ const HousekeepingManagement: React.FC = () => {
|
||||
className="border border-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
/>
|
||||
</div>
|
||||
{isAdmin && (
|
||||
{(isAdmin || userInfo?.role === 'staff') && (
|
||||
<button
|
||||
onClick={handleCreate}
|
||||
className="flex items-center space-x-2 px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
|
||||
@@ -399,8 +400,10 @@ const HousekeepingManagement: React.FC = () => {
|
||||
<Edit className="w-4 h-4" />
|
||||
</button>
|
||||
) : (
|
||||
// Staff can only edit their own assigned tasks
|
||||
task.assigned_to === userInfo?.id && task.status !== 'completed' && (
|
||||
// Housekeeping and staff can only edit their own assigned tasks
|
||||
(isHousekeeping || userInfo?.role === 'staff') &&
|
||||
task.assigned_to === userInfo?.id &&
|
||||
task.status !== 'completed' && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => handleEdit(task)}
|
||||
|
||||
Reference in New Issue
Block a user