merge
This commit is contained in:
commit
bc0e169821
|
|
@ -48,6 +48,11 @@ const columns: ColumnDef<any>[] = [
|
|||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "title",
|
||||
header: "Judul Berita",
|
||||
cell: ({ row }) => <span>{row.getValue("title")}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "pageUrl",
|
||||
header: "Link Berita",
|
||||
|
|
|
|||
|
|
@ -104,13 +104,15 @@ export default function TrackingMediaModal(props: {
|
|||
value={inputValue}
|
||||
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.map((item: any) => (
|
||||
<a
|
||||
key={item.id}
|
||||
className={`cursor-pointer ${
|
||||
selectedId === item.id ? "font-bold" : ""
|
||||
className={`cursor-pointer px-2 py-4 ${
|
||||
selectedId === item.id
|
||||
? "font-bold bg-gray-200 rounded-sm"
|
||||
: "hover:bg-gray-100 hover:font-semibold"
|
||||
}`}
|
||||
onClick={() => {
|
||||
setSelectedId(item.id);
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ const Hero = (props: { group?: string }) => {
|
|||
/>
|
||||
)}
|
||||
|
||||
{showFormModal && <FormSurvey />}
|
||||
{/* {showFormModal && <FormSurvey />} */}
|
||||
</div>
|
||||
{isLoading ? (
|
||||
<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 { 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<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) => {
|
||||
setLanguage(nextLocale);
|
||||
setSelectedLang(nextLocale);
|
||||
startTransition(() => {
|
||||
router.replace(pathname, { locale: nextLocale });
|
||||
});
|
||||
};
|
||||
return (
|
||||
<Select onValueChange={onSelectChange} defaultValue={localActive}>
|
||||
<Select onValueChange={onSelectChange} value={selectedLang}>
|
||||
<SelectTrigger className="w-[94px] border-none read-only:bg-transparent">
|
||||
<SelectValue placeholder="Select a language" />
|
||||
</SelectTrigger>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
export const { Link, redirect, usePathname, useRouter } =
|
||||
createSharedPathnamesNavigation(routing);
|
||||
|
|
|
|||
|
|
@ -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*"],
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue