From 4e11dc1571e8d4d55b85cc4b26666c51b314eb42 Mon Sep 17 00:00:00 2001 From: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Date: Thu, 14 May 2026 23:46:57 +0000 Subject: [PATCH] chore: update --- .../shift-schedule/ShiftDetailModal.tsx | 43 ++++++++++++++++++- next.config.ts | 2 +- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/components/organisms/shift-schedule/ShiftDetailModal.tsx b/components/organisms/shift-schedule/ShiftDetailModal.tsx index b4dd6da..65e2585 100644 --- a/components/organisms/shift-schedule/ShiftDetailModal.tsx +++ b/components/organisms/shift-schedule/ShiftDetailModal.tsx @@ -3,7 +3,8 @@ import { useAuth } from "@/lib/auth-context"; import { DEPARTMENTS } from "@/lib/constants"; import { useShift } from "@/lib/shift-context"; -import { useState } from "react"; +import { useQuery } from "@tanstack/react-query"; +import { useEffect, useState } from "react"; import type { ShiftDetailModalProps } from "./ShiftSchedule.types"; @@ -82,6 +83,44 @@ export default function ShiftDetailModal({ absent: "bg-red-100 text-red-700", }; + const StaffName = ({ staffId }: { staffId: string }) => { + const [name, setName] = useState(""); + const [loading, setLoading] = useState(true); + + useEffect(() => { + // Hàm gọi API + const getName = async () => { + try { + setLoading(true); + + const response = await fetch(`/api/staff/${staffId}`); + + if (!response.ok) { + throw new Error("Mạng lỗi hoặc không tìm thấy nhân viên"); + } + + const data = await response.json(); + + setName(data["name"]); + } catch (error) { + console.error("Lỗi khi lấy tên:", error); + setName("Lỗi tải tên"); + } finally { + setLoading(false); + } + }; + + if (staffId) { + getName(); + } + }, [staffId]); // Chạy lại nếu staffId thay đổi + + if (loading) + return ...; + + return {name || "N/A"}; + }; + return (
{/* Backdrop */} @@ -183,7 +222,7 @@ export default function ShiftDetailModal({
- {staff.staffId} + {isManager && ( diff --git a/next.config.ts b/next.config.ts index 101d15a..03d277a 100644 --- a/next.config.ts +++ b/next.config.ts @@ -20,7 +20,7 @@ const nextConfig: NextConfig = { ], }, async rewrites() { - const gatewayUrl = "http://localhost:32080"; + const gatewayUrl = "http://172.17.0.1:32080"; return [ { source: "/api/:path*",