pull main
This commit is contained in:
commit
2e75d679b3
|
|
@ -12,14 +12,26 @@ import EventCalender from "./event-calender";
|
||||||
import UserSurveyBox from "./survey-box";
|
import UserSurveyBox from "./survey-box";
|
||||||
import ScrollableContentPolda from "./scrollable-content-polda";
|
import ScrollableContentPolda from "./scrollable-content-polda";
|
||||||
import AdvertisementPlacements from "./advertisement-placements";
|
import AdvertisementPlacements from "./advertisement-placements";
|
||||||
|
import { useTheme } from "next-themes";
|
||||||
|
|
||||||
const SearchSectionPolda = () => {
|
const SearchSectionPolda = () => {
|
||||||
const [contentType, setContentType] = useState("all");
|
const [contentType, setContentType] = useState("all");
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations("LandingPage");
|
const t = useTranslations("LandingPage");
|
||||||
|
const { theme } = useTheme();
|
||||||
|
|
||||||
|
// Determine background image based on theme
|
||||||
|
const getBackgroundImage = () => {
|
||||||
|
if (theme === "dark") {
|
||||||
|
return "url('/assets/background-dark.jpg')";
|
||||||
|
} else {
|
||||||
|
return "url('/assets/background-white.jpg')";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex w-full min-h-screen bg-center bg-cover bg-no-repeat" style={{ backgroundImage: "url('/assets/background.png')" }}>
|
<div className="flex w-full min-h-screen bg-center bg-cover bg-no-repeat" style={{ backgroundImage: getBackgroundImage() }}>
|
||||||
<div className="hidden xl:block w-[15%] pr-4 py-5 sticky top-[150px] space-y-4 self-start">
|
<div className="hidden xl:block w-[15%] pr-4 py-5 sticky top-[150px] space-y-4 self-start">
|
||||||
<AdvertisementPlacements placement="left"/>
|
<AdvertisementPlacements placement="left"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,27 @@ import UserSurveyBox from "./survey-box";
|
||||||
import ScrollableContentPolda from "./scrollable-content-polda";
|
import ScrollableContentPolda from "./scrollable-content-polda";
|
||||||
import ScrollableContentSatker from "./scrollable-content-satker";
|
import ScrollableContentSatker from "./scrollable-content-satker";
|
||||||
import AdvertisementPlacements from "./advertisement-placements";
|
import AdvertisementPlacements from "./advertisement-placements";
|
||||||
|
import { useTheme } from "next-themes";
|
||||||
|
|
||||||
const SearchSectionSatker = () => {
|
const SearchSectionSatker = () => {
|
||||||
const [contentType, setContentType] = useState("all");
|
const [contentType, setContentType] = useState("all");
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations("LandingPage");
|
const t = useTranslations("LandingPage");
|
||||||
|
|
||||||
|
const { theme } = useTheme();
|
||||||
|
|
||||||
|
// Determine background image based on theme
|
||||||
|
const getBackgroundImage = () => {
|
||||||
|
if (theme === "dark") {
|
||||||
|
return "url('/assets/background-dark.jpg')";
|
||||||
|
} else {
|
||||||
|
return "url('/assets/background-white.jpg')";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex w-full min-h-screen bg-center bg-cover bg-no-repeat" style={{ backgroundImage: "url('/assets/background.png')" }}>
|
<div className="flex w-full min-h-screen bg-center bg-cover bg-no-repeat" style={{ backgroundImage: getBackgroundImage() }}>
|
||||||
<div className="hidden xl:block w-[15%] pr-4 py-5 sticky top-[150px] space-y-4 self-start">
|
<div className="hidden xl:block w-[15%] pr-4 py-5 sticky top-[150px] space-y-4 self-start">
|
||||||
<AdvertisementPlacements placement="left"/>
|
<AdvertisementPlacements placement="left"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import { useTranslations } from "next-intl";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import router from "next/router";
|
import router from "next/router";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
import { useTheme } from "next-themes";
|
||||||
import ScrollableContent from "./search-section-new";
|
import ScrollableContent from "./search-section-new";
|
||||||
import NewContent from "./new-content";
|
import NewContent from "./new-content";
|
||||||
import ContentCategory from "./content-category";
|
import ContentCategory from "./content-category";
|
||||||
|
|
@ -24,10 +25,21 @@ const SearchSection = () => {
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations("LandingPage");
|
const t = useTranslations("LandingPage");
|
||||||
|
const { theme } = useTheme();
|
||||||
|
|
||||||
|
// Determine background image based on theme
|
||||||
|
const getBackgroundImage = () => {
|
||||||
|
if (theme === "dark") {
|
||||||
|
return "url('/assets/background-dark.jpg')";
|
||||||
|
} else {
|
||||||
|
return "url('/assets/background-white.jpg')";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="flex w-full min-h-screen bg-center bg-cover bg-no-repeat"
|
className="flex w-full min-h-screen bg-center bg-cover bg-no-repeat"
|
||||||
style={{ backgroundImage: "url('/assets/background.png')" }}
|
style={{ backgroundImage: getBackgroundImage() }}
|
||||||
>
|
>
|
||||||
<div className="hidden xl:block w-[15%] pr-4 py-5 sticky top-[130px] space-y-4 self-start">
|
<div className="hidden xl:block w-[15%] pr-4 py-5 sticky top-[130px] space-y-4 self-start">
|
||||||
<AdvertisementPlacements placement="left"/>
|
<AdvertisementPlacements placement="left"/>
|
||||||
|
|
|
||||||
|
|
@ -148,118 +148,104 @@ const LoginForm = () => {
|
||||||
const profile = await getProfile(access_token);
|
const profile = await getProfile(access_token);
|
||||||
console.log("PROFILE : ", profile?.data?.data);
|
console.log("PROFILE : ", profile?.data?.data);
|
||||||
|
|
||||||
|
Cookies.set("home_path", profile?.data?.data?.homePath, {
|
||||||
|
expires: 1,
|
||||||
|
});
|
||||||
|
Cookies.set(
|
||||||
|
"profile_picture",
|
||||||
|
profile?.data?.data?.profilePictureUrl,
|
||||||
|
{
|
||||||
|
expires: 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
Cookies.set("state", profile?.data?.data?.userLevel?.name, {
|
||||||
|
expires: 1,
|
||||||
|
});
|
||||||
|
Cookies.set(
|
||||||
|
"state-prov",
|
||||||
|
profile.data?.data?.userLevel?.province?.provName,
|
||||||
|
{
|
||||||
|
expires: 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setCookiesEncrypt("uie", profile?.data?.data?.id, {
|
||||||
|
expires: 1,
|
||||||
|
});
|
||||||
|
setCookiesEncrypt("urie", profile?.data?.data?.roleId, {
|
||||||
|
expires: 1,
|
||||||
|
});
|
||||||
|
setCookiesEncrypt("urne", profile?.data?.data?.role?.name, {
|
||||||
|
expires: 1,
|
||||||
|
});
|
||||||
|
setCookiesEncrypt("ulie", profile?.data?.data?.userLevel?.id, {
|
||||||
|
expires: 1,
|
||||||
|
});
|
||||||
|
setCookiesEncrypt(
|
||||||
|
"uplie",
|
||||||
|
profile?.data?.data?.userLevel?.parentLevelId,
|
||||||
|
{
|
||||||
|
expires: 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setCookiesEncrypt(
|
||||||
|
"ulne",
|
||||||
|
profile?.data?.data?.userLevel?.levelNumber,
|
||||||
|
{
|
||||||
|
expires: 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setCookiesEncrypt("ufne", profile?.data?.data?.fullname, {
|
||||||
|
expires: 1,
|
||||||
|
});
|
||||||
|
setCookiesEncrypt("ulnae", profile?.data?.data?.userLevel?.name, {
|
||||||
|
expires: 1,
|
||||||
|
});
|
||||||
|
setCookiesEncrypt("uinse", profile?.data?.data?.instituteId, {
|
||||||
|
expires: 1,
|
||||||
|
});
|
||||||
|
console.log("ssaddd", profile?.data?.data?.roleId);
|
||||||
if (
|
if (
|
||||||
profile?.data?.data?.isInternational == true ||
|
Number(profile?.data?.data?.roleId) == 2 ||
|
||||||
profile?.data?.data?.isActive == false ||
|
Number(profile?.data?.data?.roleId) == 3 ||
|
||||||
profile?.data?.data?.isDelete == true
|
Number(profile?.data?.data?.roleId) == 4 ||
|
||||||
|
Number(profile?.data?.data?.roleId) == 9 ||
|
||||||
|
Number(profile?.data?.data?.roleId) == 10 ||
|
||||||
|
Number(profile?.data?.data?.roleId) == 11 ||
|
||||||
|
Number(profile?.data?.data?.roleId) == 12 ||
|
||||||
|
Number(profile?.data?.data?.roleId) == 18 ||
|
||||||
|
Number(profile?.data?.data?.roleId) == 19
|
||||||
) {
|
) {
|
||||||
Object.keys(Cookies.get()).forEach((cookieName) => {
|
if (profile?.data?.data?.roleId === 18) {
|
||||||
Cookies.remove(cookieName);
|
window.location.href = "/in/dashboard/executive-data";
|
||||||
});
|
// router.push('/admin/dashboard');
|
||||||
warning(
|
Cookies.set("status", "login", {
|
||||||
"Akun Anda tidak dapat digunakan untuk masuk ke MediaHub Polri",
|
|
||||||
"/auth/login"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Cookies.set("home_path", profile?.data?.data?.homePath, {
|
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
Cookies.set(
|
|
||||||
"profile_picture",
|
|
||||||
profile?.data?.data?.profilePictureUrl,
|
|
||||||
{
|
|
||||||
expires: 1,
|
expires: 1,
|
||||||
}
|
});
|
||||||
);
|
} else if (profile?.data?.data?.roleId === 2) {
|
||||||
Cookies.set("state", profile?.data?.data?.userLevel?.name, {
|
window.location.href = "/in/dashboard/executive";
|
||||||
expires: 1,
|
Cookies.set("status", "login", {
|
||||||
});
|
|
||||||
Cookies.set(
|
|
||||||
"state-prov",
|
|
||||||
profile.data?.data?.userLevel?.province?.provName,
|
|
||||||
{
|
|
||||||
expires: 1,
|
expires: 1,
|
||||||
}
|
});
|
||||||
);
|
} else if (
|
||||||
setCookiesEncrypt("uie", profile?.data?.data?.id, {
|
profile?.data?.data?.userLevel?.id == 794 ||
|
||||||
expires: 1,
|
profile?.data?.data?.userLevel?.parentLevelId == 761
|
||||||
});
|
|
||||||
setCookiesEncrypt("urie", profile?.data?.data?.roleId, {
|
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
setCookiesEncrypt("urne", profile?.data?.data?.role?.name, {
|
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
setCookiesEncrypt("ulie", profile?.data?.data?.userLevel?.id, {
|
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
setCookiesEncrypt(
|
|
||||||
"uplie",
|
|
||||||
profile?.data?.data?.userLevel?.parentLevelId,
|
|
||||||
{
|
|
||||||
expires: 1,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
setCookiesEncrypt(
|
|
||||||
"ulne",
|
|
||||||
profile?.data?.data?.userLevel?.levelNumber,
|
|
||||||
{
|
|
||||||
expires: 1,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
setCookiesEncrypt("ufne", profile?.data?.data?.fullname, {
|
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
setCookiesEncrypt("ulnae", profile?.data?.data?.userLevel?.name, {
|
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
setCookiesEncrypt("uinse", profile?.data?.data?.instituteId, {
|
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
console.log("ssaddd", profile?.data?.data?.roleId);
|
|
||||||
if (
|
|
||||||
Number(profile?.data?.data?.roleId) == 2 ||
|
|
||||||
Number(profile?.data?.data?.roleId) == 3 ||
|
|
||||||
Number(profile?.data?.data?.roleId) == 4 ||
|
|
||||||
Number(profile?.data?.data?.roleId) == 9 ||
|
|
||||||
Number(profile?.data?.data?.roleId) == 10 ||
|
|
||||||
Number(profile?.data?.data?.roleId) == 11 ||
|
|
||||||
Number(profile?.data?.data?.roleId) == 12 ||
|
|
||||||
Number(profile?.data?.data?.roleId) == 18 ||
|
|
||||||
Number(profile?.data?.data?.roleId) == 19
|
|
||||||
) {
|
) {
|
||||||
if (profile?.data?.data?.roleId === 18) {
|
window.location.href = "/in/dashboard";
|
||||||
window.location.href = "/in/dashboard/executive-data";
|
Cookies.set("status", "login", {
|
||||||
// router.push('/admin/dashboard');
|
expires: 1,
|
||||||
Cookies.set("status", "login", {
|
});
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
} else if (profile?.data?.data?.roleId === 2) {
|
|
||||||
window.location.href = "/in/dashboard/executive";
|
|
||||||
Cookies.set("status", "login", {
|
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
} else if (
|
|
||||||
profile?.data?.data?.userLevel?.id == 794 ||
|
|
||||||
profile?.data?.data?.userLevel?.parentLevelId == 761
|
|
||||||
) {
|
|
||||||
window.location.href = "/in/dashboard";
|
|
||||||
Cookies.set("status", "login", {
|
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
window.location.href = "/in/dashboard";
|
|
||||||
// router.push('/admin/dashboard');
|
|
||||||
Cookies.set("status", "login", {
|
|
||||||
expires: 1,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
window.location.href = "/";
|
window.location.href = "/in/dashboard";
|
||||||
|
// router.push('/admin/dashboard');
|
||||||
Cookies.set("status", "login", {
|
Cookies.set("status", "login", {
|
||||||
expires: 1,
|
expires: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
window.location.href = "/";
|
||||||
|
Cookies.set("status", "login", {
|
||||||
|
expires: 1,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
|
|
||||||
|
|
@ -105,14 +105,14 @@ export const useAuth = (): AuthContextType => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate user eligibility
|
// Validate user eligibility
|
||||||
if (!isUserEligible(profile)) {
|
// if (!isUserEligible(profile)) {
|
||||||
clearAllCookies();
|
// clearAllCookies();
|
||||||
warning(
|
// warning(
|
||||||
"Akun Anda tidak dapat digunakan untuk masuk ke MediaHub Polri",
|
// "Akun Anda tidak dapat digunakan untuk masuk ke MediaHub Polri",
|
||||||
"/auth"
|
// "/auth"
|
||||||
);
|
// );
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Set profile cookies
|
// Set profile cookies
|
||||||
setProfileCookies(profile);
|
setProfileCookies(profile);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import { getCookiesDecrypt, setCookiesEncrypt } from "@/lib/utils";
|
||||||
|
|
||||||
// Navigation configuration based on user roles
|
// Navigation configuration based on user roles
|
||||||
export const NAVIGATION_CONFIG: NavigationConfig[] = [
|
export const NAVIGATION_CONFIG: NavigationConfig[] = [
|
||||||
{ roleId: 18, path: "/in/dashboard/executive-data", label: "Executive Data Dashboard" },
|
|
||||||
{ roleId: 2, path: "/in/dashboard/executive", label: "Executive Dashboard" },
|
{ roleId: 2, path: "/in/dashboard/executive", label: "Executive Dashboard" },
|
||||||
{ roleId: 3, path: "/in/dashboard", label: "Dashboard" },
|
{ roleId: 3, path: "/in/dashboard", label: "Dashboard" },
|
||||||
{ roleId: 4, path: "/in/dashboard", label: "Dashboard" },
|
{ roleId: 4, path: "/in/dashboard", label: "Dashboard" },
|
||||||
|
|
@ -18,6 +17,10 @@ export const NAVIGATION_CONFIG: NavigationConfig[] = [
|
||||||
{ roleId: 10, path: "/in/dashboard", label: "Dashboard" },
|
{ roleId: 10, path: "/in/dashboard", label: "Dashboard" },
|
||||||
{ roleId: 11, path: "/in/dashboard", label: "Dashboard" },
|
{ roleId: 11, path: "/in/dashboard", label: "Dashboard" },
|
||||||
{ roleId: 12, path: "/in/dashboard", label: "Dashboard" },
|
{ roleId: 12, path: "/in/dashboard", label: "Dashboard" },
|
||||||
|
{ roleId: 13, path: "/in/dashboard", label: "Dashboard" },
|
||||||
|
{ roleId: 14, path: "/in/dashboard", label: "Dashboard" },
|
||||||
|
{ roleId: 15, path: "/in/dashboard", label: "Dashboard" },
|
||||||
|
{ roleId: 18, path: "/in/dashboard/executive-data", label: "Executive Data Dashboard" },
|
||||||
{ roleId: 19, path: "/in/dashboard", label: "Dashboard" },
|
{ roleId: 19, path: "/in/dashboard", label: "Dashboard" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -102,6 +105,8 @@ export const isSpecialLevel = (userLevelId: number, parentLevelId?: number): boo
|
||||||
export const getNavigationPath = (roleId: number, userLevelId?: number, parentLevelId?: number): string => {
|
export const getNavigationPath = (roleId: number, userLevelId?: number, parentLevelId?: number): string => {
|
||||||
const config = NAVIGATION_CONFIG.find(nav => nav.roleId === roleId);
|
const config = NAVIGATION_CONFIG.find(nav => nav.roleId === roleId);
|
||||||
|
|
||||||
|
console.log("Navigation Config : ", config);
|
||||||
|
|
||||||
if (config) {
|
if (config) {
|
||||||
// Special handling for role 2 with specific level conditions
|
// Special handling for role 2 with specific level conditions
|
||||||
if (roleId === 2 && userLevelId && parentLevelId && isSpecialLevel(userLevelId, parentLevelId)) {
|
if (roleId === 2 && userLevelId && parentLevelId && isSpecialLevel(userLevelId, parentLevelId)) {
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 456 KiB |
Loading…
Reference in New Issue