diff --git a/frontend/components/Header.js b/frontend/components/Header.js index 6c0a992..9008bbb 100644 --- a/frontend/components/Header.js +++ b/frontend/components/Header.js @@ -73,7 +73,11 @@ function Header({ darkMode, setDarkMode }) { } const handleToggleDarkMode = () => { - setDarkMode(prevMode => !prevMode) + setDarkMode(prevMode => { + const newMode = !prevMode + localStorage.setItem('darkMode', newMode ? '1' : '0') + return newMode + }) } return ( diff --git a/frontend/components/ProductGrid.js b/frontend/components/ProductGrid.js index b334ea7..3b8efed 100644 --- a/frontend/components/ProductGrid.js +++ b/frontend/components/ProductGrid.js @@ -69,18 +69,6 @@ export default function ProductGrid(props) { }, []) const columns = React.useMemo(() => { - const getDownloadUrl = row => { - const { id, /* eslint-disable camelcase */ display_name } = row - - const formattedDisplayName = display_name - .replace(/[-\s]/g, '') - .toLowerCase() - - const productUrl = getProductUrl(`${id}_${formattedDisplayName}`) - const downloadUrl = `${window.location.origin}${productUrl}` - return downloadUrl - } - const handleDownload = row => { router.push(getProductUrl(row.internal_name)) } @@ -90,8 +78,9 @@ export default function ProductGrid(props) { } const handleShare = row => { - const downloadUrl = getDownloadUrl(row) - setSelectedFileUrl(downloadUrl) + const productUrl = getProductUrl(row.internal_name) + const shareUrl = `${window.location.origin}${productUrl}` + setSelectedFileUrl(shareUrl) setSnackbarOpen(true) } diff --git a/frontend/pages/_app.js b/frontend/pages/_app.js index 279e032..58bfd92 100644 --- a/frontend/pages/_app.js +++ b/frontend/pages/_app.js @@ -22,6 +22,11 @@ export default function MyApp(props) { if (jssStyles) { jssStyles.parentElement.removeChild(jssStyles) } + + const darkModePreference = localStorage.getItem('darkMode') + if (darkModePreference) { + setDarkMode(darkModePreference === '1') + } }, []) const light = createTheme({