diff --git a/app/[locale]/(protected)/admin/media-tracking/component/column.tsx b/app/[locale]/(protected)/admin/media-tracking/component/column.tsx index 449e8ebb..7516c172 100644 --- a/app/[locale]/(protected)/admin/media-tracking/component/column.tsx +++ b/app/[locale]/(protected)/admin/media-tracking/component/column.tsx @@ -48,6 +48,11 @@ const columns: ColumnDef[] = [ ), }, + { + accessorKey: "title", + header: "Judul Berita", + cell: ({ row }) => {row.getValue("title")}, + }, { accessorKey: "pageUrl", header: "Link Berita", diff --git a/app/[locale]/(protected)/admin/media-tracking/component/modal.tsx b/app/[locale]/(protected)/admin/media-tracking/component/modal.tsx index 9f1c53e8..ed3043f7 100644 --- a/app/[locale]/(protected)/admin/media-tracking/component/modal.tsx +++ b/app/[locale]/(protected)/admin/media-tracking/component/modal.tsx @@ -104,13 +104,15 @@ export default function TrackingMediaModal(props: { value={inputValue} onChange={handleInputChange} />{" "} -
+
{content.length > 0 && content.map((item: any) => ( { setSelectedId(item.id); diff --git a/components/landing-page/hero.tsx b/components/landing-page/hero.tsx index 93a4cffd..aa4f8ce5 100644 --- a/components/landing-page/hero.tsx +++ b/components/landing-page/hero.tsx @@ -345,7 +345,7 @@ const Hero = (props: { group?: string }) => { /> )} - {showFormModal && } + {/* {showFormModal && } */}
{isLoading ? (
diff --git a/components/partials/header/locale-switcher.tsx b/components/partials/header/locale-switcher.tsx index fcb2582b..19d0d119 100644 --- a/components/partials/header/locale-switcher.tsx +++ b/components/partials/header/locale-switcher.tsx @@ -5,7 +5,7 @@ import { useParams } from "next/navigation"; import { locales } from "@/config"; import { usePathname, useRouter } from "@/i18n/routing"; -import { useTransition } from "react"; +import { useEffect, useState, useTransition } from "react"; import { Select, SelectContent, @@ -14,21 +14,53 @@ import { SelectValue, } from "@/components/ui/select"; import Image from "next/image"; +import Cookies from "js-cookie"; + +export const getLanguage = (): string | null => { + if (typeof window === "undefined") return null; + return localStorage.getItem("language"); +}; + +export const setLanguage = (value: string) => { + if (typeof window === "undefined") return; + localStorage.setItem("language", value); +}; export default function LocalSwitcher() { const [isPending, startTransition] = useTransition(); const router = useRouter(); const pathname = usePathname(); const params = useParams(); - const localActive = useLocale(); + const localActive = useLocale() || "in"; + const [selectedLang, setSelectedLang] = useState(""); + + useEffect(() => { + const storedLang = getLanguage(); + + if (!storedLang) { + setLanguage("in"); + setSelectedLang("in"); + + startTransition(() => { + router.replace(pathname, { locale: "in" }); + }); + } else { + setSelectedLang(storedLang); + startTransition(() => { + router.replace(pathname, { locale: storedLang }); + }); + } + }, []); const onSelectChange = (nextLocale: string) => { + setLanguage(nextLocale); + setSelectedLang(nextLocale); startTransition(() => { router.replace(pathname, { locale: nextLocale }); }); }; return ( - diff --git a/i18n/routing.ts b/i18n/routing.ts index 401b83bf..bcd8ce56 100644 --- a/i18n/routing.ts +++ b/i18n/routing.ts @@ -1,15 +1,15 @@ -import {defineRouting} from 'next-intl/routing'; -import {createSharedPathnamesNavigation} from 'next-intl/navigation'; - import {locales} from '@/config'; +import { defineRouting } from "next-intl/routing"; +import { createSharedPathnamesNavigation } from "next-intl/navigation"; +import { locales } from "@/config"; export const routing = defineRouting({ // A list of all locales that are supported locales: locales, - + // Used when no locale matches - defaultLocale: 'en' + defaultLocale: "in", }); - + // Lightweight wrappers around Next.js' navigation APIs // that will consider the routing configuration -export const {Link, redirect, usePathname, useRouter} = - createSharedPathnamesNavigation(routing); \ No newline at end of file +export const { Link, redirect, usePathname, useRouter } = + createSharedPathnamesNavigation(routing); diff --git a/middleware.ts b/middleware.ts index bb226b0d..f8a2d2b1 100644 --- a/middleware.ts +++ b/middleware.ts @@ -1,25 +1,29 @@ 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 = request.headers.get("dashcode-locale") || "in"; +// 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, - defaultLocale, - }); - const response = handleI18nRouting(request); +// // 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); +// // Step 3: Alter the response (example) +// response.headers.set("dashcode-locale", defaultLocale); - return response; -} +// return response; +// } + +export default createMiddleware(routing); export const config = { // Match only internationalized pathnames - matcher: ["/", "/(ar|in|en)/:path*"], + matcher: ["/", "/(in|en)/:path*"], };