Skip to content

Commit

Permalink
fix: 🐛 fix loading to dashboard error
Browse files Browse the repository at this point in the history
  • Loading branch information
dfrnoch committed Dec 19, 2023
1 parent e5cadc0 commit 360eac5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import type { ParentComponent } from "solid-js";
import type { Component } from "solid-js";
import { checkDb } from "@/bindings";
import { useNavigate } from "@solidjs/router";

const Loader: ParentComponent = (props) => {
const Loader: Component = () => {
console.log("Loader");
const navigate = useNavigate();

const startup = async () => {
const data = await checkDb();

if (data === 200) {
navigate("/setup");
navigate("/dashboard");
return;
}
navigate("/setup");
Expand Down
6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ const Settings = lazy(() => import("./screens/Dashboard/pages/Settings"));
const Dashboard = lazy(() => import("./screens/Dashboard"));
const Setup = lazy(() => import("./screens/Setup"));
const App = lazy(() => import("./App"));
const Loader = lazy(() => import("./Loader"));

import { render } from "solid-js/web";

import { Theme, getTheme, setTheme } from "./utils/theme";
import { Navigate, Route, Router } from "@solidjs/router";
import { Route, Router } from "@solidjs/router";

setTheme(getTheme());
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (e) => e.matches && setTheme(Theme.Dark));
Expand All @@ -28,8 +29,7 @@ window
render(
() => (
<Router root={App}>
<Route path="/" component={() => <Navigate href={"/setup"} />} />
<Route path="/loader" component={App} />
<Route path="/" component={Loader} />
<Route path="/setup" component={Setup} />
<Route path="/dashboard" component={Dashboard}>
<Route path="/" component={Overview} />
Expand Down
4 changes: 3 additions & 1 deletion src/screens/Setup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import InputList from "@/shared/components/Menu/InputList";
import { Hr } from "@/shared/components/Menu/Hr";
import { Button } from "./components/Button";
import { Title } from "./components/Title";
import { useNavigate } from "@solidjs/router";

const SetupWizard: Component = () => {
const [t] = useI18n();
const [currentStep, setCurrentStep] = createSignal(0);
const navigate = useNavigate();
const [userData, setUserData] = createStore({
companyName: "",
cin: "",
Expand Down Expand Up @@ -152,7 +154,7 @@ const SetupWizard: Component = () => {
streetAddress: "ahoj",
});

window.location.reload();
navigate("/loader");
} catch (error) {
console.log(error);
}
Expand Down

0 comments on commit 360eac5

Please sign in to comment.