Skip to content

Commit

Permalink
Split up context
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Jul 17, 2024
1 parent f5727ac commit 4627445
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { HomePage } from "./pages/HomePage"
import { createTheme, ThemeProvider } from "@mui/material/styles"
import Container from "@mui/material/Container"
import { IdentityContextProvider } from "./context"
import { IdentityContextProvider } from "./context/identity"
import { RegisterPage } from "./pages/RegisterPage"
import { LoginPage } from "./pages/LoginPage"
import { LeaderboardsPage } from "./pages/LeaderboardsPage"
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/akatsuki-api/authentication.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios"
import type { Identity } from "../../context"
import type { Identity } from "../../context/identity"

interface AuthenticateRequest {
username: string
Expand Down
5 changes: 4 additions & 1 deletion src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {
} from "@mui/material"
import { Link, useNavigate } from "react-router-dom"
import { FavoriteOutlined } from "@mui/icons-material"
import { removeIdentityFromLocalStorage, useIdentityContext } from "../context"
import {
removeIdentityFromLocalStorage,
useIdentityContext,
} from "../context/identity"
import { logout } from "../adapters/akatsuki-api/authentication"
import { useEffect, useMemo, useState } from "react"
import { AkatsukiLogo } from "./images/logos/AkatsukiLogo"
Expand Down
2 changes: 1 addition & 1 deletion src/context.tsx → src/context/identity.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import { UserPrivileges } from "./privileges"
import { UserPrivileges } from "../privileges"

const IDENTITY_CACHE_KEY = "identity"

Expand Down
2 changes: 1 addition & 1 deletion src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { Link } from "react-router-dom"
import Stack from "@mui/material/Stack"
import { type OverridableStringUnion } from "@mui/types"
import { useIdentityContext } from "../context"
import { useIdentityContext } from "../context/identity"

const NavButton = ({
to,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/LoginPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react"
import { authenticate } from "../adapters/akatsuki-api/authentication"
import { useIdentityContext } from "../context"
import { useIdentityContext } from "../context/identity"
import { useNavigate } from "react-router-dom"
import Stack from "@mui/material/Stack"
import Alert from "@mui/material/Alert"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RegisterPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useIdentityContext } from "../context"
import { useIdentityContext } from "../context/identity"

export const RegisterPage = () => {
const { identity } = useIdentityContext()
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SupportPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useIdentityContext } from "../context"
import { useIdentityContext } from "../context/identity"

export const SupportPage = () => {
const { identity } = useIdentityContext()
Expand Down

0 comments on commit 4627445

Please sign in to comment.