260322:1648 Correct Coresspondence / Doing RFA / Correct CI
CI Pipeline / build (push) Failing after 12m41s
Build and Deploy / deploy (push) Failing after 2m44s

This commit is contained in:
admin
2026-03-22 16:48:12 +07:00
parent e5deedb42e
commit 11984bfa29
683 changed files with 105251 additions and 29068 deletions
+2 -6
View File
@@ -3,13 +3,9 @@
// Force dynamic rendering for all pages under (auth) route group.
// QNAP overlayfs cannot handle the .segments/!<base64> directories
// that Next.js 16 creates during static page generation.
export const dynamic = "force-dynamic";
export const dynamic = 'force-dynamic';
export default function AuthLayout({
children,
}: {
children: React.ReactNode;
}) {
export default function AuthLayout({ children }: { children: React.ReactNode }) {
return (
<div className="flex min-h-screen w-full items-center justify-center bg-muted/40 p-4">
{/* Container หลักจัดกึ่งกลาง */}
+36 -57
View File
@@ -1,31 +1,24 @@
// File: app/(auth)/login/page.tsx
"use client";
'use client';
import { useState } from "react";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import * as z from "zod";
import { signIn } from "next-auth/react";
import { useRouter } from "next/navigation";
import { Eye, EyeOff, Loader2 } from "lucide-react";
import { toast } from "sonner";
import { useState } from 'react';
import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import * as z from 'zod';
import { signIn } from 'next-auth/react';
import { useRouter } from 'next/navigation';
import { Eye, EyeOff, Loader2 } from 'lucide-react';
import { toast } from 'sonner';
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
// กำหนด Schema สำหรับตรวจสอบข้อมูลฟอร์ม
const loginSchema = z.object({
username: z.string().min(1, "กรุณาระบุชื่อผู้ใช้งาน"),
password: z.string().min(1, "กรุณาระบุรหัสผ่าน"),
username: z.string().min(1, 'กรุณาระบุชื่อผู้ใช้งาน'),
password: z.string().min(1, 'กรุณาระบุรหัสผ่าน'),
});
type LoginValues = z.infer<typeof loginSchema>;
@@ -44,8 +37,8 @@ export default function LoginPage() {
} = useForm<LoginValues>({
resolver: zodResolver(loginSchema),
defaultValues: {
username: "",
password: "",
username: '',
password: '',
},
});
@@ -55,7 +48,7 @@ export default function LoginPage() {
try {
// เรียกใช้ NextAuth signIn (Credential Provider)
const result = await signIn("credentials", {
const result = await signIn('credentials', {
username: data.username,
password: data.password,
redirect: false, // เราจะจัดการ Redirect เอง
@@ -63,21 +56,21 @@ export default function LoginPage() {
if (result?.error) {
// กรณี Login ไม่สำเร็จ
toast.error("เข้าสู่ระบบไม่สำเร็จ", {
description: "ชื่อผู้ใช้งานหรือรหัสผ่านไม่ถูกต้อง กรุณาลองใหม่",
toast.error('เข้าสู่ระบบไม่สำเร็จ', {
description: 'ชื่อผู้ใช้งานหรือรหัสผ่านไม่ถูกต้อง กรุณาลองใหม่',
});
return;
}
// Login สำเร็จ -> ไปหน้า Dashboard
toast.success("เข้าสู่ระบบสำเร็จ", {
description: "กำลังพาท่านไปยังหน้า Dashboard...",
toast.success('เข้าสู่ระบบสำเร็จ', {
description: 'กำลังพาท่านไปยังหน้า Dashboard...',
});
router.push("/dashboard");
router.push('/dashboard');
router.refresh(); // Refresh เพื่อให้ Server Component รับรู้ Session ใหม่
} catch (error) {
toast.error("เกิดข้อผิดพลาด", {
description: "ระบบขัดข้อง กรุณาลองใหม่อีกครั้ง หรือติดต่อผู้ดูแลระบบ",
} catch (_error) {
toast.error('เกิดข้อผิดพลาด', {
description: 'ระบบขัดข้อง กรุณาลองใหม่อีกครั้ง หรือติดต่อผู้ดูแลระบบ',
});
} finally {
setIsLoading(false);
@@ -87,12 +80,8 @@ export default function LoginPage() {
return (
<Card className="w-full max-w-sm shadow-lg">
<CardHeader className="space-y-1 text-center">
<CardTitle className="text-2xl font-bold text-primary">
LCBP3 DMS
</CardTitle>
<CardDescription>
</CardDescription>
<CardTitle className="text-2xl font-bold text-primary">LCBP3 DMS</CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<form onSubmit={handleSubmit(onSubmit)}>
@@ -108,14 +97,10 @@ export default function LoginPage() {
autoComplete="username"
autoCorrect="off"
disabled={isLoading}
className={errors.username ? "border-destructive" : ""}
{...register("username")}
className={errors.username ? 'border-destructive' : ''}
{...register('username')}
/>
{errors.username && (
<p className="text-xs text-destructive">
{errors.username.message}
</p>
)}
{errors.username && <p className="text-xs text-destructive">{errors.username.message}</p>}
</div>
{/* Password Field */}
@@ -125,11 +110,11 @@ export default function LoginPage() {
<Input
id="password"
placeholder="••••••••"
type={showPassword ? "text" : "password"}
type={showPassword ? 'text' : 'password'}
autoComplete="current-password"
disabled={isLoading}
className={errors.password ? "border-destructive pr-10" : "pr-10"}
{...register("password")}
className={errors.password ? 'border-destructive pr-10' : 'pr-10'}
{...register('password')}
/>
{/* ปุ่ม Show/Hide Password */}
<Button
@@ -145,16 +130,10 @@ export default function LoginPage() {
) : (
<Eye className="h-4 w-4 text-muted-foreground" />
)}
<span className="sr-only">
{showPassword ? "Hide password" : "Show password"}
</span>
<span className="sr-only">{showPassword ? 'Hide password' : 'Show password'}</span>
</Button>
</div>
{errors.password && (
<p className="text-xs text-destructive">
{errors.password.message}
</p>
)}
{errors.password && <p className="text-xs text-destructive">{errors.password.message}</p>}
</div>
</CardContent>