disable auto language detection;
disable languuage switch for now; Tweak some error logs and messages
This commit is contained in:
@ -105,19 +105,22 @@ export default function Sidebar({ isSidebarOpen, toggleSidebar }) {
|
||||
useEffect(() => {
|
||||
const fetchLocations = async () => {
|
||||
try {
|
||||
const response = await axiosInstance.get('/api/data/locations'); // Adjust the API endpoint as needed
|
||||
const locationsData = response.data
|
||||
.filter(location => location.isActive === true)
|
||||
.map(location => ({
|
||||
text: location.name,
|
||||
url: `/cart/locations/${location.id}`,
|
||||
}));
|
||||
// Find the "Locations" menu item and populate its children with locationsData
|
||||
const menuIndex = sidemenu.findIndex(item => item.id === "locations");
|
||||
if (menuIndex !== -1) {
|
||||
sidemenu[menuIndex].children = locationsData;
|
||||
if (session) { // Don't fetch locations if the user is not authenticated
|
||||
|
||||
const response = await axiosInstance.get('/api/data/locations'); // Adjust the API endpoint as needed
|
||||
const locationsData = response.data
|
||||
.filter(location => location.isActive === true)
|
||||
.map(location => ({
|
||||
text: location.name,
|
||||
url: `/cart/locations/${location.id}`,
|
||||
}));
|
||||
// Find the "Locations" menu item and populate its children with locationsData
|
||||
const menuIndex = sidemenu.findIndex(item => item.id === "locations");
|
||||
if (menuIndex !== -1) {
|
||||
sidemenu[menuIndex].children = locationsData;
|
||||
}
|
||||
//setLocations(locationsData); // Optional, if you need to use locations elsewhere
|
||||
}
|
||||
//setLocations(locationsData); // Optional, if you need to use locations elsewhere
|
||||
} catch (error) {
|
||||
console.error("Error fetching locations:", error);
|
||||
}
|
||||
@ -174,16 +177,17 @@ function UserSection({ session }) {
|
||||
}
|
||||
|
||||
function SignInButton() {
|
||||
const t = useTranslations('common');
|
||||
// const t = useTranslations('common');
|
||||
return (
|
||||
<div className="items-center py-2 font-bold" onClick={() => signIn()}>
|
||||
<button>{t('login')}</button>
|
||||
<button>вход</button>
|
||||
{/* <button>{t('login')}</button> */}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function UserDetails({ session }) {
|
||||
const t = useTranslations('common');
|
||||
// const t = useTranslations('common');
|
||||
return (
|
||||
<>
|
||||
<hr className="m-0" />
|
||||
@ -194,7 +198,10 @@ function UserDetails({ session }) {
|
||||
<div className="ml-3 overflow-hidden">
|
||||
<p className="mx-1 mt-1 text-sm font-medium text-gray-800 dark:text-gray-200">{session.user.name}</p>
|
||||
<p className="mx-1 mt-1 text-sm font-medium text-gray-600 dark:text-gray-400">{session.user.role}</p>
|
||||
<a href="/api/auth/signout" className={styles.button} onClick={(e) => { e.preventDefault(); signOut(); }}>{t('logout')}</a>
|
||||
<a href="/api/auth/signout" className={styles.button} onClick={(e) => { e.preventDefault(); signOut(); }}>
|
||||
{/* {t('logout')} */}
|
||||
изход
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
Reference in New Issue
Block a user