mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Catch all routes
This commit is contained in:
@@ -14,8 +14,6 @@ interface CardProps {
|
||||
imageFormat?: 'square' | 'portrait' | 'landscape';
|
||||
}
|
||||
|
||||
const placeholderImg = '/product-img-placeholder.svg';
|
||||
|
||||
const Card: FC<CardProps> = ({ className, title, image, link, text, imageFormat = 'square' }) => {
|
||||
const rootClassName = cn('relative', className);
|
||||
|
||||
@@ -39,7 +37,7 @@ const Card: FC<CardProps> = ({ className, title, image, link, text, imageFormat
|
||||
} else if (type === 'category') {
|
||||
href = `/category/${link.internalLink.reference.slug.current}`;
|
||||
} else {
|
||||
return `${link.internalLink.reference.slug.current}`;
|
||||
href = `${link.internalLink.reference.slug.current}`;
|
||||
}
|
||||
|
||||
return (
|
||||
|
@@ -1,43 +1,47 @@
|
||||
'use client';
|
||||
|
||||
import LanguageIcon from 'components/icons/language';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuTrigger
|
||||
} from 'components/ui/dropdown/dropdown';
|
||||
import { useLocale } from 'next-intl';
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { useState } from 'react';
|
||||
import { supportedLanguages } from '../../../i18n-config';
|
||||
|
||||
interface LocaleSwitcherProps {
|
||||
currentLocale: string;
|
||||
localeData: {
|
||||
type: string;
|
||||
locale: string;
|
||||
translations: [];
|
||||
};
|
||||
}
|
||||
// interface LocaleSwitcherProps {
|
||||
// localeData: {
|
||||
// type: string;
|
||||
// locale: string;
|
||||
// translations: [];
|
||||
// };
|
||||
// }
|
||||
|
||||
export default function LocaleSwitcher({ currentLocale, localeData }: LocaleSwitcherProps) {
|
||||
export default function LocaleSwitcher() {
|
||||
const pathName = usePathname();
|
||||
const translations = localeData.translations;
|
||||
const currentLocale = useLocale();
|
||||
|
||||
// const translations = localeData.translations;
|
||||
|
||||
const redirectedPathName = (locale: string) => {
|
||||
if (!pathName || translations.length === 0) return '/';
|
||||
if (!pathName) return '/';
|
||||
|
||||
if (translations.length > 0) {
|
||||
const translation = translations.find((obj) => {
|
||||
return obj['locale'] === locale;
|
||||
});
|
||||
// if (translations.length > 0) {
|
||||
// const translation = translations.find((obj) => {
|
||||
// return obj['locale'] === locale;
|
||||
// });
|
||||
|
||||
if (translation) {
|
||||
const url = `/${translation['locale']}${translation['slug']}`;
|
||||
// if (translation) {
|
||||
// const url = `/${translation['locale']}${translation['slug']}`;
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
// return url;
|
||||
// }
|
||||
// }
|
||||
|
||||
return '/';
|
||||
return `/${locale}`;
|
||||
};
|
||||
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
Reference in New Issue
Block a user