diff --git a/app/[locale]/(protected)/admin/add-experts/update/[id]/page.tsx b/app/[locale]/(protected)/admin/add-experts/update/[id]/page.tsx index fccef1de..eb27b0e5 100644 --- a/app/[locale]/(protected)/admin/add-experts/update/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/add-experts/update/[id]/page.tsx @@ -37,32 +37,43 @@ import { Eye, EyeOff } from "lucide-react"; import { useParams } from "next/navigation"; const FormSchema = z.object({ - name: z.string({ - required_error: "Required", - }), - username: z.string({ - required_error: "Required", - }), - password: z.string({ - required_error: "Required", - }), - phoneNumber: z.string({ - required_error: "Required", - }), - email: z.string({ - required_error: "Required", - }), - skills: z.string({ - required_error: "Required", - }), - experiences: z.string({ - required_error: "Required", - }), - company: z.string({ - required_error: "Required", - }), + name: z.string().optional(), + username: z.string().optional(), + password: z.string().optional(), + phoneNumber: z.string().optional(), + email: z.string().optional(), + skills: z.string().optional(), + experiences: z.string().optional(), + company: z.string().optional(), }); +// const FormSchema = z.object({ +// name: z.string({ +// required_error: "Required", +// }), +// username: z.string({ +// required_error: "Required", +// }), +// password: z.string({ +// required_error: "Required", +// }), +// phoneNumber: z.string({ +// required_error: "Required", +// }), +// email: z.string({ +// required_error: "Required", +// }), +// skills: z.string({ +// required_error: "Required", +// }), +// experiences: z.string({ +// required_error: "Required", +// }), +// company: z.string({ +// required_error: "Required", +// }), +// }); + export type Placements = { index: number; roleId?: string; @@ -189,18 +200,35 @@ export default function UpdateExpertForm() { const dataReq = { id: detail?.id, - firstName: data.name, - username: data.username, - email: data.email, - password: data.password, + firstName: data.name || detail.fullname, + username: data.username || detail.username, + email: data.email || detail.email, + password: data.password || undefined, address: "", roleId: "EXP-ID", - phoneNumber: data.phoneNumber, - userCompetencyId: data.skills, - userExperienceId: data.experiences, - companyName: data.company, + phoneNumber: data.phoneNumber || detail.phoneNumber, + userCompetencyId: + data.skills || detail.userProfilesAdditional?.userCompetency?.id, + userExperienceId: + data.experiences || detail.userProfilesAdditional?.userExperienceId, + companyName: data.company || detail.userProfilesAdditional?.companyName, + isAdmin: true, }; + // const dataReq = { + // id: detail?.id, + // firstName: data.name, + // username: data.username, + // email: data.email, + // password: data.password, + // address: "", + // roleId: "EXP-ID", + // phoneNumber: data.phoneNumber, + // userCompetencyId: data.skills, + // userExperienceId: data.experiences, + // companyName: data.company, + // }; + loading(); const res = await saveUserInternal(dataReq); const resData = res?.data?.data; @@ -322,10 +350,15 @@ export default function UpdateExpertForm() { render={({ field }) => ( Nama Lengkap - */} + @@ -338,13 +371,18 @@ export default function UpdateExpertForm() { render={({ field }) => ( Username - */} + - )} @@ -355,11 +393,17 @@ export default function UpdateExpertForm() { render={({ field }) => ( No. HP - */} + @@ -371,17 +415,46 @@ export default function UpdateExpertForm() { render={({ field }) => ( Email - */} + )} /> ( + + Password (Opsional) +
+ + +
+
+ )} + /> + {/* ( @@ -406,7 +479,7 @@ export default function UpdateExpertForm() {
)} - /> + /> */} ( Nama Institusi/Perusahaan - */} + + )} diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx index 481a61d3..10e06d93 100644 --- a/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx @@ -152,12 +152,12 @@ const CampaignListTable = () => {

Daftar Campaign

- + {/* - + */} - {Array.from({ length: categoryTotalPages }, (_, i) => ( - - ))} + {(() => { + const maxVisible = 4; + let startPage = Math.max( + 1, + Math.min( + categoryPage - Math.floor(maxVisible / 2), + categoryTotalPages - maxVisible + 1 + ) + ); + const endPage = Math.min( + categoryTotalPages, + startPage + maxVisible - 1 + ); + const visiblePages = []; + for (let i = startPage; i <= endPage; i++) { + visiblePages.push(i); + } + + return visiblePages.map((pageNum) => ( + + )); + })()} + + {/* Tombol Next */}
) )} diff --git a/components/landing-page/navbar.tsx b/components/landing-page/navbar.tsx index 28998ddd..741f68ab 100644 --- a/components/landing-page/navbar.tsx +++ b/components/landing-page/navbar.tsx @@ -99,7 +99,7 @@ const Navbar = () => { ? `/polda/${poldaName}` : satkerName ? `/satker/${satkerName}` - : "/"; + : ""; let menu = ""; diff --git a/lib/menus.ts b/lib/menus.ts index 47edd011..870ff19c 100644 --- a/lib/menus.ts +++ b/lib/menus.ts @@ -100,6 +100,13 @@ export function getMenuList(pathname: string, t: any): Group[] { }, ...(!hideForRole14 ? [ + // { + // href: "/contributor/content/satker", + // label: "satker", + // active: pathname.includes("/content/satker"), + // icon: "heroicons:credit-card", + // children: [], + // }, { href: "/contributor/content/spit", label: "spit", @@ -4321,13 +4328,13 @@ export function getMenuList(pathname: string, t: any): Group[] { icon: "heroicons:arrow-trending-up", children: [], }, - { - href: "/admin/settings/banner", - label: "Banner", - active: pathname === "/admin/settings/banner", - icon: "heroicons:arrow-trending-up", - children: [], - }, + // { + // href: "/admin/settings/banner", + // label: "Banner", + // active: pathname === "/admin/settings/banner", + // icon: "heroicons:arrow-trending-up", + // children: [], + // }, // { // href: "/admin/settings/feedback", // label: "Feedback", diff --git a/middleware.ts b/middleware.ts index f8a2d2b1..d186fa40 100644 --- a/middleware.ts +++ b/middleware.ts @@ -1,29 +1,73 @@ import createMiddleware from "next-intl/middleware"; import { NextRequest, NextResponse } from "next/server"; -import { locales } from "@/config"; import { routing } from "./i18n/routing"; -// export default async function middleware(request: NextRequest) { -// // Step 1: Use the incoming request (example) -// const defaultLocale = "in"; -// // const defaultLocale = request.headers.get("dashcode-locale") || "in"; +const intlMiddleware = createMiddleware(routing); -// // Step 2: Create and call the next-intl middleware (example) -// const handleI18nRouting = createMiddleware({ -// locales: ["in", "en"], -// defaultLocale: "in", -// }); -// const response = handleI18nRouting(request); +export default function middleware(request: NextRequest) { + const { pathname } = request.nextUrl; -// // Step 3: Alter the response (example) -// response.headers.set("dashcode-locale", defaultLocale); + // --- IGNORE STATIC ASSET --- + const isStaticAsset = + pathname.startsWith("/api") || + pathname.startsWith("/_next") || + pathname.startsWith("/favicon") || + pathname.startsWith("/assets") || + pathname.startsWith("/static") || + pathname.match(/\.(png|jpg|jpeg|gif|webp|svg|ico|css|js)$/); -// return response; -// } + if (isStaticAsset) return NextResponse.next(); -export default createMiddleware(routing); + // --- LOCALES YANG VALID --- + const locales = ["in", "en"]; + // Ambil locale utama dari URL + const firstSegment = pathname.split("/")[1]; + + const isLocaleURL = locales.includes(firstSegment); + + // Jika URL sudah mengandung locale → JALANKAN next-intl + if (isLocaleURL) { + return intlMiddleware(request); + } + + // Jika URL TIDAK ada locale → redirect ke /in/ + const url = request.nextUrl.clone(); + url.pathname = `/in${pathname}`; + return NextResponse.redirect(url); +} + +// Matcher untuk semua route kecuali static files export const config = { - // Match only internationalized pathnames - matcher: ["/", "/(in|en)/:path*"], + matcher: ["/((?!_next|api|favicon.ico|assets|static).*)"], }; + +// import createMiddleware from "next-intl/middleware"; +// import { NextRequest, NextResponse } from "next/server"; +// import { locales } from "@/config"; +// import { routing } from "./i18n/routing"; + +// // export default async function middleware(request: NextRequest) { +// // // Step 1: Use the incoming request (example) +// // const defaultLocale = "in"; +// // // const defaultLocale = request.headers.get("dashcode-locale") || "in"; + +// // // Step 2: Create and call the next-intl middleware (example) +// // const handleI18nRouting = createMiddleware({ +// // locales: ["in", "en"], +// // defaultLocale: "in", +// // }); +// // const response = handleI18nRouting(request); + +// // // Step 3: Alter the response (example) +// // response.headers.set("dashcode-locale", defaultLocale); + +// // return response; +// // } + +// export default createMiddleware(routing); + +// export const config = { +// // Match only internationalized pathnames +// matcher: ["/", "/(in|en)/:path*"], +// }; diff --git a/service/content/content.ts b/service/content/content.ts index 144748b5..67b33052 100644 --- a/service/content/content.ts +++ b/service/content/content.ts @@ -46,6 +46,39 @@ export async function listDataAll( ); } +export async function listDataSatker( + isForSelf: any, + isApproval: any, + page: any, + limit: any, + search: any, + typeId: any, + statusFilter: any, + needApprovalFromLevel: any, + creator: any, + source: any, + startDate: any, + endDate: any, + title: string = "" +) { + return await httpGetInterceptor( + `media/list?enablePage=1&sortBy=createdAt&sort=desc&isAllSatker=true` + + `&size=${limit}` + + `&page=${page}` + + `&isForSelf=${isForSelf}` + + `&isApproval=${isApproval}` + + `&typeId=${typeId || ""}` + + `&statusId=${statusFilter || ""}` + + `&needApprovalFromLevel=${needApprovalFromLevel || ""}` + + `&creator=${encodeURIComponent(creator || "")}` + + `&source=${encodeURIComponent(source || "")}` + + `&startDate=${startDate || ""}` + + `&endDate=${endDate || ""}` + + `&title=${encodeURIComponent(title || search || "")}` + ); +} + + export async function listDataImage( size: any = "", page: any = "",