-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add group, create, upload links to dashboard
- Loading branch information
Showing
2 changed files
with
76 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,13 @@ | ||
import { createEffect, useContext } from "solid-js"; | ||
import { createToast } from "../components/ShowToasts"; | ||
import { UserContext } from "../contexts/UserContext"; | ||
|
||
export const Home = () => { | ||
const api_host: string = import.meta.env.VITE_API_HOST as string; | ||
|
||
const userContext = useContext(UserContext); | ||
|
||
const login = () => { | ||
fetch(`${api_host}/auth/me`, { | ||
credentials: "include", | ||
}) | ||
.then((res) => { | ||
if (res.status === 401) { | ||
window.location.href = `${api_host}/auth?redirect_uri=${window.origin}`; | ||
return; | ||
} | ||
return res.json(); | ||
}) | ||
.then(() => { | ||
window.location.href = `${ | ||
window.origin | ||
}/dashboard/${userContext.selectedOrganizationId?.()}`; | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
createToast({ | ||
title: "Error", | ||
type: "error", | ||
message: "Error logging in", | ||
}); | ||
}); | ||
}; | ||
|
||
createEffect(() => { | ||
login(); | ||
window.location.href = `${ | ||
window.origin | ||
}/dashboard/${userContext.selectedOrganizationId?.()}`; | ||
}); | ||
return <div />; | ||
}; |