mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 11:06:29 +00:00
Add timestamps to activity logs
Require a date and time when creating activity logs, allow minute-level selection, and improve date-picker scrolling within dialogs.
This commit is contained in:
+19
-1
@@ -16,6 +16,8 @@ import {
|
||||
} from '@/components/ui/select';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
import { FilePlus2, Loader2, Save } from 'lucide-react';
|
||||
import { DateTimePicker } from '@/components/ui/date-time-picker';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export interface IActivityLogType {
|
||||
id: number;
|
||||
@@ -52,6 +54,7 @@ export default function AddActivityLogModal({
|
||||
const router = useRouter();
|
||||
const [selectedTypeId, setSelectedTypeId] = useState<string>('13');
|
||||
const [description, setDescription] = useState<string>('');
|
||||
const [date, setDate] = useState<Date | undefined>();
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
const { data: fetchedData, isLoading: isLoadingTypes } = useFetchWithAxios(open ? '/project-assignment-status?type=log' : null);
|
||||
@@ -88,6 +91,7 @@ export default function AddActivityLogModal({
|
||||
|
||||
const typeName = activeType?.name || 'update';
|
||||
const payload = {
|
||||
date_at: dayjs(date).format('YYYY-MM-DD HH:mm:ss'),
|
||||
project_assignment_id: Number(assignmentId),
|
||||
type: typeName,
|
||||
description: description.trim(),
|
||||
@@ -142,6 +146,20 @@ export default function AddActivityLogModal({
|
||||
|
||||
{/* Form Body */}
|
||||
<form onSubmit={handleSubmit} className="space-y-5 px-6 pb-5 pt-0">
|
||||
{/* Description Field */}
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="log-description" className="text-xs font-semibold text-foreground">
|
||||
Datetime <span className="text-destructive">*</span>
|
||||
</Label>
|
||||
</div>
|
||||
<DateTimePicker
|
||||
placeholder="Pilih tanggal selesai"
|
||||
date={date}
|
||||
setDate={setDate}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Activity Type Field with Badge */}
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
@@ -222,7 +240,7 @@ export default function AddActivityLogModal({
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={isSubmitting || !description.trim()}
|
||||
disabled={isSubmitting || !description.trim() || !date}
|
||||
className="text-xs gap-1.5 bg-his hover:bg-his/90 text-white font-medium shadow-md shadow-his/20"
|
||||
>
|
||||
{isSubmitting ? (
|
||||
|
||||
Reference in New Issue
Block a user