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-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 />
|
|
|
|
|
<div className="flex flex-row">
|
|
|
|
|
<SidebarManagement />
|
2025-01-04 03:44:57 +00:00
|
|
|
<div className="w-2/3 p-12">
|
|
|
|
|
<div className="flex flex-col">
|
|
|
|
|
<p className="text-lg font-semibold">Tim {profile?.institute?.name}</p>
|
|
|
|
|
<p className="text-base mb-3">{user?.length} Anggota</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-row gap-5">
|
|
|
|
|
{user?.map((row: any) => (
|
|
|
|
|
<div key={row?.id}>
|
|
|
|
|
<Dialog>
|
|
|
|
|
<DialogTrigger>
|
|
|
|
|
<div className="flex flex-col items-center">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="5em" height="5em" viewBox="0 0 16 16">
|
|
|
|
|
<path fill="currentColor" d="M11 7c0 1.66-1.34 3-3 3S5 8.66 5 7s1.34-3 3-3s3 1.34 3 3" />
|
|
|
|
|
<path
|
|
|
|
|
fill="black"
|
|
|
|
|
fill-rule="evenodd"
|
|
|
|
|
d="M16 8c0 4.42-3.58 8-8 8s-8-3.58-8-8s3.58-8 8-8s8 3.58 8 8M4 13.75C4.16 13.484 5.71 11 7.99 11c2.27 0 3.83 2.49 3.99 2.75A6.98 6.98 0 0 0 14.99 8c0-3.87-3.13-7-7-7s-7 3.13-7 7c0 2.38 1.19 4.49 3.01 5.75"
|
|
|
|
|
clip-rule="evenodd"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
<p className="font-semibold text-md">{row?.fullname}</p>
|
|
|
|
|
<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;
|