fix: bug fix on datepicker simply get year for dob
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled

This commit is contained in:
Vincent Chandra Trie Novan 2025-04-27 21:56:28 +07:00
parent 3111c72091
commit c5c8e44752
7 changed files with 76 additions and 27 deletions

View File

@ -75,7 +75,13 @@ class RegistrationController extends Controller
*/ */
public function create() public function create()
{ {
$patients = Patient::select(['id', 'name'])->get(); $patients = Patient::select(['id', 'name'])
->whereNotExists(function($query) {
$query->select(DB::raw(1))
->from('t_registration')
->whereRaw('t_registration.patient_id = m_patient.id');
})
->get();
$employees = Employee::with('user:id,name')->get()->map(function ($employee) { $employees = Employee::with('user:id,name')->get()->map(function ($employee) {
return [ return [
'id' => $employee->id, 'id' => $employee->id,

View File

@ -98,6 +98,7 @@ class TransactionController extends Controller
return [ return [
'id' => $employee->id, 'id' => $employee->id,
'name' => $employee->user->name, 'name' => $employee->user->name,
'specialization' => $employee->specialization,
]; ];
}); });
@ -262,6 +263,7 @@ class TransactionController extends Controller
return [ return [
'id' => $employee->id, 'id' => $employee->id,
'name' => $employee->user->name, 'name' => $employee->user->name,
'specialization' => $employee->specialization,
]; ];
}); });

View File

