merge
This commit is contained in:
commit
bc0e169821
|
|
@ -48,6 +48,11 @@ const columns: ColumnDef<any>[] = [
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "title",
|
||||||
|
header: "Judul Berita",
|
||||||
|
cell: ({ row }) => <span>{row.getValue("title")}</span>,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "pageUrl",
|
accessorKey: "pageUrl",
|
||||||
header: "Link Berita",
|
header: "Link Berita",
|
||||||
|
|
|
||||||
|
|
@ -104,13 +104,15 @@ export default function TrackingMediaModal(props: {
|
||||||
value={inputValue}
|
value={inputValue}
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
/>{" "}
|
/>{" "}
|
||||||
<div className="w-full border rounded-md text-xs p-2 flex flex-col gap-1 max-h-[300px] overflow-auto">
|
<div className="w-full border rounded-sm text-xs p-2 flex flex-col max-h-[300px] overflow-auto">
|
||||||
{content.length > 0 &&
|
{content.length > 0 &&
|
||||||
content.map((item: any) => (
|
content.map((item: any) => (
|
||||||
<a
|
<a
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={`cursor-pointer ${
|
className={`cursor-pointer px-2 py-4 ${
|
||||||
selectedId === item.id ? "font-bold" : ""
|
selectedId === item.id
|
||||||
|
? "font-bold bg-gray-200 rounded-sm"
|
||||||
|
: "hover:bg-gray-100 hover:font-semibold"
|
||||||
}`}
|
}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setSelectedId(item.id);
|
setSelectedId(item.id);
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ const Hero = (props: { group?: string }) => {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{showFormModal && <FormSurvey />}
|
{/* {showFormModal && <FormSurvey />} */}
|
||||||
</div>
|
</div>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="flex flex-col space-y-3 mx-auto w-full lg:w-2/3">
|
<div className="flex flex-col space-y-3 mx-auto w-full lg:w-2/3">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { useParams } from "next/navigation";
|
||||||
import { locales } from "@/config";
|
import { locales } from "@/config";
|
||||||
import { usePathname, useRouter } from "@/i18n/routing";
|
import { usePathname, useRouter } from "@/i18n/routing";
|
||||||
|
|
||||||
import { useTransition } from "react";
|
import { useEffect, useState, useTransition } from "react";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
|
|
@ -14,21 +14,53 @@ import {
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import Image from "next/image";
|
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() {
|
export default function LocalSwitcher() {
|
||||||
const [isPending, startTransition] = useTransition();
|
const [isPending, startTransition] = useTransition();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const localActive = useLocale();
|
const localActive = useLocale() || "in";
|
||||||
|
const [selectedLang, setSelectedLang] = useState<string>("");
|
||||||
|
|
||||||
|
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) => {
|
const onSelectChange = (nextLocale: string) => {
|
||||||
|
setLanguage(nextLocale);
|
||||||
|
setSelectedLang(nextLocale);
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
router.replace(pathname, { locale: nextLocale });
|
router.replace(pathname, { locale: nextLocale });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Select onValueChange={onSelectChange} defaultValue={localActive}>
|
<Select onValueChange={onSelectChange} value={selectedLang}>
|
||||||
<SelectTrigger className="w-[94px] border-none read-only:bg-transparent">
|
<SelectTrigger className="w-[94px] border-none read-only:bg-transparent">
|
||||||
<SelectValue placeholder="Select a language" />
|
<SelectValue placeholder="Select a language" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
import {defineRouting} from 'next-intl/routing';
|
import { defineRouting } from "next-intl/routing";
|
||||||
import {createSharedPathnamesNavigation} from 'next-intl/navigation';
|
import { createSharedPathnamesNavigation } from "next-intl/navigation";
|
||||||
import {locales} from '@/config';
|
import { locales } from "@/config";
|
||||||
export const routing = defineRouting({
|
export const routing = defineRouting({
|
||||||
// A list of all locales that are supported
|
// A list of all locales that are supported
|
||||||
locales: locales,
|
locales: locales,
|
||||||
|
|
||||||
// Used when no locale matches
|
// Used when no locale matches
|
||||||
defaultLocale: 'en'
|
defaultLocale: "in",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Lightweight wrappers around Next.js' navigation APIs
|
// Lightweight wrappers around Next.js' navigation APIs
|
||||||
// that will consider the routing configuration
|
// that will consider the routing configuration
|
||||||
export const {Link, redirect, usePathname, useRouter} =
|
export const { Link, redirect, usePathname, useRouter } =
|
||||||
createSharedPathnamesNavigation(routing);
|
createSharedPathnamesNavigation(routing);
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,29 @@
|
||||||
import createMiddleware from "next-intl/middleware";
|
import createMiddleware from "next-intl/middleware";
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { locales } from "@/config";
|
import { locales } from "@/config";
|
||||||
|
import { routing } from "./i18n/routing";
|
||||||
|
|
||||||
export default async function middleware(request: NextRequest) {
|
// export default async function middleware(request: NextRequest) {
|
||||||
// Step 1: Use the incoming request (example)
|
// // Step 1: Use the incoming request (example)
|
||||||
const defaultLocale = request.headers.get("dashcode-locale") || "in";
|
// const defaultLocale = "in";
|
||||||
|
// // const defaultLocale = request.headers.get("dashcode-locale") || "in";
|
||||||
|
|
||||||
// Step 2: Create and call the next-intl middleware (example)
|
// // Step 2: Create and call the next-intl middleware (example)
|
||||||
const handleI18nRouting = createMiddleware({
|
// const handleI18nRouting = createMiddleware({
|
||||||
locales,
|
// locales: ["in", "en"],
|
||||||
defaultLocale,
|
// defaultLocale: "in",
|
||||||
});
|
// });
|
||||||
const response = handleI18nRouting(request);
|
// const response = handleI18nRouting(request);
|
||||||
|
|
||||||
// Step 3: Alter the response (example)
|
// // Step 3: Alter the response (example)
|
||||||
response.headers.set("dashcode-locale", defaultLocale);
|
// response.headers.set("dashcode-locale", defaultLocale);
|
||||||
|
|
||||||
return response;
|
// return response;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
export default createMiddleware(routing);
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
// Match only internationalized pathnames
|
// Match only internationalized pathnames
|
||||||
matcher: ["/", "/(ar|in|en)/:path*"],
|
matcher: ["/", "/(in|en)/:path*"],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue