mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
Merge branch 'master' into google-calendar
This commit is contained in:
@@ -43,7 +43,7 @@ export function MainNav({ className, ...props }: HTMLAttributes<HTMLElement>) {
|
||||
className={`text-sm font-medium transition-colors hover:text-his hover:border-b-[3px] border-his pt-6 pb-5 ${getMenuActiveStyle('/task')}`}
|
||||
>
|
||||
<i className="ti ti-checklist text-base mr-0.5"></i>
|
||||
My Task
|
||||
Task
|
||||
</Link>
|
||||
{session?.user.detail.role.allow_admin_panel &&
|
||||
<Link
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import dynamic from 'next/dynamic';
|
||||
import FilterComponent from '../../../component/FilterComponent';
|
||||
import ProjectAssignmentDashboardStats from '../../../component/project-assignment/ProjectAssignmentDashboardStats';
|
||||
import { IClient } from '../../../types';
|
||||
|
||||
const AssignmentList = dynamic(
|
||||
() => import('../../../component/project-assignment/AssignmentList'),
|
||||
@@ -69,12 +70,13 @@ const ConfirmDeleteWithInput = dynamic(
|
||||
);
|
||||
|
||||
interface Props {
|
||||
client: IClient;
|
||||
clientId: string;
|
||||
assignmentLists: IProjectAssignment[];
|
||||
actions?: string[]
|
||||
}
|
||||
|
||||
export default function ClientDetailComponent({ clientId, assignmentLists, actions }: Props) {
|
||||
export default function ClientDetailComponent({ client, clientId, assignmentLists, actions }: Props) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const urlLayout = searchParams?.get('layout') as 'grid' | 'list' | null;
|
||||
@@ -133,7 +135,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists, actio
|
||||
This client doesn't have any projects or internal memos yet. Try to change the filter or create one to get started.
|
||||
</p>
|
||||
</div>
|
||||
{actions?.includes("CREATE_ASSIGNMENT") &&
|
||||
{client?.name && actions?.includes("CREATE_ASSIGNMENT") &&
|
||||
<Link href={`/task/client-detail/${clientId}/project-assignments`}>
|
||||
<Button variant="outline" className="mt-4">Create Assignment</Button>
|
||||
</Link>
|
||||
|
||||
@@ -61,7 +61,7 @@ export default function ClientProfileCard({ client, clientId, actions }: Props)
|
||||
|
||||
{/* Right: + New assignment Button */}
|
||||
<div className="shrink-0 self-start lg:self-center">
|
||||
{actions?.includes("CREATE_ASSIGNMENT") &&
|
||||
{client.name && actions?.includes("CREATE_ASSIGNMENT") &&
|
||||
<Link href={`/task/client-detail/${clientId}/project-assignments`}>
|
||||
<Button className="gap-2 bg-his hover:bg-his/90 text-white font-medium rounded-xl px-5 py-2.5 shadow-sm transition-transform active:scale-[0.98]">
|
||||
<Plus className="h-4 w-4" />
|
||||
|
||||
@@ -103,6 +103,7 @@ export default async function ClientDetailPage({ params, searchParams }: Props)
|
||||
</Reveal>
|
||||
|
||||
<ClientDetailComponent
|
||||
client={client}
|
||||
clientId={client_id}
|
||||
assignmentLists={filterAssignments}
|
||||
actions={actions}
|
||||
|
||||
+11
-9
@@ -527,15 +527,17 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
<Button
|
||||
onClick={() => setAction('MANAGE_EMPLOYEE')}
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="gap-1.5 transition-transform active:scale-[0.98]"
|
||||
>
|
||||
<UserPlus className="h-4 w-4" />
|
||||
Manage team
|
||||
</Button>
|
||||
{actions?.includes("MANAGE_TEAM") &&
|
||||
<Button
|
||||
onClick={() => setAction('MANAGE_EMPLOYEE')}
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="gap-1.5 transition-transform active:scale-[0.98]"
|
||||
>
|
||||
<UserPlus className="h-4 w-4" />
|
||||
Manage team
|
||||
</Button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
>
|
||||
|
||||
@@ -36,7 +36,8 @@ const FormEndUser: FC<Props> = ({ data, onSuccess, onCancel }) => {
|
||||
|
||||
const existFile = data?.photo || null
|
||||
const dropzoneRef = useRef<any>(null);
|
||||
const maxSizeMB = 5
|
||||
const maxSizeMB = 2
|
||||
const maxSizeBytes = maxSizeMB * 1024 * 1024;
|
||||
|
||||
const openDialog = () => {
|
||||
// Note that the ref is set async,
|
||||
@@ -48,6 +49,13 @@ const FormEndUser: FC<Props> = ({ data, onSuccess, onCancel }) => {
|
||||
|
||||
const onDrop = useCallback((acceptedFiles: any[]) => {
|
||||
acceptedFiles.forEach(async (file: any) => {
|
||||
if (file.size > maxSizeBytes) {
|
||||
toast.error('File size exceeds the limit', {
|
||||
description: `Maximum allowed file size is ${maxSizeMB}MB.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onabort = () => console.log('file reading was aborted');
|
||||
@@ -184,7 +192,7 @@ const FormEndUser: FC<Props> = ({ data, onSuccess, onCancel }) => {
|
||||
<Label>Add End User Image</Label>
|
||||
{/* Drop area */}
|
||||
<Dropzone ref={dropzoneRef} onDrop={onDrop} multiple={false} noClick noKeyboard
|
||||
accept={{ 'image/*': ['.png', '.bmp', '.jpeg', '.jpg', '.webp'] }}
|
||||
accept={{ 'image/*': ['.svg', '.png', '.bmp', '.jpeg', '.jpg', '.webp'] }}
|
||||
>
|
||||
{/* @ts-ignore */}
|
||||
{({ getRootProps, getInputProps, acceptedFiles }) => {
|
||||
@@ -217,7 +225,7 @@ const FormEndUser: FC<Props> = ({ data, onSuccess, onCancel }) => {
|
||||
</div>
|
||||
<p className="mb-1.5 text-sm font-medium">Drop your files here</p>
|
||||
<p className="text-muted-foreground text-xs">
|
||||
SVG, PNG, JPG or GIF (max. {maxSizeMB}MB)
|
||||
SVG, PNG, JPG, WEBP, BMP or GIF (max. {maxSizeMB}MB)
|
||||
</p>
|
||||
<Button type='button' variant="outline" className="mt-4" onClick={openDialog}>
|
||||
<UploadIcon className="-ms-1 opacity-60" aria-hidden="true" />
|
||||
|
||||
@@ -76,7 +76,7 @@ export default function UpdateAdministrationStatus({
|
||||
}, [assignment, statusList]);
|
||||
|
||||
const [selectedStatusId, setSelectedStatusId] = useState<string>(initialStatusId);
|
||||
const [description, setDescription] = useState<string>(assignment?.project_assignment_status?.remark || assignment?.project_assignment_status?.description || assignment?.note || '');
|
||||
const [description, setDescription] = useState<string>(assignment?.project_assignment_status?.remark || assignment?.note || '');
|
||||
|
||||
useEffect(() => {
|
||||
if (initialStatusId) {
|
||||
@@ -85,7 +85,7 @@ export default function UpdateAdministrationStatus({
|
||||
}, [initialStatusId]);
|
||||
|
||||
useEffect(() => {
|
||||
const initialRemark = assignment?.project_assignment_status_notes || assignment?.project_assignment_status?.remark || assignment?.project_assignment_status?.description || assignment?.note || '';
|
||||
const initialRemark = assignment?.project_assignment_status_notes || assignment?.project_assignment_status?.remark || assignment?.note || '';
|
||||
setDescription(initialRemark);
|
||||
}, [assignment]);
|
||||
|
||||
|
||||
@@ -137,11 +137,11 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
|
||||
return dayjs(endDate).isBefore(dayjs(startDate), 'day');
|
||||
}, [startDate, endDate]);
|
||||
|
||||
const isDateMissing = !startDate || !endDate;
|
||||
const isDateMissing = !startDate;
|
||||
|
||||
const handleSave = async () => {
|
||||
if (isDateMissing) {
|
||||
toast.error('Date range required', {
|
||||
toast.error('Start Date is required', {
|
||||
description: 'Please select both a start date and an end date.'
|
||||
});
|
||||
return;
|
||||
@@ -258,7 +258,7 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-foreground">
|
||||
End Date <span className="text-destructive">*</span>
|
||||
End Date
|
||||
</label>
|
||||
<DatePicker
|
||||
date={endDate}
|
||||
@@ -298,18 +298,10 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
|
||||
</div>
|
||||
|
||||
<DialogFooter className="gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={onClose}
|
||||
disabled={isSaving}
|
||||
>
|
||||
<Button type="button" variant="outline" onClick={onClose} disabled={isSaving}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={handleSave}
|
||||
disabled={isSaving || isDateRangeInvalid || isDateMissing}
|
||||
<Button type="button" onClick={handleSave} disabled={isSaving || isDateRangeInvalid || isDateMissing}
|
||||
className="bg-his text-white hover:bg-his/90 gap-1.5 shadow-2xs font-medium"
|
||||
>
|
||||
{isSaving ? (
|
||||
|
||||
@@ -40,7 +40,8 @@ const FormClient: FC<Props> = ({ data, onSuccess, onCancel, isRedirectToDetail }
|
||||
|
||||
const existFile = data?.photo || null
|
||||
const dropzoneRef = useRef<any>(null);
|
||||
const maxSizeMB = 5
|
||||
const maxSizeMB = 2
|
||||
const maxSizeBytes = maxSizeMB * 1024 * 1024;
|
||||
|
||||
const openDialog = () => {
|
||||
if (dropzoneRef.current) {
|
||||
@@ -50,6 +51,13 @@ const FormClient: FC<Props> = ({ data, onSuccess, onCancel, isRedirectToDetail }
|
||||
|
||||
const onDrop = useCallback((acceptedFiles: any[]) => {
|
||||
acceptedFiles.forEach(async (file: any) => {
|
||||
if (file.size > maxSizeBytes) {
|
||||
toast.error('File size exceeds the limit', {
|
||||
description: `Maximum allowed file size is ${maxSizeMB}MB.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onabort = () => console.log('file reading was aborted');
|
||||
@@ -208,7 +216,7 @@ const FormClient: FC<Props> = ({ data, onSuccess, onCancel, isRedirectToDetail }
|
||||
<Label>Add Client Image</Label>
|
||||
{/* Drop area */}
|
||||
<Dropzone ref={dropzoneRef} onDrop={onDrop} multiple={false} noClick noKeyboard
|
||||
accept={{ 'image/*': ['.png', '.bmp', '.jpeg', '.jpg', '.webp'] }}
|
||||
accept={{ 'image/*': ['.svg', '.png', '.bmp', '.jpeg', '.jpg', '.webp'] }}
|
||||
>
|
||||
{/* @ts-ignore */}
|
||||
{({ getRootProps, getInputProps, acceptedFiles }) => {
|
||||
@@ -241,7 +249,7 @@ const FormClient: FC<Props> = ({ data, onSuccess, onCancel, isRedirectToDetail }
|
||||
</div>
|
||||
<p className="mb-1.5 text-sm font-medium">Drop your files here</p>
|
||||
<p className="text-muted-foreground text-xs">
|
||||
SVG, PNG, JPG or GIF (max. {maxSizeMB}MB)
|
||||
SVG, PNG, JPG, WEBP, BMP or GIF (max. {maxSizeMB}MB)
|
||||
</p>
|
||||
<Button type='button' variant="outline" className="mt-4" onClick={openDialog}>
|
||||
<UploadIcon className="-ms-1 opacity-60" aria-hidden="true" />
|
||||
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
import { redirect } from "next/navigation"
|
||||
import { notFound, redirect } from "next/navigation"
|
||||
import { ResponseData } from "@/types/types"
|
||||
import { logger } from "./logger"
|
||||
import { getCacheServerSession } from "./get-access-data"
|
||||
@@ -24,6 +24,7 @@ export default async function fetchData(url: string = '/', cache: "default" | "f
|
||||
|
||||
console.log("FETCH ERROR DATA :", res.status, data)
|
||||
if (res.status === 401 || res.status === 403) return redirect(`/auth?error=Session error or has expired !`)
|
||||
if (res.status === 404) notFound()
|
||||
// This will activate the closest `error.js` Error Boundary
|
||||
throw new Error(`(${data.code || res.status}) ${data.message || res.statusText}`)
|
||||
}
|
||||
@@ -62,6 +63,7 @@ export async function fetchDataWithPost(url: string = '/', payload: any = {}, ca
|
||||
|
||||
console.log("FETCH ERROR DATA :", res.status, data)
|
||||
if (res.status === 401 || res.status === 403) redirect(`/auth?error=Session error or has expired !`);
|
||||
if (res.status === 404) notFound()
|
||||
|
||||
throw new Error(`(${data?.code || res.status} ${res.statusText}) ${data?.message}`);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ const nextConfig: NextConfig = {
|
||||
reactStrictMode: false,
|
||||
experimental: {
|
||||
authInterrupts: true, // for forbidden page
|
||||
// MEMORY OPTIMIZING
|
||||
// 1. Prevent Next.js from loading all route modules into RAM at startup
|
||||
preloadEntriesOnStart: false,
|
||||
// 2. Optimize barrel imports (e.g., lucide-react, @mui/icons-material, lodash)
|
||||
optimizePackageImports: ['lucide-react', 'date-fns', 'lodash'],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@
|
||||
"url": "https://github.com/ichsankurnia/hats-app/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "next dev -p 1209",
|
||||
"dev": "set NODE_OPTIONS=\"--max-old-space-size=2048\" && next dev -p 1209",
|
||||
"dev:save": "set NODE_TLS_REJECT_UNAUTHORIZED='0' && next dev -p 1209",
|
||||
"build": "next build",
|
||||
"start": "next start -p 7002",
|
||||
@@ -95,4 +95,4 @@
|
||||
"tw-animate-css": "^1.4.0",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -30,5 +30,5 @@
|
||||
".next/dev/types/**/*.ts",
|
||||
"**/*.mts"
|
||||
],
|
||||
"exclude": ["node_modules", "**/*.old.tsx", "**/*.old.ts"]
|
||||
"exclude": ["node_modules", ".next", "**/*.old.tsx", "**/*.old.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user