2025-01-04 03:44:57 +00:00
|
|
|
"use client";
|
|
|
|
|
|
2025-01-02 11:53:11 +00:00
|
|
|
import HeaderManagement from "@/components/landing-page/header-management";
|
|
|
|
|
import SidebarManagement from "@/components/landing-page/sidebar-management";
|
2025-01-04 03:44:57 +00:00
|
|
|
import { close, error, loading } from "@/config/swal";
|
|
|
|
|
import { getCookiesDecrypt } from "@/lib/utils";
|
2025-01-16 16:55:04 +00:00
|
|
|
import { getInfoProfile, getUsersTeams, saveUserReports } from "@/service/landing/landing";
|
2025-01-04 03:44:57 +00:00
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
|
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
|
|
|
|
import withReactContent from "sweetalert2-react-content";
|
|
|
|
|
import Swal from "sweetalert2";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
2025-01-16 16:55:04 +00:00
|
|
|
import toast from "react-hot-toast";
|
|
|
|
|
import { useToast } from "@/components/ui/use-toast";
|
|
|
|
|
import { ToastAction } from "@/components/ui/toast";
|
2025-02-11 11:16:07 +00:00
|
|
|
import Image from "next/image";
|
2025-01-02 11:53:11 +00:00
|
|
|
|
|
|
|
|
const page = () => {
|
2025-01-04 03:44:57 +00:00
|
|
|
const [user, setUser] = useState<any>();
|
|
|
|
|
const [profile, setProfile] = useState<any>();
|
|
|
|
|
const instituteId = getCookiesDecrypt("uinse");
|
|
|
|
|
const [userSelected, setUserSelected] = useState();
|
|
|
|
|
const [reportMessage, setReportMessage] = useState<string>();
|
|
|
|
|
const MySwal = withReactContent(Swal);
|
2025-01-16 16:55:04 +00:00
|
|
|
const { toast } = useToast();
|
|
|
|
|
const [reportMessageOpen, setReportMessageOpen] = useState(false);
|
2025-01-04 03:44:57 +00:00
|
|
|
|
|
|
|
|
// const launchModal = (user: any) => {
|
|
|
|
|
// setUserSelected(user);
|
|
|
|
|
// $("#modalDetailProfile").modal("show");
|
|
|
|
|
// };
|
|
|
|
|
async function onSubmit() {
|
|
|
|
|
MySwal.fire({
|
|
|
|
|
title: "Simpan Data",
|
|
|
|
|
text: "",
|
|
|
|
|
icon: "warning",
|
|
|
|
|
showCancelButton: true,
|
|
|
|
|
cancelButtonColor: "#d33",
|
|
|
|
|
confirmButtonColor: "#3085d6",
|
|
|
|
|
confirmButtonText: "Simpan",
|
|
|
|
|
}).then((result) => {
|
|
|
|
|
if (result.isConfirmed) {
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function save() {
|
2025-01-16 16:55:04 +00:00
|
|
|
setReportMessageOpen(false);
|
|
|
|
|
|
2025-01-04 03:44:57 +00:00
|
|
|
loading();
|
|
|
|
|
const data = {
|
|
|
|
|
userId: user?.id,
|
|
|
|
|
message: reportMessage,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const response = await saveUserReports(data);
|
|
|
|
|
|
|
|
|
|
if (response?.error) {
|
2025-01-16 16:55:04 +00:00
|
|
|
toast({
|
|
|
|
|
variant: "destructive",
|
|
|
|
|
title: "Uh oh! Something went wrong.",
|
|
|
|
|
});
|
|
|
|
|
// error(response?.message);
|
2025-01-04 03:44:57 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
close();
|
|
|
|
|
|
2025-01-16 16:55:04 +00:00
|
|
|
toast({
|
|
|
|
|
title: "Success !!",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// toast.success("SUKSES !!", {
|
|
|
|
|
// position: "top-right",
|
|
|
|
|
// });
|
|
|
|
|
// successSubmit();
|
2025-01-04 03:44:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function successSubmit() {
|
|
|
|
|
MySwal.fire({
|
|
|
|
|
title: "Sukses",
|
|
|
|
|
icon: "success",
|
|
|
|
|
confirmButtonColor: "#3085d6",
|
|
|
|
|
confirmButtonText: "OK",
|
|
|
|
|
}).then((result) => {
|
|
|
|
|
if (result.isConfirmed) {
|
|
|
|
|
("hide");
|
|
|
|
|
// $("#modalReportProfile").modal("hide");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
async function getTeams() {
|
|
|
|
|
if (instituteId != undefined) {
|
|
|
|
|
loading();
|
|
|
|
|
const response = await getUsersTeams(instituteId);
|
|
|
|
|
setUser(response?.data?.data);
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getProfile() {
|
|
|
|
|
loading();
|
|
|
|
|
const response = await getInfoProfile();
|
|
|
|
|
setProfile(response?.data?.data);
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getTeams();
|
|
|
|
|
getProfile();
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-01-02 11:53:11 +00:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<HeaderManagement />
|
2025-01-31 12:51:04 +00:00
|
|
|
<div className="flex flex-col lg:flex-row">
|
2025-01-02 11:53:11 +00:00
|
|
|
<SidebarManagement />
|
2025-01-04 03:44:57 +00:00
|
|
|
<div className="w-2/3 p-12">
|
|
|
|
|
<div className="flex flex-col">
|
2025-02-11 11:16:07 +00:00
|
|
|
<p className="text-2xl w-fit font-bold bg-[#bb3523] px-4 py-1 rounded-lg text-center text-white my-4 ">
|
|
|
|
|
<span className="text-black">Tim </span>
|
|
|
|
|
{profile?.institute?.name}
|
|
|
|
|
</p>
|
|
|
|
|
<p className="text-base mb-3">
|
|
|
|
|
{user?.length} Anggota Tim {profile?.institute?.name}
|
|
|
|
|
</p>
|
2025-01-04 03:44:57 +00:00
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-row gap-5">
|
|
|
|
|
{user?.map((row: any) => (
|
|
|
|
|
<div key={row?.id}>
|
|
|
|
|
<Dialog>
|
|
|
|
|
<DialogTrigger>
|
2025-02-11 11:16:07 +00:00
|
|
|
<div className="flex flex-col items-center border border-gray-500 p-2 bg-[#f8f8f8] rounded-md">
|
|
|
|
|
<Image src="/assets/gg-profile.png" alt="" width={1280} height={720} className="h-10 w-10 mb-4" />
|
|
|
|
|
<p className="font-bold text-base ">{row?.fullname}</p>
|
2025-01-04 03:44:57 +00:00
|
|
|
<p className="text-sm font-light">{row?.username || "username"}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</DialogTrigger>
|
|
|
|
|
<DialogContent className="flex flex-row justify-center" size="sm">
|
|
|
|
|
<div className="flex flex-col w-full gap-2">
|
|
|
|
|
<div>
|
|
|
|
|
<h1 className="font-semibold">{row?.fullname}</h1>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="border-b border-black w-full"></div>
|
|
|
|
|
<div className="gap-1">
|
|
|
|
|
<div className="font-light">{row?.email}</div>
|
|
|
|
|
<div className="font-light">{row?.phoneNumber}</div>
|
|
|
|
|
<div className="font-light">{row?.address}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="border-b border-black w-full"></div>
|
|
|
|
|
<div className="place-items-end">
|
2025-01-16 16:55:04 +00:00
|
|
|
<Dialog open={reportMessageOpen} onOpenChange={setReportMessageOpen}>
|
2025-01-04 03:44:57 +00:00
|
|
|
<DialogTrigger asChild>
|
2025-01-16 16:55:04 +00:00
|
|
|
<Button variant="outline" className="bg-red-500 rounded-md text-white hover:bg-white hover:text-red-500">
|
2025-01-04 03:44:57 +00:00
|
|
|
Report
|
|
|
|
|
</Button>
|
|
|
|
|
</DialogTrigger>
|
|
|
|
|
<DialogContent className="sm:max-w-[425px]">
|
|
|
|
|
<div className="flex flex-col w-full gap-2">
|
|
|
|
|
<div>
|
|
|
|
|
<h1 className="font-semibold">{row?.fullname}</h1>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="border-b border-black w-full"></div>
|
|
|
|
|
<div className="flex flex-col">
|
|
|
|
|
<h1 className="text-red-600 mb-2">Alasan Report Akun</h1>
|
2025-01-16 16:55:04 +00:00
|
|
|
<textarea id="formControlTextarea1" rows={4} className="border border-black font-light" onChange={(e: any) => setReportMessage(e.target.value)} />
|
2025-01-04 03:44:57 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<DialogFooter>
|
2025-01-16 16:55:04 +00:00
|
|
|
<Dialog>
|
|
|
|
|
<DialogTrigger asChild>
|
|
|
|
|
<Button className="bg-red-500 text-white" type="submit">
|
|
|
|
|
Kirim
|
|
|
|
|
</Button>
|
|
|
|
|
</DialogTrigger>
|
|
|
|
|
<DialogContent>
|
|
|
|
|
<h1>Simpan Data?</h1>
|
|
|
|
|
<DialogFooter>
|
|
|
|
|
<DialogClose>
|
|
|
|
|
<Button onClick={save}>Simpan</Button>
|
|
|
|
|
</DialogClose>
|
|
|
|
|
<DialogClose>
|
|
|
|
|
<Button>Cancel</Button>
|
|
|
|
|
</DialogClose>
|
|
|
|
|
</DialogFooter>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
2025-01-04 03:44:57 +00:00
|
|
|
</DialogFooter>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-01-02 11:53:11 +00:00
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default page;
|