diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml
index 2cc099f..6f77eea 100644
--- a/.github/workflows/image.yml
+++ b/.github/workflows/image.yml
@@ -6,7 +6,7 @@ on:
jobs:
publish-docker-image:
name: Build & Publish Docker Image
- runs-on: self-hosted
+ runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
diff --git a/src/App.tsx b/src/App.tsx
index 825fbbb..0429b5d 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,20 +1,20 @@
import { Container } from "@mui/material";
import "./App.css";
-import { AppwriteContextProvider } from "./contexts/appwrite";
-import { AuthContextProvider } from "./contexts/auth";
import { Router } from "./routes";
+import { AuthProvider } from "./providers/auth.provider";
+import { AppwriteProvider } from "./providers/appwrite.provider";
export function App() {
return (
<>
-
-
+
+
-
-
+
+
>
);
}
diff --git a/src/contexts/appwrite.context.tsx b/src/contexts/appwrite.context.tsx
new file mode 100644
index 0000000..cc004e2
--- /dev/null
+++ b/src/contexts/appwrite.context.tsx
@@ -0,0 +1,10 @@
+import { Client } from "appwrite";
+import { createContext } from "react";
+
+export type AppwriteContextValue = {
+ client: Client;
+};
+
+export const AppwriteContext = createContext(
+ {} as AppwriteContextValue,
+);
diff --git a/src/contexts/auth.context.tsx b/src/contexts/auth.context.tsx
new file mode 100644
index 0000000..3de125e
--- /dev/null
+++ b/src/contexts/auth.context.tsx
@@ -0,0 +1,13 @@
+import { createContext } from "react";
+import { Models } from "appwrite";
+
+export type AuthContextType = {
+ session?: Models.Session;
+ user?: Models.User;
+ loggedIn: boolean;
+ login(email: string, password: string): Promise;
+ logout(): Promise;
+ register(email: string, password: string, name: string): Promise;
+};
+
+export const AuthContext = createContext({} as AuthContextType);
diff --git a/src/hooks/useAppwrite.ts b/src/hooks/useAppwrite.ts
index 97e57ce..256c062 100644
--- a/src/hooks/useAppwrite.ts
+++ b/src/hooks/useAppwrite.ts
@@ -1,5 +1,5 @@
import { useContext } from "react";
-import { AppwriteContext } from "../contexts/appwrite";
+import { AppwriteContext } from "../contexts/appwrite.context";
export function useAppwrite() {
return useContext(AppwriteContext);
diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts
index f27697d..526e5dd 100644
--- a/src/hooks/useAuth.ts
+++ b/src/hooks/useAuth.ts
@@ -1,5 +1,5 @@
import { useContext } from "react";
-import { AuthContext } from "../contexts/auth";
+import { AuthContext } from "../contexts/auth.context";
export function useAuth() {
return useContext(AuthContext);
diff --git a/src/contexts/appwrite.tsx b/src/providers/appwrite.provider.tsx
similarity index 55%
rename from src/contexts/appwrite.tsx
rename to src/providers/appwrite.provider.tsx
index a6c93f0..4744a4c 100644
--- a/src/contexts/appwrite.tsx
+++ b/src/providers/appwrite.provider.tsx
@@ -1,17 +1,10 @@
import { Client } from "appwrite";
-import { createContext, PropsWithChildren } from "react";
-
-export type AppwriteContextValue = {
- client: Client;
-};
-
-export const AppwriteContext = createContext(
- {} as AppwriteContextValue,
-);
+import { PropsWithChildren } from "react";
+import { AppwriteContext } from "../contexts/appwrite.context";
type Props = PropsWithChildren;
-export function AppwriteContextProvider({ children }: Props) {
+export function AppwriteProvider({ children }: Props) {
const client = new Client();
client
.setEndpoint("https://cloud.appwrite.io/v1")
diff --git a/src/contexts/auth.tsx b/src/providers/auth.provider.tsx
similarity index 84%
rename from src/contexts/auth.tsx
rename to src/providers/auth.provider.tsx
index 561881e..791344e 100644
--- a/src/contexts/auth.tsx
+++ b/src/providers/auth.provider.tsx
@@ -1,5 +1,4 @@
import {
- createContext,
PropsWithChildren,
useCallback,
useEffect,
@@ -8,19 +7,9 @@ import {
} from "react";
import { useAppwrite } from "../hooks/useAppwrite";
import { Account, AppwriteException, ID, Models } from "appwrite";
+import { AuthContext } from "../contexts/auth.context";
-export type AuthContextValue = {
- session?: Models.Session;
- user?: Models.User;
- loggedIn: boolean;
- login(email: string, password: string): Promise;
- logout(): Promise;
- register(email: string, password: string, name: string): Promise;
-};
-
-export const AuthContext = createContext({} as AuthContextValue);
-
-export function AuthContextProvider({ children }: PropsWithChildren) {
+export function AuthProvider({ children }: PropsWithChildren) {
const { client } = useAppwrite();
const account = useMemo(() => new Account(client), [client]);
diff --git a/src/routes/error.tsx b/src/routes/error.page.tsx
similarity index 92%
rename from src/routes/error.tsx
rename to src/routes/error.page.tsx
index 8927d49..d7a9d17 100644
--- a/src/routes/error.tsx
+++ b/src/routes/error.page.tsx
@@ -5,7 +5,7 @@ type RouteError = {
statusText: string;
};
-export default function ErrorPage() {
+export function ErrorPage() {
const error = useRouteError() as RouteError;
console.error(error);
diff --git a/src/routes/index.tsx b/src/routes/index.tsx
index efb96c7..6cd6611 100644
--- a/src/routes/index.tsx
+++ b/src/routes/index.tsx
@@ -3,12 +3,12 @@ import {
RouteObject,
RouterProvider,
} from "react-router-dom";
-import { Root } from "./root";
+import { Root } from "./root.page";
import { useAuth } from "../hooks/useAuth";
-import { Login } from "./login";
-import ErrorPage from "./error";
-import { Main } from "./main";
-import { Register } from "./register";
+import { Login } from "./login.page";
+import { Main } from "./main.page";
+import { Register } from "./register.page";
+import { ErrorPage } from "./error.page";
export function Router() {
const { loggedIn } = useAuth();
diff --git a/src/routes/login.tsx b/src/routes/login.page.tsx
similarity index 100%
rename from src/routes/login.tsx
rename to src/routes/login.page.tsx
diff --git a/src/routes/main.tsx b/src/routes/main.page.tsx
similarity index 100%
rename from src/routes/main.tsx
rename to src/routes/main.page.tsx
diff --git a/src/routes/register.tsx b/src/routes/register.page.tsx
similarity index 100%
rename from src/routes/register.tsx
rename to src/routes/register.page.tsx
diff --git a/src/routes/root.tsx b/src/routes/root.page.tsx
similarity index 100%
rename from src/routes/root.tsx
rename to src/routes/root.page.tsx