Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
uche789 committed Nov 8, 2024
1 parent 64e1679 commit d055dcc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/language-dropdown.tsx/LanguageDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const LanguageDropdown: FC<{ selected?: string, clickHandler: (value: string) =>
selected = "de",
clickHandler,
}) => {
const [isOpen, setIsOpen] = useState(false);
const [isOpen, setIsOpen] = useState(false);
const getClassMenuItem = (value: string) =>
`language-dropdown-menu-item ${selected === value ? "language-dropdown-menu-item--selected" : ""}`;

Expand Down
18 changes: 16 additions & 2 deletions src/features/layout/components/app-header/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IconType } from "@/lib/types";
import SvgIcon from "@/components/svg-icon/svg-icon";
import "./AppHeader.scss";
import links from "../links";
import { Link, useNavigate, useParams } from "react-router-dom";
import { Link, redirect, useLocation, useNavigate, useParams } from "react-router-dom";
import LanguageDropdown from "@/components/language-dropdown.tsx/LanguageDropdown";

export default function AppHeader() {
Expand All @@ -18,8 +18,22 @@ export default function AppHeader() {
}

const setLanguage = (value: string) => {
if (/\/grammar\/[^/]+/.test(window.location.pathname)) {
navigate('/' + value + '/grammar');
return;
} else if (/\/practice\/[^/]+/.test(window.location.pathname)) {
navigate('/' + value + '/practice');
return;
} else if (/\/vocabulary\/[^/]+/.test(window.location.pathname)) {
navigate('/' + value + '/vocabulary');
return;
} else if (/\/idiom\//.test(window.location.pathname)) {
navigate('/' + value + '/idioms');
return;
}

const pathname = window.location.pathname.replace(/\/(de|fr|jp)/, `/${value}`);
window.location.replace(window.origin + pathname)
navigate(pathname.replace('/learn-german', ''))
}

return (
Expand Down
2 changes: 2 additions & 0 deletions src/pages/GrammarPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default function Practice() {
const selected = searchParams.get('grammarType');
if (selected) {
setIds([...ids, categories.grammar[selected]])
} else {
setIds(ids)
}
refetch()
}, [params, searchParams])
Expand Down
7 changes: 7 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@ export default defineConfig({
"@": path.resolve(__dirname, "./src"),
},
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler' // or "modern"
}
}
},
base: "./"
});

0 comments on commit d055dcc

Please sign in to comment.