Skip to content

Commit

Permalink
Refactor isOffSections logic to handle environment variable parsing m…
Browse files Browse the repository at this point in the history
…ore robustly
  • Loading branch information
MatinDehghanian committed Dec 6, 2024
1 parent 57d86c9 commit 2619ec1
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,34 @@ function App() {
? `${data.username} Sub Info`
: `${import.meta.env.VITE_BRAND_NAME || "Ourenus"} Sub Info`;

const isOffSections = useMemo(() => {
try {
return JSON.parse(
import.meta.env.VITE_OFF_SECTIONS || {
const isOffSections = useMemo(() => {
try {
const envValue = import.meta.env.VITE_OFF_SECTIONS;
if (envValue) {
return JSON.parse(envValue);
}
return {
appsBox: true,
logoBox: true,
timeBox: true,
usageBox: true,
userBox: true,
supportBox: true,
configs: true,
}
);
} catch (error) {
console.error("Failed to parse VITE_OFF_SECTIONS:", error);
return {};
}
}, []);
};
} catch (error) {
console.error("Failed to parse VITE_OFF_SECTIONS:", error);
return {
appsBox: true,
logoBox: true,
timeBox: true,
usageBox: true,
userBox: true,
supportBox: true,
configs: true,
};
}
}, []);

return (
<ThemeProvider theme={theme}>
Expand Down

0 comments on commit 2619ec1

Please sign in to comment.