@ -24,6 +24,11 @@ const mainNavItems: NavItem[] = [
href: '/dashboard', href: '/dashboard',
icon: LayoutGrid, icon: LayoutGrid,
}, },
{
title: 'Data Pasien',
href: '/patients',
icon: LucideAmbulance,
},
{ {
title: 'Registrasi', title: 'Registrasi',
href: '/registrations', href: '/registrations',
@ -42,11 +47,6 @@ const masterNavItems = [
href: '/employees', href: '/employees',
icon: Users, icon: Users,
}, },
{
title: 'Data Pasien',
href: '/patients',
icon: LucideAmbulance,
},
{ {
title: 'Data Asuransi', title: 'Data Asuransi',
href: '/insurances', href: '/insurances',

View File

@ -184,17 +184,38 @@ export default function EmployeeForm({ mode, employee }: EmployeeFormProps) {
{data.birth_date ? ( {data.birth_date ? (
format(new Date(data.birth_date), "dd/MM/yyyy") format(new Date(data.birth_date), "dd/MM/yyyy")
) : ( ) : (
<span>Pilih Tanggal</span> <span>Pilih tanggal</span>
)} )}
</Button> </Button>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent className="w-auto p-0"> <PopoverContent className="w-auto p-0" align="start">
<div className="flex flex-col">
<div className="flex justify-between px-3 pt-3">
<select
value={data.birth_date ? new Date(data.birth_date).getFullYear() : new Date().getFullYear()}
onChange={(e) => {
const currentDate = data.birth_date ? new Date(data.birth_date) : new Date();
const newDate = new Date(currentDate);
newDate.setFullYear(parseInt(e.target.value));
setData('birth_date', toLocalISOString(newDate));
}}
className="border rounded px-2 py-1 text-sm"
>
{Array.from({ length: 100 }, (_, i) => new Date().getFullYear() - i).map((year) => (
<option key={year} value={year}>
{year}
</option>
))}
</select>
</div>
<Calendar <Calendar
mode="single" mode="single"
selected={data.birth_date ? new Date(data.birth_date) : undefined} selected={data.birth_date ? new Date(data.birth_date) : undefined}
onSelect={(date) => date && setData('birth_date', toLocalISOString(date))} onSelect={(date) => date && setData('birth_date', toLocalISOString(date))}
initialFocus initialFocus
showOutsideDays={false}
/> />
</div>
</PopoverContent> </PopoverContent>
</Popover> </Popover>
<InputError message={errors.birth_date} /> <InputError message={errors.birth_date} />

View File

@ -167,13 +167,34 @@ export default function PatientForm({ mode, patient }: PatientFormProps) {
)} )}
</Button> </Button>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent className="w-auto p-0"> <PopoverContent className="w-auto p-0" align="start">
<div className="flex flex-col">
<div className="flex justify-between px-3 pt-3">
<select
value={data.birth_date ? new Date(data.birth_date).getFullYear() : new Date().getFullYear()}
onChange={(e) => {
const currentDate = data.birth_date ? new Date(data.birth_date) : new Date();
const newDate = new Date(currentDate);
newDate.setFullYear(parseInt(e.target.value));
setData('birth_date', toLocalISOString(newDate));
}}
className="border rounded px-2 py-1 text-sm"
>
{Array.from({ length: 100 }, (_, i) => new Date().getFullYear() - i).map((year) => (
<option key={year} value={year}>
{year}
</option>
))}
</select>
</div>
<Calendar <Calendar
mode="single" mode="single"
selected={data.birth_date ? new Date(data.birth_date) : undefined} selected={data.birth_date ? new Date(data.birth_date) : undefined}
onSelect={(date) => date && setData('birth_date', toLocalISOString(date))} onSelect={(date) => date && setData('birth_date', toLocalISOString(date))}
initialFocus initialFocus
showOutsideDays={false}
/> />
</div>
</PopoverContent> </PopoverContent>
</Popover> </Popover>
<InputError message={errors.birth_date} /> <InputError message={errors.birth_date} />

View File

@ -303,7 +303,7 @@ export default function TransactionForm({
<SelectContent> <SelectContent>
{employees.map((employee) => ( {employees.map((employee) => (
<SelectItem key={employee.id} value={employee.id}> <SelectItem key={employee.id} value={employee.id}>
{employee.name} {employee.name} - {employee.specialization}
</SelectItem> </SelectItem>
))} ))}
</SelectContent> </SelectContent>
@ -486,10 +486,11 @@ export default function TransactionForm({
<Label htmlFor="paid_amount">Jumlah Pembayaran *</Label> <Label htmlFor="paid_amount">Jumlah Pembayaran *</Label>
<Input <Input
id="paid_amount" id="paid_amount"
type="number" type="text"
value={data.paid_amount} value={formatCurrency(data.paid_amount)}
onChange={(e) => { onChange={(e) => {
const paidAmount = Math.max(0, parseFloat(e.target.value) || 0); const numericValue = e.target.value.replace(/[^0-9]/g, '');
const paidAmount = parseFloat(numericValue) || 0;
setData('paid_amount', paidAmount); setData('paid_amount', paidAmount);
}} }}
placeholder="Jumlah pembayaran" placeholder="Jumlah pembayaran"

View File

@ -150,7 +150,6 @@ export default function TransactionIndex() {
<TableHead>No. Invoice</TableHead> <TableHead>No. Invoice</TableHead>
<TableHead>No. Registrasi</TableHead> <TableHead>No. Registrasi</TableHead>
<TableHead>Nama Pasien</TableHead> <TableHead>Nama Pasien</TableHead>
<TableHead>Asuransi</TableHead>
<TableHead>Petugas Kasir</TableHead> <TableHead>Petugas Kasir</TableHead>
<TableHead>Tanggal Transaksi</TableHead> <TableHead>Tanggal Transaksi</TableHead>
<TableHead>Status</TableHead> <TableHead>Status</TableHead>
@ -163,7 +162,6 @@ export default function TransactionIndex() {
<TableCell className="font-medium">{transaction.invoice_number}</TableCell> <TableCell className="font-medium">{transaction.invoice_number}</TableCell>
<TableCell>{transaction.registration_number}</TableCell> <TableCell>{transaction.registration_number}</TableCell>
<TableCell>{transaction.patient_name}</TableCell> <TableCell>{transaction.patient_name}</TableCell>
<TableCell>{transaction.insurance_name || 'Tanpa Asuransi'}</TableCell>
<TableCell>{transaction.cashier_name || 'N/A'}</TableCell> <TableCell>{transaction.cashier_name || 'N/A'}</TableCell>
<TableCell> <TableCell>
{new Date(transaction.transaction_datetime).toLocaleDateString('id-ID', { {new Date(transaction.transaction_datetime).toLocaleDateString('id-ID', {