1import './App.css'
2import { useTheme } from './utils/hooks/themeHook'
3import { BsSunFill, BsFillMoonFill } from "react-icons/bs";;
4import { TheIcon } from './components/Shared/TheIcon';
5
6import { Query, useQuery } from 'react-query';
7import { BrowserRouter, Routes, Route } from 'react-router-dom';
8import { Home } from './components/home/Home';
9import { Redirect } from './components/login/Redirect';
10import { Login } from './components/login/Login';
11import { useEffect, useInsertionEffect } from 'react';
12import { client } from './pocket/config';
13import { ProtectedRoute } from './components/login/PrivateRoutes';
14import { UserType } from './components/login/types';
15
16
17type AppProps = {
18
19};
20type MutationVars = {
21 data: any;
22 index: string;
23}
24export interface FormOptions {
25 field_name: string;
26 field_type: string;
27 default_value: string | number
28 options?: { name: string; value: string }[]
29}
30function App({ }: AppProps) {
31 const { colorTheme, setTheme } = useTheme();
32 const mode = colorTheme === "light" ? BsSunFill : BsFillMoonFill;
33 const toggle = () => {
34 setTheme(colorTheme);
35 };
36
37 const getUser = async()=>{
38 return client.authStore.model
39 }
40
41
42
43
44 const userQuery = useQuery(["user"],getUser);
45
46 console.log("user query ====== ",userQuery)
47
48
49if(userQuery.isLoading){
50 return(
51 <div className="w-full min-h-screen text-5xl font-bold flex-col-center">
52 LOADING....
53 </div>
54 )
55}
56 if (userQuery.isError) {
57 return (
58 <div className="w-full min-h-screen text-5xl font-bold flex-col-center">
59 {}
60 {userQuery?.error?.message}
61 </div>
62 )
63 }
64const user = userQuery.data as UserType|null|undefined
65 return (
66 <div
67 className="w-full min-h-screen flex-col-center scroll-bar
68 dark:bg-black dark:text-white "
69 >
70
71 <BrowserRouter>
72 <div className="fixed top-[0px] w-[100%] z-50">
73 <div className="w-fit p-1 flex-center">
74 <TheIcon Icon={mode} size={"25"} color={""} iconAction={toggle} />
75 </div>
76 </div>
77 <div className="w-full h-[90%] mt-16 ">
78 <Routes>
79 <Route
80 path="/"
81 element={
82 <ProtectedRoute user={user}>
83 <Home user={user} />
84 </ProtectedRoute>
85 }
86 />
87 {}
88 <Route path="/login" element={<Login />} />
89
90 <Route path="/redirect" element={<Redirect user={user}/>} />
91
92 </Routes>
93 </div>
94 </BrowserRouter>
95
96 </div>
97 );
98}
99
100export default App