feat:add notification, profile
This commit is contained in:
parent
990fbf44a5
commit
2af3b88fc5
|
|
@ -0,0 +1,122 @@
|
|||
import * as React from "react";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
|
||||
import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuItem,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { format } from "date-fns";
|
||||
import { Link } from "@/components/navigation";
|
||||
|
||||
const columns: ColumnDef<any>[] = [
|
||||
{
|
||||
accessorKey: "no",
|
||||
header: "No",
|
||||
cell: ({ row }) => <span>{row.getValue("no")}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "title",
|
||||
header: "Title",
|
||||
cell: ({ row }) => (
|
||||
<span className="whitespace-normal">{row.getValue("title")}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "categoryName",
|
||||
header: "Category",
|
||||
cell: ({ row }) => <span>{row.getValue("categoryName")}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "createdAt",
|
||||
header: "Upload Date",
|
||||
cell: ({ row }) => {
|
||||
const createdAt = row.getValue("createdAt") as
|
||||
| string
|
||||
| number
|
||||
| undefined;
|
||||
|
||||
const formattedDate =
|
||||
createdAt && !isNaN(new Date(createdAt).getTime())
|
||||
? format(new Date(createdAt), "dd-MM-yyyy HH:mm:ss")
|
||||
: "-";
|
||||
return <span className="whitespace-nowrap">{formattedDate}</span>;
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "tags",
|
||||
header: "Tag",
|
||||
cell: ({ row }) => <span className="">{row.getValue("tags")}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "statusName",
|
||||
header: "Status",
|
||||
cell: ({ row }) => {
|
||||
const statusColors: Record<string, string> = {
|
||||
diterima: "bg-green-100 text-green-600",
|
||||
"menunggu review": "bg-orange-100 text-orange-600",
|
||||
};
|
||||
|
||||
// Mengambil `statusName` dari data API
|
||||
const status = row.getValue("statusName") as string;
|
||||
const statusName = status?.toLocaleLowerCase(); // Ubah ke huruf kecil
|
||||
|
||||
// Gunakan `statusName` untuk pencocokan
|
||||
const statusStyles =
|
||||
statusColors[statusName] || "bg-gray-100 text-gray-600";
|
||||
|
||||
return (
|
||||
<Badge className={cn("rounded-full px-5", statusStyles)}>
|
||||
{status} {/* Tetap tampilkan nilai asli */}
|
||||
</Badge>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
id: "actions",
|
||||
accessorKey: "action",
|
||||
header: "Actions",
|
||||
enableHiding: false,
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
size="icon"
|
||||
className="bg-transparent ring-offset-transparent hover:bg-transparent hover:ring-0 hover:ring-transparent"
|
||||
>
|
||||
<span className="sr-only">Open menu</span>
|
||||
<MoreVertical className="h-4 w-4 text-default-800" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="p-0" align="end">
|
||||
<Link href={`/contributor/blog/detail/${row.original.id}`}>
|
||||
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
||||
<Eye className="w-4 h-4 me-1.5" />
|
||||
View
|
||||
</DropdownMenuItem>
|
||||
</Link>
|
||||
<Link href={`/contributor/blog/update/${row.original.id}`}>
|
||||
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
||||
<SquarePen className="w-4 h-4 me-1.5" />
|
||||
Edit
|
||||
</DropdownMenuItem>
|
||||
</Link>
|
||||
<DropdownMenuItem className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none">
|
||||
<Trash2 className="w-4 h-4 me-1.5" />
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default columns;
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { getNotifications } from "@/service/notifications/notifications";
|
||||
import {
|
||||
CalendarCheck,
|
||||
CheckCheck,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
CircleAlert,
|
||||
Clock7,
|
||||
MessageCircle,
|
||||
SquareCheck,
|
||||
UploadIcon,
|
||||
} from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export type Notification = {
|
||||
id: number;
|
||||
notificationTypeId: number;
|
||||
message: string;
|
||||
createdAt: string;
|
||||
isActive: boolean;
|
||||
isPublic: boolean;
|
||||
isRead: boolean;
|
||||
redirectUrl: string;
|
||||
userGroupIdDst: string | null;
|
||||
userIdDst: string | null;
|
||||
userLevelIdDst: string;
|
||||
userLevelNumberDst: string | null;
|
||||
userRoleIdDst: string;
|
||||
};
|
||||
|
||||
const getNotificationIcon = (notificationTypeId: number) => {
|
||||
switch (notificationTypeId) {
|
||||
case 2:
|
||||
return <MessageCircle className="h-8 w-8 text-success" />;
|
||||
case 3:
|
||||
return <UploadIcon className="h-5 w-5 text-warning" />;
|
||||
case 4:
|
||||
return <CheckCheck className="h-5 w-5 text-primary" />;
|
||||
case 5:
|
||||
return <SquareCheck className="h-5 w-5 text-warning" />;
|
||||
case 6:
|
||||
return <CalendarCheck className="h-5 w-5 text-danger" />;
|
||||
case 7:
|
||||
return <CircleAlert className="h-5 w-5 text-danger" />;
|
||||
case 8:
|
||||
return <Clock7 className="h-5 w-5 text-danger" />;
|
||||
default:
|
||||
return <SquareCheck className="h-5 w-5 text-danger" />;
|
||||
}
|
||||
};
|
||||
|
||||
const NotificationsList: React.FC = () => {
|
||||
const router = useRouter();
|
||||
const [notifications, setNotifications] = useState<Notification[]>([]);
|
||||
const [totalData, setTotalData] = useState<number>(0);
|
||||
const [page, setPage] = useState<number>(1);
|
||||
const [pageSize] = useState<number>(10);
|
||||
const [totalPage, setTotalPage] = useState<number>(1);
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchNotifications() {
|
||||
const response = await getNotifications(page - 1, pageSize);
|
||||
setNotifications(response.data?.data?.content || []);
|
||||
setTotalData(response.data?.data?.totalElements || 0);
|
||||
setTotalPage(response.data?.data?.totalPages);
|
||||
}
|
||||
fetchNotifications();
|
||||
}, [page, pageSize]);
|
||||
|
||||
const handleNotificationClick = (redirectUrl: string) => {
|
||||
router.push(redirectUrl);
|
||||
};
|
||||
|
||||
const handlePageChange = (newPage: number) => {
|
||||
setPage(newPage);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mx-3">
|
||||
<div className="space-y-3">
|
||||
{notifications.length > 0 ? (
|
||||
notifications.map((notification) => (
|
||||
<div
|
||||
key={notification.id}
|
||||
className="flex items-start space-x-4 p-4 border rounded-lg shadow-sm bg-white cursor-pointer"
|
||||
onClick={() => handleNotificationClick(notification.redirectUrl)}
|
||||
>
|
||||
<div className="flex-shrink-0">
|
||||
<div className="flex-none">
|
||||
{getNotificationIcon(notification.notificationTypeId)}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-sm font-medium">{notification.message}</p>
|
||||
<p className="text-xs text-gray-500">
|
||||
{new Date(notification.createdAt).toLocaleString()}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<p className="text-gray-500 text-sm">Tidak ada notifikasi.</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Pagination */}
|
||||
<div className="flex justify-end items-center mt-6 gap-3 mb-3">
|
||||
<Button
|
||||
onClick={() => handlePageChange(page - 1)}
|
||||
disabled={page === 1}
|
||||
variant="outline"
|
||||
className="rounded-full"
|
||||
size="sm"
|
||||
>
|
||||
<ChevronLeft size={20} />
|
||||
</Button>
|
||||
<p className="text-sm">
|
||||
Page {page} of {totalPage}
|
||||
</p>
|
||||
<Button
|
||||
onClick={() => handlePageChange(page + 1)}
|
||||
disabled={page === totalPage}
|
||||
variant="outline"
|
||||
className="rounded-full"
|
||||
size="sm"
|
||||
>
|
||||
<ChevronRight size={20} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default NotificationsList;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
export const metadata = {
|
||||
title: "Notifications",
|
||||
};
|
||||
|
||||
const Layout = ({ children }: { children: React.ReactNode }) => {
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
export default Layout;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import SiteBreadcrumb from "@/components/site-breadcrumb";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Plus } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Link } from "@/components/navigation";
|
||||
import BlogTable from "../contributor/blog/components/blog-table";
|
||||
import NotificationsTable from "./components/notifications-table";
|
||||
|
||||
const NotificationsPage = async () => {
|
||||
return (
|
||||
<div>
|
||||
<SiteBreadcrumb />
|
||||
<div className="space-y-4">
|
||||
<Card>
|
||||
<CardHeader className="border-b border-solid border-default-200 mb-6">
|
||||
<CardTitle>
|
||||
<div className="flex items-center">
|
||||
<div className="flex-1 text-xl font-medium text-default-900">
|
||||
Table List Notifications
|
||||
</div>
|
||||
</div>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="p-0">
|
||||
<NotificationsTable />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default NotificationsPage;
|
||||
|
|
@ -0,0 +1,193 @@
|
|||
"use client";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { control } from "leaflet";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import * as z from "zod";
|
||||
import Swal from "sweetalert2";
|
||||
import { getBlog, postBlog } from "@/service/blog/blog";
|
||||
import { id } from "date-fns/locale";
|
||||
import router from "next/router";
|
||||
import { getInfoProfile, saveUser, setupPassword } from "@/service/auth";
|
||||
import withReactContent from "sweetalert2-react-content";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Link } from "@/components/navigation";
|
||||
|
||||
const profileSchema = z.object({
|
||||
password: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
retypePassword: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
});
|
||||
|
||||
type Detail = {
|
||||
id: number;
|
||||
userId: any;
|
||||
password: string;
|
||||
retypePassword: string;
|
||||
};
|
||||
|
||||
const ChangePassword: React.FC = () => {
|
||||
const MySwal = withReactContent(Swal);
|
||||
const [detail, setDetail] = useState<Detail>();
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
|
||||
type ProfileSchema = z.infer<typeof profileSchema>;
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
formState: { errors },
|
||||
} = useForm<ProfileSchema>({
|
||||
resolver: zodResolver(profileSchema),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
async function initState() {
|
||||
const response = await getInfoProfile();
|
||||
const details = response.data?.data;
|
||||
|
||||
setDetail(details);
|
||||
console.log("data", details);
|
||||
}
|
||||
|
||||
initState();
|
||||
}, []);
|
||||
|
||||
const save = async (data: ProfileSchema) => {
|
||||
const requestData = {
|
||||
...data,
|
||||
// userId: detail?.userKeycloakId,
|
||||
password: data.password,
|
||||
retypePassword: detail?.retypePassword,
|
||||
};
|
||||
|
||||
const response = await setupPassword(requestData);
|
||||
console.log("Form Data Submitted:", requestData);
|
||||
console.log("response", response);
|
||||
|
||||
MySwal.fire({
|
||||
title: "Sukses",
|
||||
text: "Data berhasil disimpan.",
|
||||
icon: "success",
|
||||
confirmButtonColor: "#3085d6",
|
||||
confirmButtonText: "OK",
|
||||
}).then(() => {
|
||||
router.push("/en/auth");
|
||||
});
|
||||
};
|
||||
|
||||
const onSubmit = (data: ProfileSchema) => {
|
||||
MySwal.fire({
|
||||
title: "Simpan Data",
|
||||
text: "Apakah Anda yakin ingin menyimpan data ini?",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonColor: "#3085d6",
|
||||
confirmButtonText: "Simpan",
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
save(data);
|
||||
}
|
||||
});
|
||||
};
|
||||
return (
|
||||
<div className="px-4 lg:px-14 py-8">
|
||||
<div className="text-center mb-8">
|
||||
<div className="w-20 h-20 mx-auto rounded-full bg-red-700 flex items-center justify-center">
|
||||
<span className="text-white text-3xl font-bold">👤</span>
|
||||
</div>
|
||||
<h1 className="text-2xl font-bold mt-4">Ubah Profile</h1>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-center gap-4 mb-8">
|
||||
<Link href={"/profile"}>
|
||||
<button className="border border-red-700 text-red-700 px-4 py-2 rounded">
|
||||
User Profile
|
||||
</button>
|
||||
</Link>
|
||||
<Link href={"/profile/change-profile"}>
|
||||
<button className="border border-red-700 text-red-700 px-4 py-2 rounded">
|
||||
Ubah Foto
|
||||
</button>
|
||||
</Link>
|
||||
<Link href={"/profile/change-password"}>
|
||||
<button className="bg-red-700 text-white px-4 py-2 rounded">
|
||||
Ubah Password
|
||||
</button>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="max-w-3xl mx-auto bg-white shadow-sm p-4 rounded">
|
||||
<p className="mb-6 text-gray-600">
|
||||
Silahkan ubah data pribadi Anda pada form berikut.
|
||||
</p>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div>
|
||||
<div className="mb-4">
|
||||
<Label>
|
||||
Password<span className="text-red-500">*</span>
|
||||
</Label>
|
||||
<Controller
|
||||
control={control}
|
||||
name="password"
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
size="md"
|
||||
type="password"
|
||||
defaultValue={field.value}
|
||||
onChange={field.onChange}
|
||||
placeholder="Enter Title"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.password?.message && (
|
||||
<p className="text-red-400 text-sm">
|
||||
{errors.password.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="mb-4">
|
||||
<Label>
|
||||
Konfirmasi Password<span className="text-red-500">*</span>
|
||||
</Label>
|
||||
<Controller
|
||||
control={control}
|
||||
name="retypePassword"
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
size="md"
|
||||
type="password"
|
||||
defaultValue={field.value}
|
||||
onChange={field.onChange}
|
||||
placeholder="Enter Title"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.retypePassword?.message && (
|
||||
<p className="text-red-400 text-sm">
|
||||
{errors.retypePassword.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="mt-4">
|
||||
<button
|
||||
type="submit"
|
||||
className="bg-red-700 text-white px-6 py-2 rounded hover:bg-red-800 focus:outline-none focus:ring focus:ring-red-300"
|
||||
>
|
||||
Simpan
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ChangePassword;
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
"use client";
|
||||
import { Link } from "@/components/navigation";
|
||||
import React, { useState } from "react";
|
||||
|
||||
const ChangeProfile: React.FC = () => {
|
||||
const [selectedImage, setSelectedImage] = useState<File | null>(null);
|
||||
|
||||
const handleImageChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.target.files && e.target.files[0]) {
|
||||
setSelectedImage(e.target.files[0]);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
if (selectedImage) {
|
||||
console.log("Foto berhasil diganti:", selectedImage.name);
|
||||
alert("Foto berhasil diganti.");
|
||||
} else {
|
||||
alert("Silakan pilih foto terlebih dahulu.");
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = () => {
|
||||
setSelectedImage(null);
|
||||
alert("Foto berhasil dihapus.");
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="px-4 lg:px-14 py-8">
|
||||
<div className="text-center mb-8">
|
||||
<div className="w-20 h-20 mx-auto rounded-full bg-red-700 flex items-center justify-center">
|
||||
<span className="text-white text-3xl font-bold">👤</span>
|
||||
</div>
|
||||
<h1 className="text-2xl font-bold mt-4">Ubah Photo</h1>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-center gap-4 mb-8">
|
||||
<Link href={"/profile"}>
|
||||
<button className="border border-red-700 text-red-700 px-4 py-2 rounded">
|
||||
User Profile
|
||||
</button>
|
||||
</Link>
|
||||
<Link href={"/profile/change-profile"}>
|
||||
<button className="bg-red-700 text-white px-4 py-2 rounded">
|
||||
Ubah Foto
|
||||
</button>
|
||||
</Link>
|
||||
<Link href={"/profile/change-password"}>
|
||||
<button className="border border-red-700 text-red-700 px-4 py-2 rounded">
|
||||
Ubah Password
|
||||
</button>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="w-80 mx-auto bg-gray-900 text-white shadow-md p-8 rounded">
|
||||
<div className="flex justify-center mb-6">
|
||||
<div className="w-40 h-40 rounded-full border border-gray-300 flex items-center justify-center">
|
||||
{selectedImage ? (
|
||||
<img
|
||||
src={URL.createObjectURL(selectedImage)}
|
||||
alt="Preview"
|
||||
className="w-full h-full rounded-full object-cover"
|
||||
/>
|
||||
) : (
|
||||
<span className="text-gray-500">No Image</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-center gap-4">
|
||||
<input
|
||||
type="file"
|
||||
id="upload"
|
||||
accept="image/*"
|
||||
className="hidden"
|
||||
onChange={handleImageChange}
|
||||
/>
|
||||
<label
|
||||
htmlFor="upload"
|
||||
className="bg-blue-600 text-white px-4 py-2 rounded cursor-pointer"
|
||||
>
|
||||
Ganti Foto
|
||||
</label>
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
className="border border-red-700 text-red-700 px-4 py-2 rounded"
|
||||
>
|
||||
Hapus Foto
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ChangeProfile;
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import LayoutProvider from "@/providers/layout.provider";
|
||||
import LayoutContentProvider from "@/providers/content.provider";
|
||||
import DashCodeSidebar from "@/components/partials/sidebar";
|
||||
import DashCodeFooter from "@/components/partials/footer";
|
||||
import ThemeCustomize from "@/components/partials/customizer";
|
||||
import DashCodeHeader from "@/components/partials/header";
|
||||
|
||||
import { redirect } from "@/components/navigation";
|
||||
import Footer from "@/components/landing-page/footer";
|
||||
import Navbar from "@/components/landing-page/navbar";
|
||||
|
||||
const layout = async ({ children }: { children: React.ReactNode }) => {
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
{children}
|
||||
<Footer />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default layout;
|
||||
|
|
@ -0,0 +1,301 @@
|
|||
"use client";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { control } from "leaflet";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import * as z from "zod";
|
||||
import Swal from "sweetalert2";
|
||||
import { getBlog, postBlog } from "@/service/blog/blog";
|
||||
import { id } from "date-fns/locale";
|
||||
import router from "next/router";
|
||||
import { getInfoProfile, saveUser } from "@/service/auth";
|
||||
import withReactContent from "sweetalert2-react-content";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Link } from "@/components/navigation";
|
||||
|
||||
const profileSchema = z.object({
|
||||
username: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
fullname: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
memberIdentity: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
email: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
address: z
|
||||
.string()
|
||||
.min(2, { message: "Narasi Penugasan harus lebih dari 2 karakter." }),
|
||||
phoneNumber: z.string().min(1, { message: "Kategori diperlukan" }),
|
||||
});
|
||||
|
||||
type Detail = {
|
||||
id: number;
|
||||
userId: any;
|
||||
firstName: string;
|
||||
username: string;
|
||||
fullname: string;
|
||||
memberIdentity: any;
|
||||
email: string;
|
||||
address: string;
|
||||
phoneNumber: any;
|
||||
message: string;
|
||||
};
|
||||
|
||||
const UbahProfile: React.FC = () => {
|
||||
const MySwal = withReactContent(Swal);
|
||||
const [detail, setDetail] = useState<Detail>();
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
|
||||
type ProfileSchema = z.infer<typeof profileSchema>;
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
formState: { errors },
|
||||
} = useForm<ProfileSchema>({
|
||||
resolver: zodResolver(profileSchema),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
async function initState() {
|
||||
const response = await getInfoProfile();
|
||||
const details = response.data?.data;
|
||||
|
||||
setDetail(details);
|
||||
console.log("data", details);
|
||||
}
|
||||
|
||||
initState();
|
||||
}, []);
|
||||
|
||||
const save = async (data: ProfileSchema) => {
|
||||
const requestData = {
|
||||
...data,
|
||||
// userId: detail?.userKeycloakId,
|
||||
firstName: detail?.fullname,
|
||||
username: detail?.username,
|
||||
memberIdentity: detail?.memberIdentity,
|
||||
email: detail?.email,
|
||||
address: detail?.address,
|
||||
phoneNumber: detail?.phoneNumber,
|
||||
// message: data.title,
|
||||
};
|
||||
|
||||
const response = await saveUser(requestData);
|
||||
console.log("Form Data Submitted:", requestData);
|
||||
console.log("response", response);
|
||||
|
||||
MySwal.fire({
|
||||
title: "Sukses",
|
||||
text: "Data berhasil disimpan.",
|
||||
icon: "success",
|
||||
confirmButtonColor: "#3085d6",
|
||||
confirmButtonText: "OK",
|
||||
}).then(() => {
|
||||
router.push("/en/auth");
|
||||
});
|
||||
};
|
||||
|
||||
const onSubmit = (data: ProfileSchema) => {
|
||||
MySwal.fire({
|
||||
title: "Simpan Data",
|
||||
text: "Apakah Anda yakin ingin menyimpan data ini?",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonColor: "#3085d6",
|
||||
confirmButtonText: "Simpan",
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
save(data);
|
||||
}
|
||||
});
|
||||
};
|
||||
return (
|
||||
<div className="px-4 lg:px-14 py-8">
|
||||
<div className="text-center mb-8">
|
||||
<div className="w-20 h-20 mx-auto rounded-full bg-red-700 flex items-center justify-center">
|
||||
<span className="text-white text-3xl font-bold">👤</span>
|
||||
</div>
|
||||
<h1 className="text-2xl font-bold mt-4">Ubah Profile</h1>
|
||||
</div>
|
||||
<div className="flex justify-center gap-4 mb-8">
|
||||
<Link href={"/profile"}>
|
||||
<button className="bg-red-700 text-white px-4 py-2 rounded">
|
||||
User Profile
|
||||
</button>
|
||||
</Link>
|
||||
<Link href={"/profile/change-profile"}>
|
||||
<button className="border border-red-700 text-red-700 px-4 py-2 rounded">
|
||||
Ubah Foto
|
||||
</button>
|
||||
</Link>
|
||||
<Link href={"/profile/change-password"}>
|
||||
<button className="border border-red-700 text-red-700 px-4 py-2 rounded">
|
||||
Ubah Password
|
||||
</button>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="max-w-3xl mx-auto bg-white shadow-sm p-4 rounded">
|
||||
<p className="mb-6 text-gray-600">
|
||||
Silahkan ubah data pribadi Anda pada form berikut.
|
||||
</p>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
{detail !== undefined ? (
|
||||
<div>
|
||||
<div className="mb-4">
|
||||
<Label>
|
||||
Username<span className="text-red-500">*</span>
|
||||
</Label>
|
||||
<Controller
|
||||
control={control}
|
||||
name="username"
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
size="md"
|
||||
type="text"
|
||||
defaultValue={detail?.username}
|
||||
onChange={field.onChange}
|
||||
placeholder="Enter Title"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.username?.message && (
|
||||
<p className="text-red-400 text-sm">
|
||||
{errors.username.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="mb-4">
|
||||
<Label>
|
||||
Nama Lengkap<span className="text-red-500">*</span>
|
||||
</Label>
|
||||
<Controller
|
||||
control={control}
|
||||
name="fullname"
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
size="md"
|
||||
type="text"
|
||||
defaultValue={detail?.fullname}
|
||||
onChange={field.onChange}
|
||||
placeholder="Enter Title"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.fullname?.message && (
|
||||
<p className="text-red-400 text-sm">
|
||||
{errors.fullname.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="mb-4">
|
||||
<Label>
|
||||
Nomor Identitas<span className="text-red-500">*</span>
|
||||
</Label>
|
||||
<Controller
|
||||
control={control}
|
||||
name="memberIdentity"
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
size="md"
|
||||
type="text"
|
||||
defaultValue={detail?.memberIdentity}
|
||||
onChange={field.onChange}
|
||||
placeholder="Enter Title"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.memberIdentity?.message && (
|
||||
<p className="text-red-400 text-sm">
|
||||
{errors.memberIdentity.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="mb-4">
|
||||
<Label>
|
||||
Email<span className="text-red-500">*</span>
|
||||
</Label>
|
||||
<Controller
|
||||
control={control}
|
||||
name="email"
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
size="md"
|
||||
type="text"
|
||||
defaultValue={detail?.email}
|
||||
onChange={field.onChange}
|
||||
placeholder="Enter Title"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.email?.message && (
|
||||
<p className="text-red-400 text-sm">{errors.email.message}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="mb-4">
|
||||
<Label>
|
||||
Nomor HP<span className="text-red-500">*</span>
|
||||
</Label>
|
||||
<Controller
|
||||
control={control}
|
||||
name="phoneNumber"
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
size="md"
|
||||
type="number"
|
||||
defaultValue={detail?.phoneNumber}
|
||||
onChange={field.onChange}
|
||||
placeholder="Enter Title"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.phoneNumber?.message && (
|
||||
<p className="text-red-400 text-sm">
|
||||
{errors.phoneNumber.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="mb-4">
|
||||
<Label>
|
||||
Alamat<span className="text-red-500">*</span>
|
||||
</Label>
|
||||
<Controller
|
||||
control={control}
|
||||
name="address"
|
||||
render={({ field }) => (
|
||||
<Textarea
|
||||
defaultValue={detail?.address}
|
||||
onChange={field.onChange}
|
||||
placeholder="Enter Title"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.address?.message && (
|
||||
<p className="text-red-400 text-sm">
|
||||
{errors.address.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="mt-4">
|
||||
<button
|
||||
type="submit"
|
||||
className="bg-red-700 text-white px-6 py-2 rounded hover:bg-red-800 focus:outline-none focus:ring focus:ring-red-300"
|
||||
>
|
||||
Simpan
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default UbahProfile;
|
||||
|
|
@ -60,6 +60,7 @@ export default function FormUpdatePressConference() {
|
|||
|
||||
const [detail, setDetail] = useState<Detail>();
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [location, setLocation] = useState("");
|
||||
|
||||
const {
|
||||
control,
|
||||
|
|
@ -89,6 +90,7 @@ export default function FormUpdatePressConference() {
|
|||
if (details) {
|
||||
setStartTime(details.startTime);
|
||||
setEndTime(details.endTime);
|
||||
setLocation(details.address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -103,6 +105,12 @@ export default function FormUpdatePressConference() {
|
|||
setEndTime(e.target.value);
|
||||
};
|
||||
|
||||
const handleLocationChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||
const value = e.target.value;
|
||||
setLocation(value);
|
||||
setValue("location", value);
|
||||
};
|
||||
|
||||
const save = async (data: TaskSchema) => {
|
||||
const requestData: {
|
||||
id?: number;
|
||||
|
|
@ -123,19 +131,18 @@ export default function FormUpdatePressConference() {
|
|||
address: data.location,
|
||||
speakerTitle: data.level,
|
||||
speakerName: data.name,
|
||||
startTime, // Start time from state
|
||||
endTime, // End time from state
|
||||
addressLat: "0.0", // Replace with actual latitude
|
||||
addressLong: "0.0", // Replace with actual longitude
|
||||
startTime,
|
||||
endTime,
|
||||
addressLat: "0.0",
|
||||
addressLong: "0.0",
|
||||
startDate: date?.from ? format(date.from, "yyyy-MM-dd") : null,
|
||||
endDate: date?.to ? format(date.to, "yyyy-MM-dd") : null,
|
||||
isYoutube: isLiveStreamingEnabled,
|
||||
scheduleTypeId: 1,
|
||||
};
|
||||
|
||||
// Add id property if it exists
|
||||
if (id) {
|
||||
requestData.id = parseInt(id, 10); // Ensure id is a number
|
||||
requestData.id = parseInt(id, 10);
|
||||
}
|
||||
|
||||
console.log("Form Data Submitted:", requestData);
|
||||
|
|
@ -309,10 +316,12 @@ export default function FormUpdatePressConference() {
|
|||
</div>
|
||||
</div>
|
||||
<div>
|
||||
{/* Kirim setValue ke MapHome */}
|
||||
<MapHome
|
||||
draggable
|
||||
setLocation={(location) => setValue("location", location)}
|
||||
setLocation={(location) => {
|
||||
setLocation(location);
|
||||
setValue("location", location);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
|
|
@ -322,8 +331,8 @@ export default function FormUpdatePressConference() {
|
|||
render={({ field }) => (
|
||||
<Textarea
|
||||
rows={3}
|
||||
defaultValue={detail?.address}
|
||||
onChange={field.onChange}
|
||||
value={location}
|
||||
onChange={handleLocationChange}
|
||||
placeholder="Masukan lokasi"
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,26 @@ import { FiFile, FiImage, FiMusic, FiYoutube } from "react-icons/fi";
|
|||
import { useParams, usePathname, useRouter } from "next/navigation";
|
||||
import { generateLocalizedPath } from "@/utils/globals";
|
||||
import { Link } from "@/i18n/routing";
|
||||
import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, navigationMenuTriggerStyle } from "@/components/ui/navigation-menu";
|
||||
import {
|
||||
NavigationMenu,
|
||||
NavigationMenuContent,
|
||||
NavigationMenuItem,
|
||||
NavigationMenuLink,
|
||||
NavigationMenuList,
|
||||
NavigationMenuTrigger,
|
||||
navigationMenuTriggerStyle,
|
||||
} from "@/components/ui/navigation-menu";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "../ui/dropdown-menu";
|
||||
import Image from "next/image";
|
||||
import { Icon } from "../ui/icon";
|
||||
import { getCookiesDecrypt } from "@/lib/utils";
|
||||
|
||||
const Navbar = () => {
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
|
|
@ -16,6 +35,10 @@ const Navbar = () => {
|
|||
const locale = params?.locale;
|
||||
const [language, setLanguage] = useState<"id" | "en">("id");
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const fullname = getCookiesDecrypt("ufne");
|
||||
const roleName = getCookiesDecrypt("urne");
|
||||
const levelName = getCookiesDecrypt("ulnae");
|
||||
const roleId = getCookiesDecrypt("urie");
|
||||
|
||||
const handleLanguageChange = (lang: "id" | "en") => {
|
||||
setLanguage(lang);
|
||||
|
|
@ -27,18 +50,41 @@ const Navbar = () => {
|
|||
<div className="flex items-center justify-between px-4 lg:px-20 py-4 gap-3">
|
||||
{/* Logo */}
|
||||
<Link href="/" className="flex items-center">
|
||||
<img src="/assets/mediahub-logo.gif" alt="Media Hub Logo" className="w-fit h-20 md:h-24" />
|
||||
<img
|
||||
src="/assets/mediahub-logo.gif"
|
||||
alt="Media Hub Logo"
|
||||
className="w-fit h-20 md:h-24"
|
||||
/>
|
||||
</Link>
|
||||
|
||||
{/* Mobile Menu Toggle */}
|
||||
<button className="text-black dark:text-white right-0 size-20 h-10 w-10 lg:hidden" onClick={() => setMenuOpen(!menuOpen)}>
|
||||
<button
|
||||
className="text-black dark:text-white right-0 size-20 h-10 w-10 lg:hidden"
|
||||
onClick={() => setMenuOpen(!menuOpen)}
|
||||
>
|
||||
{menuOpen ? (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path fill="#000" d="m13.41 12l4.3-4.29a1 1 0 1 0-1.42-1.42L12 10.59l-4.29-4.3a1 1 0 0 0-1.42 1.42l4.3 4.29l-4.3 4.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l4.29-4.3l4.29 4.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42Z" />
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fill="#000"
|
||||
d="m13.41 12l4.3-4.29a1 1 0 1 0-1.42-1.42L12 10.59l-4.29-4.3a1 1 0 0 0-1.42 1.42l4.3 4.29l-4.3 4.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l4.29-4.3l4.29 4.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42Z"
|
||||
/>
|
||||
</svg>
|
||||
) : (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path fill="#000" d="M4 6a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1m0 6a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1m1 5a1 1 0 1 0 0 2h14a1 1 0 1 0 0-2z" />
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fill="#000"
|
||||
d="M4 6a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1m0 6a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1m1 5a1 1 0 1 0 0 2h14a1 1 0 1 0 0-2z"
|
||||
/>
|
||||
</svg>
|
||||
)}
|
||||
</button>
|
||||
|
|
@ -51,7 +97,14 @@ const Navbar = () => {
|
|||
<NavigationMenuItem>
|
||||
<NavigationMenuTrigger>
|
||||
<a className="dark:text-white text-black flex flex-row justify-center items-center cursor-pointer">
|
||||
<svg className="mx-2 dark:" width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg
|
||||
className="mx-2 dark:"
|
||||
width="25"
|
||||
height="24"
|
||||
viewBox="0 0 25 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M20 7.5H5C4.6023 7.5004 4.221 7.65856 3.93978 7.93978C3.65856 8.221 3.5004 8.6023 3.5 9V19.5C3.5004 19.8977 3.65856 20.279 3.93978 20.5602C4.221 20.8414 4.6023 20.9996 5 21H20C20.3977 20.9996 20.779 20.8414 21.0602 20.5602C21.3414 20.279 21.4996 19.8977 21.5 19.5V9C21.4996 8.6023 21.3414 8.221 21.0602 7.93978C20.779 7.65856 20.3977 7.5004 20 7.5ZM10.25 17.25V11.25L15.5 14.25L10.25 17.25ZM5 4.5H20V6H5V4.5ZM6.5 1.5H18.5V3H6.5V1.5Z"
|
||||
fill="currentColor"
|
||||
|
|
@ -61,25 +114,56 @@ const Navbar = () => {
|
|||
</a>
|
||||
</NavigationMenuTrigger>
|
||||
<NavigationMenuContent className="p-0 rounded-md overflow-hidden w-full">
|
||||
<NavigationMenuLink onClick={() => router.push(generateLocalizedPath("/video/filter", String(locale)))} className="flex items-start gap-1.5 p-2 ">
|
||||
<NavigationMenuLink
|
||||
onClick={() =>
|
||||
router.push(
|
||||
generateLocalizedPath("/video/filter", String(locale))
|
||||
)
|
||||
}
|
||||
className="flex items-start gap-1.5 p-2 "
|
||||
>
|
||||
<p className="text-slate-600 dark:text-white hover:text-[#bb3523] flex flex-row justify-center items-center px-5 py-2 cursor-pointer">
|
||||
<FiYoutube className="mr-2" />
|
||||
Video
|
||||
</p>
|
||||
</NavigationMenuLink>
|
||||
<NavigationMenuLink onClick={() => router.push(generateLocalizedPath("/audio/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 ">
|
||||
<NavigationMenuLink
|
||||
onClick={() =>
|
||||
router.push(
|
||||
generateLocalizedPath("/audio/filter", String(locale))
|
||||
)
|
||||
}
|
||||
className="flex place-items-start gap-1.5 p-2 "
|
||||
>
|
||||
<p className="text-slate-600 dark:text-white hover:text-[#bb3523] flex flex-row justify-center items-center px-5 py-2 cursor-pointer">
|
||||
<FiMusic className="mr-2" />
|
||||
Audio
|
||||
</p>
|
||||
</NavigationMenuLink>
|
||||
<NavigationMenuLink onClick={() => router.push(generateLocalizedPath("/image/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2">
|
||||
<NavigationMenuLink
|
||||
onClick={() =>
|
||||
router.push(
|
||||
generateLocalizedPath("/image/filter", String(locale))
|
||||
)
|
||||
}
|
||||
className="flex place-items-start gap-1.5 p-2"
|
||||
>
|
||||
<p className="text-slate-600 dark:text-white hover:text-[#bb3523] flex flex-row justify-center items-center px-5 py-2 cursor-pointer">
|
||||
<FiImage className="mr-2" />
|
||||
Foto
|
||||
</p>
|
||||
</NavigationMenuLink>
|
||||
<NavigationMenuLink onClick={() => router.push(generateLocalizedPath("/document/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2">
|
||||
<NavigationMenuLink
|
||||
onClick={() =>
|
||||
router.push(
|
||||
generateLocalizedPath(
|
||||
"/document/filter",
|
||||
String(locale)
|
||||
)
|
||||
)
|
||||
}
|
||||
className="flex place-items-start gap-1.5 p-2"
|
||||
>
|
||||
<p className="text-slate-600 dark:text-white hover:text-[#bb3523] flex flex-row justify-center items-center px-5 py-2 cursor-pointer">
|
||||
<FiFile className="mr-2" />
|
||||
Teks
|
||||
|
|
@ -91,7 +175,14 @@ const Navbar = () => {
|
|||
<Link href="/schedule" legacyBehavior passHref>
|
||||
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
|
||||
<span>
|
||||
<svg className="mr-2" width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg
|
||||
className="mr-2"
|
||||
width="25"
|
||||
height="24"
|
||||
viewBox="0 0 25 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M19.5 4H18.5V3C18.5 2.4 18.1 2 17.5 2C16.9 2 16.5 2.4 16.5 3V4H8.5V3C8.5 2.4 8.1 2 7.5 2C6.9 2 6.5 2.4 6.5 3V4H5.5C3.8 4 2.5 5.3 2.5 7V8H22.5V7C22.5 5.3 21.2 4 19.5 4ZM2.5 19C2.5 20.7 3.8 22 5.5 22H19.5C21.2 22 22.5 20.7 22.5 19V10H2.5V19ZM17.5 12C18.1 12 18.5 12.4 18.5 13C18.5 13.6 18.1 14 17.5 14C16.9 14 16.5 13.6 16.5 13C16.5 12.4 16.9 12 17.5 12ZM17.5 16C18.1 16 18.5 16.4 18.5 17C18.5 17.6 18.1 18 17.5 18C16.9 18 16.5 17.6 16.5 17C16.5 16.4 16.9 16 17.5 16ZM12.5 12C13.1 12 13.5 12.4 13.5 13C13.5 13.6 13.1 14 12.5 14C11.9 14 11.5 13.6 11.5 13C11.5 12.4 11.9 12 12.5 12ZM12.5 16C13.1 16 13.5 16.4 13.5 17C13.5 17.6 13.1 18 12.5 18C11.9 18 11.5 17.6 11.5 17C11.5 16.4 11.9 16 12.5 16ZM7.5 12C8.1 12 8.5 12.4 8.5 13C8.5 13.6 8.1 14 7.5 14C6.9 14 6.5 13.6 6.5 13C6.5 12.4 6.9 12 7.5 12ZM7.5 16C8.1 16 8.5 16.4 8.5 17C8.5 17.6 8.1 18 7.5 18C6.9 18 6.5 17.6 6.5 17C6.5 16.4 6.9 16 7.5 16Z"
|
||||
fill="currentColor"
|
||||
|
|
@ -106,7 +197,14 @@ const Navbar = () => {
|
|||
<Link href="/indeks" legacyBehavior passHref>
|
||||
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
|
||||
<span>
|
||||
<svg className="mr-2" width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg
|
||||
className="mr-2"
|
||||
width="25"
|
||||
height="24"
|
||||
viewBox="0 0 25 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
|
|
@ -128,22 +226,40 @@ const Navbar = () => {
|
|||
</Link>
|
||||
<div className="flex items-center space-x-1 ">
|
||||
<a href="https://tvradio.polri.go.id/">
|
||||
<img src="/assets/polriTv.png" className="w-auto lg:max-w-screen-lg h-10 flex-auto " />
|
||||
<img
|
||||
src="/assets/polriTv.png"
|
||||
className="w-auto lg:max-w-screen-lg h-10 flex-auto "
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div className="relative inline-block text-left">
|
||||
{/* Tombol Utama */}
|
||||
<button onClick={() => setIsOpen(!isOpen)} className="flex items-center space-x-2 p-2 text-gray-700 bg-slate-200 rounded-lg">
|
||||
<button
|
||||
onClick={() => setIsOpen(!isOpen)}
|
||||
className="flex items-center space-x-2 p-2 text-gray-700 bg-slate-200 rounded-lg"
|
||||
>
|
||||
<img
|
||||
src={language === "id" ? "https://upload.wikimedia.org/wikipedia/commons/9/9f/Flag_of_Indonesia.svg" : "https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg"}
|
||||
src={
|
||||
language === "id"
|
||||
? "https://upload.wikimedia.org/wikipedia/commons/9/9f/Flag_of_Indonesia.svg"
|
||||
: "https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg"
|
||||
}
|
||||
alt={language === "id" ? "Ind" : "Eng"}
|
||||
className="w-3 h-3"
|
||||
/>
|
||||
<span>{language === "id" ? "Ind" : "Eng"}</span>
|
||||
<span className="text-gray-500">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 32 32">
|
||||
<path fill="currentColor" d="M8.037 11.166L14.5 22.36c.825 1.43 2.175 1.43 3 0l6.463-11.195c.826-1.43.15-2.598-1.5-2.598H9.537c-1.65 0-2.326 1.17-1.5 2.6z" />
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="15"
|
||||
height="15"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M8.037 11.166L14.5 22.36c.825 1.43 2.175 1.43 3 0l6.463-11.195c.826-1.43.15-2.598-1.5-2.598H9.537c-1.65 0-2.326 1.17-1.5 2.6z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
|
|
@ -151,12 +267,30 @@ const Navbar = () => {
|
|||
{/* Dropdown Menu */}
|
||||
{isOpen && (
|
||||
<div className="absolute right-0 mt-2 w-auto bg-slate-200 border rounded-md shadow-lg z-10">
|
||||
<button onClick={() => handleLanguageChange("id")} className={`flex items-center space-x-2 w-full px-4 py-2 ${language === "id" ? "font-medium" : ""}`}>
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/9/9f/Flag_of_Indonesia.svg" alt="Indonesia" className="w-5 h-5" />
|
||||
<button
|
||||
onClick={() => handleLanguageChange("id")}
|
||||
className={`flex items-center space-x-2 w-full px-4 py-2 ${
|
||||
language === "id" ? "font-medium" : ""
|
||||
}`}
|
||||
>
|
||||
<img
|
||||
src="https://upload.wikimedia.org/wikipedia/commons/9/9f/Flag_of_Indonesia.svg"
|
||||
alt="Indonesia"
|
||||
className="w-5 h-5"
|
||||
/>
|
||||
<span>Ind</span>
|
||||
</button>
|
||||
<button onClick={() => handleLanguageChange("en")} className={`flex items-center space-x-2 w-full px-4 py-2 ${language === "en" ? "font-medium" : ""}`}>
|
||||
<img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" alt="English" className="w-5 h-5" />
|
||||
<button
|
||||
onClick={() => handleLanguageChange("en")}
|
||||
className={`flex items-center space-x-2 w-full px-4 py-2 ${
|
||||
language === "en" ? "font-medium" : ""
|
||||
}`}
|
||||
>
|
||||
<img
|
||||
src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg"
|
||||
alt="English"
|
||||
className="w-5 h-5"
|
||||
/>
|
||||
<span>Eng</span>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -164,9 +298,18 @@ const Navbar = () => {
|
|||
</div>
|
||||
<ThemeSwitcher />
|
||||
<div className="relative text-gray-600 dark:text-white">
|
||||
<input type="text" placeholder="Pencarian" className="pl-8 pr-4 py-1 w-28 text-[13px] border rounded-full focus:outline-none dark:text-white" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Pencarian"
|
||||
className="pl-8 pr-4 py-1 w-28 text-[13px] border rounded-full focus:outline-none dark:text-white"
|
||||
/>
|
||||
<span className="absolute left-4 top-1/2 transform -translate-y-1/2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="13"
|
||||
height="13"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
fill-rule="evenodd"
|
||||
|
|
@ -176,12 +319,153 @@ const Navbar = () => {
|
|||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Link href="/auth" className="px-4 py-1 bg-[#bb3523] text-white font-semibold rounded-md hover:bg-[#bb3523]">
|
||||
Masuk
|
||||
</Link>
|
||||
<button className="px-4 py-1 border border-[#bb3523] text-[#bb3523] font-semibold rounded-md hover:bg-[#bb3523] hover:text-white">Daftar</button>
|
||||
</div>
|
||||
|
||||
{roleId === "6" ? (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild className="cursor-pointer">
|
||||
<div className="flex items-center gap-3 text-default-800">
|
||||
<Image
|
||||
src={"https://netidhub.com/assets/img/user-avatar.png"}
|
||||
alt={"Image"}
|
||||
width={36}
|
||||
height={36}
|
||||
className="rounded-full"
|
||||
/>
|
||||
<div>
|
||||
<div className="text-sm font-medium capitalize lg:block hidden">
|
||||
Mabes Polri - Approver
|
||||
</div>
|
||||
<p className="text-xs">(MABES POLRI)</p>
|
||||
</div>
|
||||
<span className="text-base me-2.5 lg:inline-block hidden">
|
||||
<Icon icon="heroicons-outline:chevron-down"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56 p-0" align="end">
|
||||
<DropdownMenuGroup>
|
||||
{[
|
||||
{
|
||||
name: "Profile & Settings",
|
||||
icon: "heroicons:user",
|
||||
href: "/profile",
|
||||
},
|
||||
{
|
||||
name: "Dashboard",
|
||||
icon: "heroicons:megaphone",
|
||||
href: "/dashboard",
|
||||
},
|
||||
].map((item, index) => (
|
||||
<Link
|
||||
href={item.href}
|
||||
key={`info-menu-${index}`}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<DropdownMenuItem className="flex items-center gap-2 text-sm font-medium text-default-600 capitalize px-3 py-1.5 cursor-pointer">
|
||||
<Icon icon={item.icon} className="w-4 h-4" />
|
||||
{item.name}
|
||||
</DropdownMenuItem>
|
||||
</Link>
|
||||
))}
|
||||
</DropdownMenuGroup>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem className="flex items-center gap-2 text-sm font-medium text-default-600 capitalize my-1 px-3 cursor-pointer">
|
||||
<div>
|
||||
<Link href={"/auth"}>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-full flex items-center gap-2"
|
||||
>
|
||||
<Icon icon="heroicons:power" className="w-4 h-4" />
|
||||
Log out
|
||||
</button>
|
||||
</Link>
|
||||
</div>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
) : roleId === "3" ? (
|
||||
// Dropdown menu for roleId === 3
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild className="cursor-pointer">
|
||||
<div className="flex items-center gap-3 text-default-800">
|
||||
<Image
|
||||
src={"https://netidhub.com/assets/img/user-avatar.png"}
|
||||
alt={"Image"}
|
||||
width={36}
|
||||
height={36}
|
||||
className="rounded-full"
|
||||
/>
|
||||
<div>
|
||||
<div className="text-sm font-medium capitalize lg:block hidden">
|
||||
Mabes Polri - Reviewer
|
||||
</div>
|
||||
<p className="text-xs">(MABES POLRI)</p>
|
||||
</div>
|
||||
<span className="text-base me-2.5 lg:inline-block hidden">
|
||||
<Icon icon="heroicons-outline:chevron-down"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56 p-0" align="end">
|
||||
<DropdownMenuGroup>
|
||||
{[
|
||||
{
|
||||
name: "Profile & Settings",
|
||||
icon: "heroicons:user",
|
||||
href: "/profile",
|
||||
},
|
||||
{
|
||||
name: "Dashboard",
|
||||
icon: "heroicons:megaphone",
|
||||
href: "/dashboard",
|
||||
},
|
||||
].map((item, index) => (
|
||||
<Link
|
||||
href={item.href}
|
||||
key={`info-menu-${index}`}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<DropdownMenuItem className="flex items-center gap-2 text-sm font-medium text-default-600 capitalize px-3 py-1.5 cursor-pointer">
|
||||
<Icon icon={item.icon} className="w-4 h-4" />
|
||||
{item.name}
|
||||
</DropdownMenuItem>
|
||||
</Link>
|
||||
))}
|
||||
</DropdownMenuGroup>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem className="flex items-center gap-2 text-sm font-medium text-default-600 capitalize my-1 px-3 cursor-pointer">
|
||||
<div>
|
||||
<Link href={"/auth"}>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-full flex items-center gap-2"
|
||||
>
|
||||
<Icon icon="heroicons:power" className="w-4 h-4" />
|
||||
Log out
|
||||
</button>
|
||||
</Link>
|
||||
</div>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
) : (
|
||||
// Masuk and Daftar buttons for roleId === null
|
||||
<div className="flex justify-center items-center mx-3 gap-5">
|
||||
<Link
|
||||
href="/auth"
|
||||
className="w-full lg:w-fit px-4 py-1 bg-[#bb3523] text-white font-semibold rounded-md hover:bg-red-700 text-center"
|
||||
>
|
||||
Masuk
|
||||
</Link>
|
||||
<Link
|
||||
href="#"
|
||||
className="w-full lg:w-fit px-4 py-1 border border-[#bb3523] text-[#bb3523] font-semibold rounded-md hover:bg-[#bb3523] text-center hover:text-white"
|
||||
>
|
||||
Daftar
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -193,7 +477,14 @@ const Navbar = () => {
|
|||
<NavigationMenuItem>
|
||||
<NavigationMenuTrigger>
|
||||
<a className="dark:text-white text-black flex flex-row justify-center items-center cursor-pointer">
|
||||
<svg className="mx-2 dark:" width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg
|
||||
className="mx-2 dark:"
|
||||
width="25"
|
||||
height="24"
|
||||
viewBox="0 0 25 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M20 7.5H5C4.6023 7.5004 4.221 7.65856 3.93978 7.93978C3.65856 8.221 3.5004 8.6023 3.5 9V19.5C3.5004 19.8977 3.65856 20.279 3.93978 20.5602C4.221 20.8414 4.6023 20.9996 5 21H20C20.3977 20.9996 20.779 20.8414 21.0602 20.5602C21.3414 20.279 21.4996 19.8977 21.5 19.5V9C21.4996 8.6023 21.3414 8.221 21.0602 7.93978C20.779 7.65856 20.3977 7.5004 20 7.5ZM10.25 17.25V11.25L15.5 14.25L10.25 17.25ZM5 4.5H20V6H5V4.5ZM6.5 1.5H18.5V3H6.5V1.5Z"
|
||||
fill="currentColor"
|
||||
|
|
@ -203,25 +494,56 @@ const Navbar = () => {
|
|||
</a>
|
||||
</NavigationMenuTrigger>
|
||||
<NavigationMenuContent className="p-0 rounded-md overflow-hidden w-full">
|
||||
<NavigationMenuLink onClick={() => router.push(generateLocalizedPath("/video/filter", String(locale)))} className="flex items-start gap-1.5 p-2 hover:bg-white">
|
||||
<NavigationMenuLink
|
||||
onClick={() =>
|
||||
router.push(
|
||||
generateLocalizedPath("/video/filter", String(locale))
|
||||
)
|
||||
}
|
||||
className="flex items-start gap-1.5 p-2 hover:bg-white"
|
||||
>
|
||||
<p className="text-slate-600 hover:text-[#bb3523] flex flex-row justify-center items-center px-5 py-2 cursor-pointer">
|
||||
<FiYoutube className="mr-2" />
|
||||
Video
|
||||
</p>
|
||||
</NavigationMenuLink>
|
||||
<NavigationMenuLink onClick={() => router.push(generateLocalizedPath("/audio/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 hover:bg-white">
|
||||
<NavigationMenuLink
|
||||
onClick={() =>
|
||||
router.push(
|
||||
generateLocalizedPath("/audio/filter", String(locale))
|
||||
)
|
||||
}
|
||||
className="flex place-items-start gap-1.5 p-2 hover:bg-white"
|
||||
>
|
||||
<p className="text-slate-600 hover:text-[#bb3523] flex flex-row justify-center items-center px-5 py-2 cursor-pointer">
|
||||
<FiMusic className="mr-2" />
|
||||
Audio
|
||||
</p>
|
||||
</NavigationMenuLink>
|
||||
<NavigationMenuLink onClick={() => router.push(generateLocalizedPath("/image/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 hover:bg-white">
|
||||
<NavigationMenuLink
|
||||
onClick={() =>
|
||||
router.push(
|
||||
generateLocalizedPath("/image/filter", String(locale))
|
||||
)
|
||||
}
|
||||
className="flex place-items-start gap-1.5 p-2 hover:bg-white"
|
||||
>
|
||||
<p className="text-slate-600 hover:text-[#bb3523] flex flex-row justify-center items-center px-5 py-2 cursor-pointer">
|
||||
<FiImage className="mr-2" />
|
||||
Foto
|
||||
</p>
|
||||
</NavigationMenuLink>
|
||||
<NavigationMenuLink onClick={() => router.push(generateLocalizedPath("/document/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 hover:bg-white">
|
||||
<NavigationMenuLink
|
||||
onClick={() =>
|
||||
router.push(
|
||||
generateLocalizedPath(
|
||||
"/document/filter",
|
||||
String(locale)
|
||||
)
|
||||
)
|
||||
}
|
||||
className="flex place-items-start gap-1.5 p-2 hover:bg-white"
|
||||
>
|
||||
<p className="text-slate-600 hover:text-[#bb3523] flex flex-row justify-center items-center px-5 py-2 cursor-pointer">
|
||||
<FiFile className="mr-2" />
|
||||
Teks
|
||||
|
|
@ -233,7 +555,14 @@ const Navbar = () => {
|
|||
<Link href="/schedule" legacyBehavior passHref>
|
||||
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
|
||||
<span>
|
||||
<svg className="mr-2" width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg
|
||||
className="mr-2"
|
||||
width="25"
|
||||
height="24"
|
||||
viewBox="0 0 25 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M19.5 4H18.5V3C18.5 2.4 18.1 2 17.5 2C16.9 2 16.5 2.4 16.5 3V4H8.5V3C8.5 2.4 8.1 2 7.5 2C6.9 2 6.5 2.4 6.5 3V4H5.5C3.8 4 2.5 5.3 2.5 7V8H22.5V7C22.5 5.3 21.2 4 19.5 4ZM2.5 19C2.5 20.7 3.8 22 5.5 22H19.5C21.2 22 22.5 20.7 22.5 19V10H2.5V19ZM17.5 12C18.1 12 18.5 12.4 18.5 13C18.5 13.6 18.1 14 17.5 14C16.9 14 16.5 13.6 16.5 13C16.5 12.4 16.9 12 17.5 12ZM17.5 16C18.1 16 18.5 16.4 18.5 17C18.5 17.6 18.1 18 17.5 18C16.9 18 16.5 17.6 16.5 17C16.5 16.4 16.9 16 17.5 16ZM12.5 12C13.1 12 13.5 12.4 13.5 13C13.5 13.6 13.1 14 12.5 14C11.9 14 11.5 13.6 11.5 13C11.5 12.4 11.9 12 12.5 12ZM12.5 16C13.1 16 13.5 16.4 13.5 17C13.5 17.6 13.1 18 12.5 18C11.9 18 11.5 17.6 11.5 17C11.5 16.4 11.9 16 12.5 16ZM7.5 12C8.1 12 8.5 12.4 8.5 13C8.5 13.6 8.1 14 7.5 14C6.9 14 6.5 13.6 6.5 13C6.5 12.4 6.9 12 7.5 12ZM7.5 16C8.1 16 8.5 16.4 8.5 17C8.5 17.6 8.1 18 7.5 18C6.9 18 6.5 17.6 6.5 17C6.5 16.4 6.9 16 7.5 16Z"
|
||||
fill="currentColor"
|
||||
|
|
@ -248,7 +577,14 @@ const Navbar = () => {
|
|||
<Link href="/indeks" legacyBehavior passHref>
|
||||
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
|
||||
<span>
|
||||
<svg className="mr-2" width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg
|
||||
className="mr-2"
|
||||
width="25"
|
||||
height="24"
|
||||
viewBox="0 0 25 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
|
|
@ -270,21 +606,39 @@ const Navbar = () => {
|
|||
</div>
|
||||
<div className="flex items-center space-x-1 mx-3 text-yellow-600 font-medium">
|
||||
<a href="https://tvradio.polri.go.id/">
|
||||
<img src="/assets/polriTv.png" className="w-21 h-11 flex items-center" />
|
||||
<img
|
||||
src="/assets/polriTv.png"
|
||||
className="w-21 h-11 flex items-center"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
<div className="relative inline-block mx-3 text-left">
|
||||
{/* Tombol Utama Bahasa */}
|
||||
<button onClick={() => setIsOpen(!isOpen)} className="flex items-center space-x-2 p-2 text-gray-700 bg-slate-200 rounded-lg">
|
||||
<button
|
||||
onClick={() => setIsOpen(!isOpen)}
|
||||
className="flex items-center space-x-2 p-2 text-gray-700 bg-slate-200 rounded-lg"
|
||||
>
|
||||
<img
|
||||
src={language === "id" ? "https://upload.wikimedia.org/wikipedia/commons/9/9f/Flag_of_Indonesia.svg" : "https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg"}
|
||||
src={
|
||||
language === "id"
|
||||
? "https://upload.wikimedia.org/wikipedia/commons/9/9f/Flag_of_Indonesia.svg"
|
||||
: "https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg"
|
||||
}
|
||||
alt={language === "id" ? "Ind" : "Eng"}
|
||||
className="w-3 h-3"
|
||||
/>
|
||||
<span>{language === "id" ? "Ind" : "Eng"}</span>
|
||||
<span className="text-gray-500">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 32 32">
|
||||
<path fill="currentColor" d="M8.037 11.166L14.5 22.36c.825 1.43 2.175 1.43 3 0l6.463-11.195c.826-1.43.15-2.598-1.5-2.598H9.537c-1.65 0-2.326 1.17-1.5 2.6z" />
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="15"
|
||||
height="15"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M8.037 11.166L14.5 22.36c.825 1.43 2.175 1.43 3 0l6.463-11.195c.826-1.43.15-2.598-1.5-2.598H9.537c-1.65 0-2.326 1.17-1.5 2.6z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
|
|
@ -292,12 +646,30 @@ const Navbar = () => {
|
|||
{/* Dropdown Menu */}
|
||||
{isOpen && (
|
||||
<div className="absolute right-0 mt-2 w-auto bg-slate-200 border rounded-md shadow-lg z-10">
|
||||
<button onClick={() => handleLanguageChange("id")} className={`flex items-center space-x-2 w-full px-4 py-2 ${language === "id" ? "font-medium" : ""}`}>
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/9/9f/Flag_of_Indonesia.svg" alt="Indonesia" className="w-5 h-5" />
|
||||
<button
|
||||
onClick={() => handleLanguageChange("id")}
|
||||
className={`flex items-center space-x-2 w-full px-4 py-2 ${
|
||||
language === "id" ? "font-medium" : ""
|
||||
}`}
|
||||
>
|
||||
<img
|
||||
src="https://upload.wikimedia.org/wikipedia/commons/9/9f/Flag_of_Indonesia.svg"
|
||||
alt="Indonesia"
|
||||
className="w-5 h-5"
|
||||
/>
|
||||
<span>Ind</span>
|
||||
</button>
|
||||
<button onClick={() => handleLanguageChange("en")} className={`flex items-center space-x-2 w-full px-4 py-2 ${language === "en" ? "font-medium" : ""}`}>
|
||||
<img src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg" alt="English" className="w-5 h-5" />
|
||||
<button
|
||||
onClick={() => handleLanguageChange("en")}
|
||||
className={`flex items-center space-x-2 w-full px-4 py-2 ${
|
||||
language === "en" ? "font-medium" : ""
|
||||
}`}
|
||||
>
|
||||
<img
|
||||
src="https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg"
|
||||
alt="English"
|
||||
className="w-5 h-5"
|
||||
/>
|
||||
<span>Eng</span>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -306,13 +678,23 @@ const Navbar = () => {
|
|||
</div>
|
||||
|
||||
<div className=" py-1 flex items-center mx-3">
|
||||
<input type="text" placeholder="Pencarian" className="border rounded-full w-full text-sm text-center text-gray-600" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Pencarian"
|
||||
className="border rounded-full w-full text-sm text-center text-gray-600"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex justify-center items-center mx-3 gap-5">
|
||||
<Link href="/auth" className="w-full lg:w-fit px-4 py-1 bg-[#bb3523] text-white font-semibold rounded-md hover:bg-red-700 text-center">
|
||||
<Link
|
||||
href="/auth"
|
||||
className="w-full lg:w-fit px-4 py-1 bg-[#bb3523] text-white font-semibold rounded-md hover:bg-red-700 text-center"
|
||||
>
|
||||
Masuk
|
||||
</Link>
|
||||
<Link href="#" className="w-full lg:w-fit px-4 py-1 border border-[#bb3523] text-[#bb3523] font-semibold rounded-md hover:bg-[#bb3523] text-center hover:text-white">
|
||||
<Link
|
||||
href="#"
|
||||
className="w-full lg:w-fit px-4 py-1 border border-[#bb3523] text-[#bb3523] font-semibold rounded-md hover:bg-[#bb3523] text-center hover:text-white"
|
||||
>
|
||||
Daftar
|
||||
</Link>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"use client"
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import HeaderContent from "./header-content";
|
||||
|
|
@ -26,8 +26,8 @@ const DashCodeHeader = () => {
|
|||
<div className="nav-tools flex items-center md:gap-4 gap-3">
|
||||
<LocalSwitcher />
|
||||
<ThemeSwitcher />
|
||||
<Cart />
|
||||
<Messages />
|
||||
{/* <Cart />
|
||||
<Messages /> */}
|
||||
<Notifications />
|
||||
<ProfileInfo />
|
||||
<SheetMenu />
|
||||
|
|
|
|||
|
|
@ -1,90 +1,168 @@
|
|||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Link } from '@/i18n/routing';
|
||||
import { Link } from "@/i18n/routing";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { notifications, type Notification } from "./data";
|
||||
import shortImage from "@/public/images/all-img/short-image-2.png";
|
||||
import { Icon } from "@/components/ui/icon";
|
||||
import { useEffect, useState } from "react";
|
||||
import { getNotifications } from "@/service/notifications/notifications";
|
||||
import { format, formatDate } from "date-fns";
|
||||
import {
|
||||
CalendarCheck,
|
||||
CheckCheck,
|
||||
CircleAlert,
|
||||
Clock7,
|
||||
MessageCircle,
|
||||
SquareCheck,
|
||||
UploadIcon,
|
||||
} from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export type Notification = {
|
||||
id: number;
|
||||
notificationTypeId: number;
|
||||
message: string;
|
||||
createdAt: string;
|
||||
isActive: boolean;
|
||||
isPublic: boolean;
|
||||
isRead: boolean;
|
||||
redirectUrl: string;
|
||||
userGroupIdDst: string | null;
|
||||
userIdDst: string | null;
|
||||
userLevelIdDst: string;
|
||||
userLevelNumberDst: string | null;
|
||||
userRoleIdDst: string;
|
||||
};
|
||||
|
||||
const getNotificationIcon = (notificationTypeId: number) => {
|
||||
const router = useRouter();
|
||||
switch (notificationTypeId) {
|
||||
case 2:
|
||||
return <MessageCircle className="h-8 w-8 text-success" />;
|
||||
case 3:
|
||||
return <UploadIcon className="h-5 w-5 text-warning" />;
|
||||
case 4:
|
||||
return <CheckCheck className="h-5 w-5 text-primary" />;
|
||||
case 5:
|
||||
return <SquareCheck className="h-5 w-5 text-warning" />;
|
||||
case 6:
|
||||
return <CalendarCheck className="h-5 w-5 text-danger" />;
|
||||
case 7:
|
||||
return <CircleAlert className="h-5 w-5 text-danger" />;
|
||||
case 8:
|
||||
return <Clock7 className="h-5 w-5 text-danger" />;
|
||||
default:
|
||||
return <SquareCheck className="h-5 w-5 text-danger" />;
|
||||
}
|
||||
};
|
||||
|
||||
const Notifications = () => {
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button type="button" className="relative hidden focus:ring-none focus:outline-none md:h-8 md:w-8 md:bg-secondary text-secondary-foreground rounded-full md:flex flex-col items-center justify-center">
|
||||
<Icon icon="heroicons-outline:bell" className="animate-tada h-5 w-5" />
|
||||
<Badge className=" w-4 h-4 p-0 text-[8px] rounded-full font-semibold items-center justify-center absolute left-[calc(100%-12px)] bottom-[calc(100%-10px)]" color="destructive">
|
||||
2
|
||||
</Badge>
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent
|
||||
align="end"
|
||||
className=" z-[999] mx-4 lg:w-[320px] p-0"
|
||||
>
|
||||
<DropdownMenuLabel
|
||||
const router = useRouter();
|
||||
const [notifications, setNotifications] = useState<Notification[]>([]);
|
||||
const [notificationTotal, setNotificationTotal] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
async function initState() {
|
||||
const response = await getNotifications();
|
||||
setNotifications(response.data?.data?.content);
|
||||
setNotificationTotal(response.data?.data?.totalElements);
|
||||
console.log("notif", response.data?.data?.content);
|
||||
}
|
||||
initState();
|
||||
}, []);
|
||||
|
||||
>
|
||||
<div className="flex justify-between px-4 py-3 border-b border-default-100 ">
|
||||
<div className="text-sm text-default-800 font-medium ">
|
||||
Notifications
|
||||
</div>
|
||||
<div className="text-default-800 text-xs md:text-right">
|
||||
<Link href="/notifications" className="underline">
|
||||
View all
|
||||
</Link>
|
||||
</div>
|
||||
const formatDate = (dateString: string) => {
|
||||
const date = new Date(dateString);
|
||||
return format(date, "dd/MM/yyyy HH:mm");
|
||||
};
|
||||
|
||||
const handleNotificationClick = (redirectUrl: string) => {
|
||||
router.push(redirectUrl);
|
||||
};
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="relative hidden focus:ring-none focus:outline-none md:h-8 md:w-8 md:bg-secondary text-secondary-foreground rounded-full md:flex flex-col items-center justify-center"
|
||||
>
|
||||
<Icon
|
||||
icon="heroicons-outline:bell"
|
||||
className="animate-tada h-5 w-5"
|
||||
/>
|
||||
<Badge
|
||||
className=" w-4 h-4 p-0 text-[8px] rounded-full font-semibold items-center justify-center absolute left-[calc(100%-12px)] bottom-[calc(100%-10px)]"
|
||||
color="destructive"
|
||||
>
|
||||
{notificationTotal > 99 ? "99+" : notificationTotal}
|
||||
</Badge>
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent
|
||||
align="end"
|
||||
className=" z-[999] mx-4 lg:w-[320px] p-0"
|
||||
>
|
||||
<DropdownMenuLabel>
|
||||
<div className="flex justify-between px-4 py-3 border-b border-default-100 ">
|
||||
<div className="text-sm text-default-800 font-medium ">
|
||||
you have {notificationTotal > 99 ? "99+" : notificationTotal}{" "}
|
||||
notifications
|
||||
</div>
|
||||
<div className="text-default-800 text-xs md:text-right">
|
||||
<Link href="/notifications" className="underline">
|
||||
View all
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</DropdownMenuLabel>
|
||||
<div className="h-[300px] xl:h-[350px]">
|
||||
<ScrollArea className="h-full">
|
||||
{notifications.map((item: Notification, index: number) => (
|
||||
<DropdownMenuItem
|
||||
key={`inbox-${index}`}
|
||||
className="flex gap-9 py-2 px-4 cursor-pointer group "
|
||||
onClick={() => handleNotificationClick(item?.redirectUrl)}
|
||||
>
|
||||
<div className="flex items-start gap-2 flex-1 ">
|
||||
<div className="flex-none">
|
||||
{getNotificationIcon(item.notificationTypeId)}
|
||||
</div>
|
||||
<div className="flex-1 flex flex-col gap-0.5">
|
||||
<div className="text-sm text-default-600 dark:group-hover:text-default-800 font-normal truncate whitespace-normal ">
|
||||
{item?.message}
|
||||
</div>
|
||||
</DropdownMenuLabel>
|
||||
<div className="h-[300px] xl:h-[350px]">
|
||||
<ScrollArea className="h-full">
|
||||
{notifications.map((item: Notification, index: number) => (
|
||||
<DropdownMenuItem
|
||||
key={`inbox-${index}`}
|
||||
className="flex gap-9 py-2 px-4 cursor-pointer group "
|
||||
>
|
||||
<div className="flex items-start gap-2 flex-1">
|
||||
<div className="flex-none">
|
||||
<Avatar className="h-8 w-8 ">
|
||||
<AvatarImage src={item.avatar} />
|
||||
<AvatarFallback> {item.title.charAt(0)}</AvatarFallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
<div className="flex-1 flex flex-col gap-0.5">
|
||||
<div className="text-sm text-default-600 dark:group-hover:text-default-800 font-normal truncate">
|
||||
{item.title}
|
||||
</div>
|
||||
<div className="text-xs text-default-600 dark:group-hover:text-default-700 font-light line-clamp-1 ">
|
||||
{item.desc}
|
||||
</div>
|
||||
<div className=" text-default-400 dark:group-hover:text-default-500 text-xs"> {item.date}</div>
|
||||
</div>
|
||||
</div>
|
||||
{item.unreadmessage && (
|
||||
<div className="flex-0">
|
||||
<span className="h-[10px] w-[10px] bg-destructive border border-destructive-foreground dark:border-default-400 rounded-full inline-block" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</ScrollArea>
|
||||
{/* <div className="text-xs text-default-600 dark:group-hover:text-default-700 font-light line-clamp-1 ">
|
||||
{item?.desc}
|
||||
</div> */}
|
||||
<div className=" text-default-400 dark:group-hover:text-default-500 text-xs">
|
||||
{" "}
|
||||
{formatDate(item?.createdAt)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
{/* {item?.unreadmessage && (
|
||||
<div className="flex-0">
|
||||
<span className="h-[10px] w-[10px] bg-destructive border border-destructive-foreground dark:border-default-400 rounded-full inline-block" />
|
||||
</div>
|
||||
)} */}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</ScrollArea>
|
||||
</div>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
};
|
||||
|
||||
export default Notifications;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import { Link } from "@/i18n/routing";
|
|||
import React from "react";
|
||||
|
||||
const ProfileInfo = () => {
|
||||
|
||||
return (
|
||||
<div className="md:block hidden">
|
||||
<DropdownMenu>
|
||||
|
|
@ -30,9 +29,11 @@ const ProfileInfo = () => {
|
|||
height={36}
|
||||
className="rounded-full"
|
||||
/>
|
||||
|
||||
<div className="text-sm font-medium capitalize lg:block hidden ">
|
||||
UserName
|
||||
<div>
|
||||
<div className="text-sm font-medium capitalize lg:block hidden ">
|
||||
Mabes Polri - Approver
|
||||
</div>
|
||||
<p className="text-xs">(MABES POLRI)</p>
|
||||
</div>
|
||||
<span className="text-base me-2.5 lg:inline-block hidden">
|
||||
<Icon icon="heroicons-outline:chevron-down"></Icon>
|
||||
|
|
@ -40,7 +41,7 @@ const ProfileInfo = () => {
|
|||
</div>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56 p-0" align="end">
|
||||
<DropdownMenuLabel className="flex gap-2 items-center mb-1 p-3">
|
||||
{/* <DropdownMenuLabel className="flex gap-2 items-center mb-1 p-3">
|
||||
<Image
|
||||
src={"https://netidhub.com/assets/img/user-avatar.png"}
|
||||
alt={"Image"}
|
||||
|
|
@ -60,29 +61,29 @@ const ProfileInfo = () => {
|
|||
Email
|
||||
</Link>
|
||||
</div>
|
||||
</DropdownMenuLabel>
|
||||
</DropdownMenuLabel> */}
|
||||
<DropdownMenuGroup>
|
||||
{[
|
||||
{
|
||||
name: "profile",
|
||||
name: "profile & Settings",
|
||||
icon: "heroicons:user",
|
||||
href: "/user-profile",
|
||||
},
|
||||
{
|
||||
name: "Billing",
|
||||
icon: "heroicons:megaphone",
|
||||
href: "/dashboard",
|
||||
},
|
||||
{
|
||||
name: "Settings",
|
||||
icon: "heroicons:paper-airplane",
|
||||
href: "/dashboard",
|
||||
},
|
||||
{
|
||||
name: "Keyboard shortcuts",
|
||||
icon: "heroicons:language",
|
||||
href: "/dashboard",
|
||||
href: "/profile",
|
||||
},
|
||||
// {
|
||||
// name: "Billing",
|
||||
// icon: "heroicons:megaphone",
|
||||
// href: "/dashboard",
|
||||
// },
|
||||
// {
|
||||
// name: "Settings",
|
||||
// icon: "heroicons:paper-airplane",
|
||||
// href: "/dashboard",
|
||||
// },
|
||||
// {
|
||||
// name: "Keyboard shortcuts",
|
||||
// icon: "heroicons:language",
|
||||
// href: "/dashboard",
|
||||
// },
|
||||
].map((item, index) => (
|
||||
<Link
|
||||
href={item.href}
|
||||
|
|
@ -98,7 +99,7 @@ const ProfileInfo = () => {
|
|||
</DropdownMenuGroup>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuGroup>
|
||||
<Link href="/dashboard" className="cursor-pointer">
|
||||
{/* <Link href="/dashboard" className="cursor-pointer">
|
||||
<DropdownMenuItem className="flex items-center gap-2 text-sm font-medium text-default-600 capitalize px-3 py-1.5 cursor-pointer">
|
||||
<Icon icon="heroicons:user-group" className="w-4 h-4" />
|
||||
team
|
||||
|
|
@ -168,17 +169,11 @@ const ProfileInfo = () => {
|
|||
))}
|
||||
</DropdownMenuSubContent>
|
||||
</DropdownMenuPortal>
|
||||
</DropdownMenuSub>
|
||||
</DropdownMenuSub> */}
|
||||
</DropdownMenuGroup>
|
||||
<DropdownMenuSeparator className="mb-0 dark:bg-background" />
|
||||
<DropdownMenuItem className="flex items-center gap-2 text-sm font-medium text-default-600 capitalize my-1 px-3 cursor-pointer">
|
||||
<div>
|
||||
<form
|
||||
// action={async () => {
|
||||
// "use server";
|
||||
// await signOut();
|
||||
// }}
|
||||
>
|
||||
<Link href={"/auth"}>
|
||||
<button
|
||||
type="submit"
|
||||
className=" w-full flex items-center gap-2"
|
||||
|
|
@ -186,7 +181,7 @@ const ProfileInfo = () => {
|
|||
<Icon icon="heroicons:power" className="w-4 h-4" />
|
||||
Log out
|
||||
</button>
|
||||
</form>
|
||||
</Link>
|
||||
</div>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
import { getAPI, postAPI, postAPIWithJson } from "../config/api";
|
||||
import {
|
||||
getAPI,
|
||||
getAPIInterceptor,
|
||||
postAPI,
|
||||
postAPIInterceptor,
|
||||
postAPIWithJson,
|
||||
} from "../config/api";
|
||||
import { getAPIDummy } from "./http-config/axiosCustom";
|
||||
|
||||
import {
|
||||
|
|
@ -16,13 +22,20 @@ export async function getProfile(token: any) {
|
|||
return getAPI(url, token);
|
||||
}
|
||||
|
||||
// export async function setLogin(data: any) {
|
||||
// const pathUrl = `signin`;
|
||||
// const headers = {
|
||||
// "content-type": "application/json",
|
||||
// };
|
||||
// return await httpPost(pathUrl, headers, data);
|
||||
// }
|
||||
export async function getInfoProfile() {
|
||||
const url = "users/info";
|
||||
return getAPIInterceptor(url);
|
||||
}
|
||||
|
||||
export async function setupPassword(data: any) {
|
||||
const url = "setup-password";
|
||||
return postAPIInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function saveUser(data: any) {
|
||||
const url = "users/save";
|
||||
return postAPIInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function userInfo(token: any) {
|
||||
const pathUrl = `users/info`;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
import { getAPIInterceptor } from "@/config/api";
|
||||
|
||||
export async function getNotifications(page = 0, pageSize = 10) {
|
||||
const url = `notification/list?enablePage=1&page=${page}&pageSize=${pageSize}`;
|
||||
return getAPIInterceptor(url);
|
||||
}
|
||||
Loading…
Reference in New Issue