fix: final commit #46

Merged
TakahashiNguyen merged 10 commits from fix-lmao into main 2026-05-15 13:22:13 +00:00
2 changed files with 42 additions and 3 deletions
Showing only changes of commit 4e11dc1571 - Show all commits
@@ -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 <span className="animate-pulse text-gray-400">...</span>;
return <span>{name || "N/A"}</span>;
};
return (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4">
{/* Backdrop */}
@@ -183,7 +222,7 @@ export default function ShiftDetailModal({
<i className="fa-solid fa-user text-[10px] text-(--color-primary)"></i>
</div>
<span className="text-foreground text-sm font-medium">
{staff.staffId}
<StaffName staffId={staff.staffId} />
</span>
</div>
{isManager && (
+1 -1
View File
@@ -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*",