Compare commits
	
		
			No commits in common. "d335803cf8455b404d9041f1c24306ac370d0f54" and "b52537cfe446628664843649059182f774ca1ab8" have entirely different histories.
		
	
	
		
			d335803cf8
			...
			b52537cfe4
		
	
		| 
						 | 
				
			
			@ -7,18 +7,13 @@ use App\Http\Controllers\Controller;
 | 
			
		|||
use App\Jobs\InitializeLeaveDays;
 | 
			
		||||
use App\Models\LeaveDays;
 | 
			
		||||
use App\Models\Notes;
 | 
			
		||||
use Carbon\Carbon;
 | 
			
		||||
use Illuminate\Http\Request;
 | 
			
		||||
use Illuminate\Support\Facades\DB;
 | 
			
		||||
use Illuminate\Support\Facades\Validator;
 | 
			
		||||
use Maatwebsite\Excel\Facades\Excel;
 | 
			
		||||
use Modules\Admin\app\Models\Ticket;
 | 
			
		||||
use App\Traits\AnalyzeData;
 | 
			
		||||
 | 
			
		||||
class LeaveManagementController extends Controller
 | 
			
		||||
{
 | 
			
		||||
    use AnalyzeData;
 | 
			
		||||
 | 
			
		||||
    public function get(Request $request)
 | 
			
		||||
    {
 | 
			
		||||
        $yearNow = $request->query('year', now()->year);
 | 
			
		||||
| 
						 | 
				
			
			@ -171,16 +166,6 @@ class LeaveManagementController extends Controller
 | 
			
		|||
 | 
			
		||||
        $note->n_reason = $reason;
 | 
			
		||||
        $note->save();
 | 
			
		||||
 | 
			
		||||
        // Clear Timekeeping cache
 | 
			
		||||
        $ticket = Ticket::find($note->ticket_id);
 | 
			
		||||
        if ($ticket) {
 | 
			
		||||
            $this->createOrUpdateRecordForCurrentMonth(Carbon::parse($ticket->start_date)->month, Carbon::parse($ticket->start_date)->year);
 | 
			
		||||
            $this->createOrUpdateRecordForCurrentMonth(Carbon::parse($ticket->end_date)->month, Carbon::parse($ticket->end_date)->year);
 | 
			
		||||
        } else {
 | 
			
		||||
            $this->createOrUpdateRecordForCurrentMonth(Carbon::parse($note->created_at)->month, Carbon::parse($note->created_at)->year);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return response()->json(data: ['message' => 'Update success', 'status' => true]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,7 @@ class UserController extends Controller
 | 
			
		|||
        ]);
 | 
			
		||||
 | 
			
		||||
        if ($request->has('id')) {
 | 
			
		||||
            $payload = $request->only(['name', 'email', 'permission', 'is_permanent', 'is_separated']);
 | 
			
		||||
            $payload = $request->only(['name', 'email', 'permission', 'is_permanent']);
 | 
			
		||||
            $user = User::find($request->id);
 | 
			
		||||
 | 
			
		||||
            // Không cho chuyển từ chính thức thành lại thử việc
 | 
			
		||||
| 
						 | 
				
			
			@ -47,10 +47,6 @@ class UserController extends Controller
 | 
			
		|||
                return response()->json(['status' => false, 'message' => 'You cannot change an employee from permanent to probationary.']);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!$request->is_separated && $user->is_separated) {
 | 
			
		||||
                return response()->json(['status' => false, 'message' => 'You cannot change status of separated employee.']);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Thêm ngày phép khi thành nhân viên chính thức
 | 
			
		||||
            if ($request->is_permanent && !$user->is_permanent) {
 | 
			
		||||
                $userLeaveDay = LeaveDays::where('ld_user_id', $user->id)
 | 
			
		||||
| 
						 | 
				
			
			@ -82,8 +78,7 @@ class UserController extends Controller
 | 
			
		|||
                'email' => $request->email,
 | 
			
		||||
                'password' => bcrypt('Work@1234'),
 | 
			
		||||
                'permission' => $request->permission,
 | 
			
		||||
                'is_permanent' => false,
 | 
			
		||||
                'is_separated' => false
 | 
			
		||||
                'is_permanent' => false
 | 
			
		||||
            ]);
 | 
			
		||||
 | 
			
		||||
            // Khởi tạo LeaveDays cho nhân viên mới
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,6 @@ class User extends Authenticatable implements JWTSubject
 | 
			
		|||
        'password',
 | 
			
		||||
        'permission',
 | 
			
		||||
        'is_permanent',
 | 
			
		||||
        'is_separated',
 | 
			
		||||
        'permanent_date'
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,6 +17,8 @@ class InitializeLeaveDaysCommand extends Command
 | 
			
		|||
 | 
			
		||||
    public function handle()
 | 
			
		||||
    {
 | 
			
		||||
        InitializeLeaveDays::dispatch();
 | 
			
		||||
        $year = $this->argument('year');
 | 
			
		||||
        // Không sử dụng nữa, theo rule mới
 | 
			
		||||
        // InitializeLeaveDays::dispatch($year);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,11 +37,6 @@ class AddMonthlyLeaveDays implements ShouldQueue
 | 
			
		|||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // Nếu là nhân viên nghỉ việc, ko cộng phép
 | 
			
		||||
      if ($user->is_separated) {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      $leaveDay = LeaveDays::where('ld_user_id', $user->id)
 | 
			
		||||
        ->where('ld_year', $this->year)
 | 
			
		||||
        ->first();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,14 +38,11 @@ class CheckUserAttendanceJob implements ShouldQueue
 | 
			
		|||
    {
 | 
			
		||||
        // Lấy tất cả người dùng
 | 
			
		||||
        $users = User::where('permission', 'not like', '%admin%')
 | 
			
		||||
            ->where('permission', 'not like', '%accountant%')->get();
 | 
			
		||||
 | 
			
		||||
                ->where('permission', 'not like', '%accountant%')->get();
 | 
			
		||||
        foreach ($users as $key => $user) {
 | 
			
		||||
            // Check nhân viên nghỉ việc
 | 
			
		||||
            if ($user->is_separated) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // if ($user->id != 4) {
 | 
			
		||||
            //     continue;
 | 
			
		||||
            // }
 | 
			
		||||
            // Kiểm tra dựa trên period (Sáng 'S' hoặc Chiều 'C')
 | 
			
		||||
            if ($this->period === 'S') {
 | 
			
		||||
                $this->checkMorning($user);
 | 
			
		||||
| 
						 | 
				
			
			@ -131,19 +128,14 @@ class CheckUserAttendanceJob implements ShouldQueue
 | 
			
		|||
        $reason = 'KHONG PHEP';
 | 
			
		||||
 | 
			
		||||
        //Check ngày hợp lệ nếu có check và check out của user khác
 | 
			
		||||
        $dateNow = Tracking::whereBetween('time_string', [$startTime, $endTime])->exists();
 | 
			
		||||
        $dateNow = Tracking::whereBetween('time_string', [$startTime, $endTime])
 | 
			
		||||
            ->get();
 | 
			
		||||
        $hasCheckIndateNow = $dateNow->where('status', 'check in')->isNotEmpty();
 | 
			
		||||
        $hasCheckOutdateNow = $dateNow->where('status', 'check out')->isNotEmpty();
 | 
			
		||||
 | 
			
		||||
        // Nếu không có check in/out, không gửi ticket và có check in/out của người khác => tạo ticket không phép
 | 
			
		||||
        if ($hasCheckIn || $hasCheckOut) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($existingTicket) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($dateNow) {
 | 
			
		||||
            $ticket = Ticket::create([
 | 
			
		||||
        // Nếu không có check-in hoặc check-out, và chưa có ticket, tạo ticket mới
 | 
			
		||||
        if (($hasCheckIndateNow && $hasCheckOutdateNow) && !$hasCheckIn && !$hasCheckOut && !$existingTicket) {
 | 
			
		||||
            Ticket::create([
 | 
			
		||||
                'user_id' => $userId,
 | 
			
		||||
                'start_date' => $today->format('Y-m-d'),
 | 
			
		||||
                'start_period' => $periodCode,
 | 
			
		||||
| 
						 | 
				
			
			@ -167,10 +159,8 @@ class CheckUserAttendanceJob implements ShouldQueue
 | 
			
		|||
            $admins = Admin::where('permission', 'like', '%admin%')->get();
 | 
			
		||||
            foreach ($admins as $key => $value) {
 | 
			
		||||
                $data = array(
 | 
			
		||||
                    "ticket_id" => $ticket->id,
 | 
			
		||||
                    "email_template" => "email.notification_tickets",
 | 
			
		||||
                    "email" => $user->email,
 | 
			
		||||
                    "admin_email" => $value->email,
 | 
			
		||||
                    "name" => $user->name,
 | 
			
		||||
                    "date" => $dataMasterStartPeriod->c_name . " (" . $formattedStartDate . ") - " . $dataMasterEndPeriod->c_name . " (" . $formattedEndDate . ")",
 | 
			
		||||
                    "type" => $dataMasterType->c_name,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,11 +37,6 @@ class InitializeLeaveDays implements ShouldQueue
 | 
			
		|||
        $ld_day_total = Carbon::now()->month; // Khởi tạo phép hiện có bằng tháng hiện tại
 | 
			
		||||
 | 
			
		||||
        foreach ($users as $user) {
 | 
			
		||||
            // Check nhân viên nghỉ việc
 | 
			
		||||
            if ($user->is_separated) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Kiểm tra xem dữ liệu của user này đã tồn tại cho năm hiện tại chưa
 | 
			
		||||
            $existingData = LeaveDays::where('ld_user_id', $user->id)
 | 
			
		||||
                ->where('ld_year', $this->year)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,29 +0,0 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
use Illuminate\Database\Migrations\Migration;
 | 
			
		||||
use Illuminate\Database\Schema\Blueprint;
 | 
			
		||||
use Illuminate\Support\Facades\DB;
 | 
			
		||||
use Illuminate\Support\Facades\Schema;
 | 
			
		||||
 | 
			
		||||
return new class extends Migration
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Run the migrations.
 | 
			
		||||
     */
 | 
			
		||||
    public function up(): void
 | 
			
		||||
    {
 | 
			
		||||
        Schema::table('users', function (Blueprint $table) {
 | 
			
		||||
            $table->boolean('is_separated')->default(false);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Reverse the migrations.
 | 
			
		||||
     */
 | 
			
		||||
    public function down(): void
 | 
			
		||||
    {
 | 
			
		||||
        Schema::table('users', function (Blueprint $table) {
 | 
			
		||||
            $table->dropColumn('is_separated');
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -853,13 +853,7 @@ const LeaveManagement = () => {
 | 
			
		|||
                    return (
 | 
			
		||||
                      <Table.Td
 | 
			
		||||
                        bg={total > 0 ? '#ffb5b5' : ''}
 | 
			
		||||
                        opacity={
 | 
			
		||||
                          Number(date.year) === currentYear
 | 
			
		||||
                            ? d.value > currentMonth
 | 
			
		||||
                              ? 0.4
 | 
			
		||||
                              : 1
 | 
			
		||||
                            : 1
 | 
			
		||||
                        }
 | 
			
		||||
                        opacity={d.value > currentMonth ? 0.4 : 1}
 | 
			
		||||
                        key={i}
 | 
			
		||||
                        ta={'center'}
 | 
			
		||||
                      >
 | 
			
		||||
| 
						 | 
				
			
			@ -980,7 +974,6 @@ const LeaveManagement = () => {
 | 
			
		|||
 | 
			
		||||
                  {/* Off */}
 | 
			
		||||
                  <Table.Td
 | 
			
		||||
                    style={{ cursor: 'pointer' }}
 | 
			
		||||
                    onClick={() => {
 | 
			
		||||
                      openDetailOff()
 | 
			
		||||
                      setDetailOffItem(user)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,47 +47,14 @@
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
/* Thêm styles cho Modal xác nhận xóa */
 | 
			
		||||
.confirmModal {
 | 
			
		||||
.deleteModal {
 | 
			
		||||
  background-color: light-dark(white, #2d353c);
 | 
			
		||||
  text-align: center;
 | 
			
		||||
  border: solid 1px rgb(9, 132, 132);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.confirmModalTitle {
 | 
			
		||||
  color: rgb(9, 132, 132);
 | 
			
		||||
  font-weight: 600;
 | 
			
		||||
  font-size: 1.2rem;
 | 
			
		||||
  margin-bottom: 1rem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.confirmModalContent {
 | 
			
		||||
  color: light-dark(#2d353c, white);
 | 
			
		||||
  margin-bottom: 1.5rem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.confirmModalFooter {
 | 
			
		||||
  display: flex;
 | 
			
		||||
  justify-content: flex-end;
 | 
			
		||||
  gap: 10px;
 | 
			
		||||
  margin-top: 1rem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.confirmButton {
 | 
			
		||||
  background-color: rgb(9, 132, 132);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.confirmButton:hover {
 | 
			
		||||
  background-color: rgb(9, 132, 132);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.deleteModal {
 | 
			
		||||
  background-color: light-dark(white, #2d353c);
 | 
			
		||||
  text-align: center;
 | 
			
		||||
  border: solid 1px #ff4646;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.deleteModalTitle {
 | 
			
		||||
  color: #ff4646;
 | 
			
		||||
  color: rgb(9, 132, 132);
 | 
			
		||||
  font-weight: 600;
 | 
			
		||||
  font-size: 1.2rem;
 | 
			
		||||
  margin-bottom: 1rem;
 | 
			
		||||
| 
						 | 
				
			
			@ -106,9 +73,9 @@
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
.deleteButton {
 | 
			
		||||
  background-color: #ff4646;
 | 
			
		||||
  background-color: rgb(9, 132, 132);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.deleteButton:hover {
 | 
			
		||||
  background-color: #ff6b6b;
 | 
			
		||||
  background-color: rgb(9, 132, 132);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ import {
 | 
			
		|||
  Group,
 | 
			
		||||
  Modal,
 | 
			
		||||
  MultiSelect,
 | 
			
		||||
  Select,
 | 
			
		||||
  Switch,
 | 
			
		||||
  Text,
 | 
			
		||||
  TextInput,
 | 
			
		||||
} from '@mantine/core'
 | 
			
		||||
| 
						 | 
				
			
			@ -21,30 +21,15 @@ import { useForm } from '@mantine/form'
 | 
			
		|||
import { IconEdit, IconX } from '@tabler/icons-react'
 | 
			
		||||
import { useEffect, useState } from 'react'
 | 
			
		||||
import classes from './UsersManagement.module.css'
 | 
			
		||||
 | 
			
		||||
type TUserForm = {
 | 
			
		||||
  id: number
 | 
			
		||||
  email: string
 | 
			
		||||
  name: string
 | 
			
		||||
  permission: string
 | 
			
		||||
  status: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const UsersManagement = () => {
 | 
			
		||||
  const [users, setUsers] = useState<TUser[]>([])
 | 
			
		||||
  const [action, setAction] = useState('')
 | 
			
		||||
  const [activeBtn, setActiveBtn] = useState(false)
 | 
			
		||||
  const [item, setItem] = useState({
 | 
			
		||||
    id: 0,
 | 
			
		||||
    is_permanent: false,
 | 
			
		||||
    is_separated: false,
 | 
			
		||||
  })
 | 
			
		||||
  const [item, setItem] = useState({ id: 0, is_permanent: false })
 | 
			
		||||
  const [disableBtn, setDisableBtn] = useState(false)
 | 
			
		||||
  const [info, setInfo] = useState('')
 | 
			
		||||
  const [isPermanentConfirmOpen, setIsPermanentConfirmOpen] =
 | 
			
		||||
    useState<boolean>(false)
 | 
			
		||||
  const [isSeparatedConfirmOpen, setIsSeparatedConfirmOpen] =
 | 
			
		||||
    useState<boolean>(false)
 | 
			
		||||
 | 
			
		||||
  const columns = [
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -81,10 +66,6 @@ const UsersManagement = () => {
 | 
			
		|||
      size: '20%',
 | 
			
		||||
      header: 'Employment Type',
 | 
			
		||||
      render: (row: TUser) => {
 | 
			
		||||
        if (row.is_separated) {
 | 
			
		||||
          return <Badge color="red">Separated</Badge>
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return row.is_permanent ? (
 | 
			
		||||
          <Badge color="teal">Permanent</Badge>
 | 
			
		||||
        ) : (
 | 
			
		||||
| 
						 | 
				
			
			@ -105,10 +86,7 @@ const UsersManagement = () => {
 | 
			
		|||
                setAction('edit')
 | 
			
		||||
                setItem(row)
 | 
			
		||||
                form.reset()
 | 
			
		||||
                form.setValues({
 | 
			
		||||
                  ...row,
 | 
			
		||||
                  status: row.is_permanent ? 'permanent' : '',
 | 
			
		||||
                })
 | 
			
		||||
                form.setValues(row)
 | 
			
		||||
              }}
 | 
			
		||||
              width={20}
 | 
			
		||||
              height={20}
 | 
			
		||||
| 
						 | 
				
			
			@ -134,7 +112,7 @@ const UsersManagement = () => {
 | 
			
		|||
      name: '',
 | 
			
		||||
      email: '',
 | 
			
		||||
      permission: '',
 | 
			
		||||
      status: '',
 | 
			
		||||
      is_permanent: false,
 | 
			
		||||
    },
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -149,7 +127,7 @@ const UsersManagement = () => {
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const handleCreate = async (values: TUserForm) => {
 | 
			
		||||
  const handleCreate = async (values: TUser) => {
 | 
			
		||||
    try {
 | 
			
		||||
      const { id, ...data } = values
 | 
			
		||||
      const res = await post(createOrUpdateUser, data)
 | 
			
		||||
| 
						 | 
				
			
			@ -164,25 +142,12 @@ const UsersManagement = () => {
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const handleUpdate = async (values: TUserForm) => {
 | 
			
		||||
  const handleUpdate = async (values: TUser) => {
 | 
			
		||||
    try {
 | 
			
		||||
      const res = await update(
 | 
			
		||||
        createOrUpdateUser,
 | 
			
		||||
        {
 | 
			
		||||
          ...values,
 | 
			
		||||
          is_permanent: item.is_permanent
 | 
			
		||||
            ? true
 | 
			
		||||
            : values.status === 'permanent',
 | 
			
		||||
          is_separated: item.is_separated
 | 
			
		||||
            ? true
 | 
			
		||||
            : values.status === 'separated',
 | 
			
		||||
        },
 | 
			
		||||
        getAll,
 | 
			
		||||
      )
 | 
			
		||||
      const res = await update(createOrUpdateUser, values, getAll)
 | 
			
		||||
      if (res === true) {
 | 
			
		||||
        setAction('')
 | 
			
		||||
        setIsPermanentConfirmOpen(false)
 | 
			
		||||
        setIsSeparatedConfirmOpen(false)
 | 
			
		||||
        form.reset()
 | 
			
		||||
      }
 | 
			
		||||
    } catch (error) {
 | 
			
		||||
| 
						 | 
				
			
			@ -228,7 +193,6 @@ const UsersManagement = () => {
 | 
			
		|||
        onClose={() => {
 | 
			
		||||
          setAction('')
 | 
			
		||||
          setIsPermanentConfirmOpen(false)
 | 
			
		||||
          setIsSeparatedConfirmOpen(false)
 | 
			
		||||
          form.reset()
 | 
			
		||||
        }}
 | 
			
		||||
        title={
 | 
			
		||||
| 
						 | 
				
			
			@ -241,10 +205,8 @@ const UsersManagement = () => {
 | 
			
		|||
          onSubmit={form.onSubmit(async (values) => {
 | 
			
		||||
            setDisableBtn(true)
 | 
			
		||||
            if (action === 'edit') {
 | 
			
		||||
              if (values.status === 'permanent' && !item.is_permanent) {
 | 
			
		||||
              if (values.is_permanent && !item.is_permanent) {
 | 
			
		||||
                setIsPermanentConfirmOpen(true)
 | 
			
		||||
              } else if (values.status === 'separated' && !item.is_separated) {
 | 
			
		||||
                setIsSeparatedConfirmOpen(true)
 | 
			
		||||
              } else {
 | 
			
		||||
                await handleUpdate(values)
 | 
			
		||||
              }
 | 
			
		||||
| 
						 | 
				
			
			@ -294,21 +256,17 @@ const UsersManagement = () => {
 | 
			
		|||
              mb={'md'}
 | 
			
		||||
            />
 | 
			
		||||
 | 
			
		||||
            {action === 'edit' && !item.is_separated ? (
 | 
			
		||||
              <Select
 | 
			
		||||
                label="Employment type"
 | 
			
		||||
                data={[
 | 
			
		||||
                  { value: 'permanent', label: 'Permanent' },
 | 
			
		||||
                  { value: 'separated', label: 'Separated' },
 | 
			
		||||
                ]}
 | 
			
		||||
                value={form.values.status}
 | 
			
		||||
                onChange={(value) => {
 | 
			
		||||
                  if (value) {
 | 
			
		||||
                    form.setFieldValue('status', value)
 | 
			
		||||
                  }
 | 
			
		||||
                }}
 | 
			
		||||
                w="50%"
 | 
			
		||||
                required
 | 
			
		||||
            {action === 'edit' && !item.is_permanent ? (
 | 
			
		||||
              <Switch
 | 
			
		||||
                label="Permanent employee"
 | 
			
		||||
                style={{ width: 'fit-content' }}
 | 
			
		||||
                checked={form.values.is_permanent}
 | 
			
		||||
                onChange={(event) =>
 | 
			
		||||
                  form.setFieldValue(
 | 
			
		||||
                    'is_permanent',
 | 
			
		||||
                    event.currentTarget.checked,
 | 
			
		||||
                  )
 | 
			
		||||
                }
 | 
			
		||||
              />
 | 
			
		||||
            ) : (
 | 
			
		||||
              ''
 | 
			
		||||
| 
						 | 
				
			
			@ -369,57 +327,14 @@ const UsersManagement = () => {
 | 
			
		|||
        onClose={() => setIsPermanentConfirmOpen(false)}
 | 
			
		||||
        centered
 | 
			
		||||
        size="sm"
 | 
			
		||||
        classNames={{
 | 
			
		||||
          content: classes.confirmModal,
 | 
			
		||||
        }}
 | 
			
		||||
      >
 | 
			
		||||
        <Text className={classes.confirmModalTitle}>Confirm Update</Text>
 | 
			
		||||
        <Text className={classes.confirmModalContent}>
 | 
			
		||||
          This action will change the employment type from{' '}
 | 
			
		||||
          <strong>Probation</strong> to <strong>Permanent</strong>.
 | 
			
		||||
        </Text>
 | 
			
		||||
        <Text className={classes.confirmModalContent}>
 | 
			
		||||
          Are you sure you want to proceed?
 | 
			
		||||
        </Text>
 | 
			
		||||
 | 
			
		||||
        <Box className={classes.confirmModalFooter}>
 | 
			
		||||
          <Button
 | 
			
		||||
            variant="outline"
 | 
			
		||||
            onClick={() => {
 | 
			
		||||
              setIsPermanentConfirmOpen(false)
 | 
			
		||||
            }}
 | 
			
		||||
            disabled={disableBtn}
 | 
			
		||||
          >
 | 
			
		||||
            Cancel
 | 
			
		||||
          </Button>
 | 
			
		||||
          <Button
 | 
			
		||||
            className={classes.confirmButton}
 | 
			
		||||
            onClick={async () => {
 | 
			
		||||
              setDisableBtn(true)
 | 
			
		||||
              await handleUpdate(form.values)
 | 
			
		||||
              setDisableBtn(false)
 | 
			
		||||
            }}
 | 
			
		||||
            disabled={disableBtn}
 | 
			
		||||
          >
 | 
			
		||||
            Confirm
 | 
			
		||||
          </Button>
 | 
			
		||||
        </Box>
 | 
			
		||||
      </Modal>
 | 
			
		||||
 | 
			
		||||
      {/* Confirm change to separated employee */}
 | 
			
		||||
      <Modal
 | 
			
		||||
        opened={isSeparatedConfirmOpen}
 | 
			
		||||
        onClose={() => setIsSeparatedConfirmOpen(false)}
 | 
			
		||||
        centered
 | 
			
		||||
        size="sm"
 | 
			
		||||
        classNames={{
 | 
			
		||||
          content: classes.deleteModal,
 | 
			
		||||
        }}
 | 
			
		||||
      >
 | 
			
		||||
        <Text className={classes.deleteModalTitle}>Confirm Update</Text>
 | 
			
		||||
        <Text className={classes.deleteModalContent}>
 | 
			
		||||
          This action will change the employment type to{' '}
 | 
			
		||||
          <strong>Separated</strong>.
 | 
			
		||||
          This action will change the employment type from{' '}
 | 
			
		||||
          <strong>Probation</strong> to <strong>Permanent</strong>.
 | 
			
		||||
        </Text>
 | 
			
		||||
        <Text className={classes.deleteModalContent}>
 | 
			
		||||
          Are you sure you want to proceed?
 | 
			
		||||
| 
						 | 
				
			
			@ -429,7 +344,7 @@ const UsersManagement = () => {
 | 
			
		|||
          <Button
 | 
			
		||||
            variant="outline"
 | 
			
		||||
            onClick={() => {
 | 
			
		||||
              setIsSeparatedConfirmOpen(false)
 | 
			
		||||
              setIsPermanentConfirmOpen(false)
 | 
			
		||||
            }}
 | 
			
		||||
            disabled={disableBtn}
 | 
			
		||||
          >
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,7 +77,6 @@ export type TUser = {
 | 
			
		|||
  name: string
 | 
			
		||||
  permission: string
 | 
			
		||||
  is_permanent: boolean
 | 
			
		||||
  is_separated: boolean
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export type DataReason = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue