fix:button approver

This commit is contained in:
Anang Yusman 2026-01-26 12:25:42 +08:00
parent 3a12d7baa7
commit 3716fa3cd8
2 changed files with 19 additions and 9 deletions

View File

@ -48,10 +48,14 @@ export default function PromoDetailDialog({
const router = useRouter();
const [userRoleId, setUserRoleId] = useState<string | null>(null);
const MySwal = withReactContent(Swal);
// 🔹 Ambil userlevelId dari cookies
useEffect(() => {
const ulne = Cookies.get("ulne"); // contoh: "3"
setUserLevelId(ulne ?? null);
const urie = Cookies.get("urie"); // contoh: "3"
setUserRoleId(urie ?? null);
}, []);
// FORMAT TANGGAL → DD-MM-YYYY
@ -325,7 +329,7 @@ export default function PromoDetailDialog({
<p className="text-center text-gray-600">Data tidak ditemukan</p>
)}
</div>
{userLevelId !== "2" && promo && (
{userRoleId !== "2" && promo && (
<div className="flex justify-between items-center gap-3 px-6 py-4 border-t bg-[#F2F7FA]">
{promo.status_id === 1 ? (
<>
@ -351,7 +355,7 @@ export default function PromoDetailDialog({
Reject
</Button>
{userLevelId === "1" && (
{userRoleId === "1" && (
<Button
// variant="ghost"
size="sm"

View File

@ -101,7 +101,7 @@ export default function DetailAgentForm(props: { isDetail: boolean }) {
const id = params?.id;
const [data, setData] = useState<any>(null);
const [openApproverHistory, setOpenApproverHistory] = useState(false);
const [userLevelId, setUserLevelId] = useState<string | null>(null);
const router = useRouter();
const [openCommentModal, setOpenCommentModal] = useState(false);
@ -115,11 +115,17 @@ export default function DetailAgentForm(props: { isDetail: boolean }) {
setOpenCommentModal(false);
};
// 🔹 Ambil userlevelId dari cookies
const [userRoleId, setUserRoleId] = useState<string | null>(null);
const MySwal = withReactContent(Swal);
// 🔹 Ambil userlevelId dari cookies
useEffect(() => {
const ulne = Cookies.get("ulne"); // contoh: "3"
setUserLevelId(ulne ?? null);
const urie = Cookies.get("urie"); // contoh: "3"
setUserRoleId(urie ?? null);
}, []);
useEffect(() => {
fetchData();
}, []);
@ -313,7 +319,7 @@ export default function DetailAgentForm(props: { isDetail: boolean }) {
<p>Jaecoo - Approver | 10/11/2026</p>
</div>
</div>
{userLevelId !== "2" && data && (
{userRoleId !== "2" && data && (
<div className="flex justify-between items-center gap-3 px-6 py-4 border-t bg-[#F2F7FA] mt-10">
{data.status_id === 1 ? (
<>
@ -333,7 +339,7 @@ export default function DetailAgentForm(props: { isDetail: boolean }) {
Reject
</Button>
{userLevelId === "1" && (
{userRoleId === "1" && (
<Button
className="bg-green-600 hover:bg-green-700 text-white w-[180px]"
onClick={() => handleApproveAgent(data.id)}