Contect with order api

This commit is contained in:
Jelaletdin12
2025-12-09 23:01:18 +05:00
parent d6c163dd06
commit 14f9bd400e
18 changed files with 910 additions and 624 deletions

View File

@@ -1,29 +1,39 @@
"use client"
import { useRouter } from "next/navigation"
import Image from "next/image"
import { useLocale } from "next-intl"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import tm from "@/public/tm.png"
import ru from "@/public/ru.png"
"use client";
import { useRouter, usePathname } from "next/navigation";
import Image from "next/image";
import { useLocale } from "next-intl";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import tm from "@/public/tm.png";
import ru from "@/public/ru.png";
interface Language {
code: string
name: string
flag: any
code: string;
name: string;
flag: any;
}
const LANGUAGES: Language[] = [
{ code: "ru", name: "Russian", flag: ru },
{ code: "tm", name: "Turkmen", flag: tm },
]
];
export default function LanguageSelector() {
const locale = useLocale()
const router = useRouter()
const locale = useLocale();
const router = useRouter();
const pathname = usePathname(); // Şu anki path'i al
const handleLanguageChange = (newLocale: string) => {
router.push(`/${newLocale}`)
}
// Mevcut path'i yeni locale ile değiştir
// Örnek: /tm/cart -> /ru/cart
const currentPath = pathname.replace(`/${locale}`, "");
router.push(`/${newLocale}${currentPath}`);
};
return (
<Select value={locale} onValueChange={handleLanguageChange}>
@@ -43,17 +53,22 @@ export default function LanguageSelector() {
))}
</SelectContent>
</Select>
)
);
}
function FlagIcon({ locale }: { locale: string }) {
const language = LANGUAGES.find((lang) => lang.code === locale)
const language = LANGUAGES.find((lang) => lang.code === locale);
if (!language) return null
if (!language) return null;
return (
<div className="relative h-5 w-7">
<Image src={language.flag || "/placeholder.svg"} alt={language.name} fill className="object-cover rounded" />
<Image
src={language.flag || "/placeholder.svg"}
alt={language.name}
fill
className="object-cover rounded"
/>
</div>
)
);
}