Skip to content

Commit

Permalink
client: wip create debate page
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham-Lal authored Jul 10, 2024
2 parents 071b94b + b61df6f commit 608ecbe
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 27 deletions.
19 changes: 19 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./App.css"
import { useRef, useState, useEffect } from "react"
import { Routes, Route, Navigate } from "react-router-dom"
import { Toaster } from "sonner"
import { ProtectedRoute } from "./ProtectedRoute"
// import { ProtectedRoute } from "./ProtectedRoute"
import { Theme, useNavStore } from "./store/useNavStore"
import { AuthTab, useAuthStore } from "./store/useAuthStore"
import handleAutoLogin from "./utils/handleAutoLogin"
Expand All @@ -23,7 +23,7 @@ export default function App() {
const { expand, sidebar, setSidebar } = useNavStore();

useEffect(() => {
document.body.setAttribute('data-theme', localStorage.getItem('theme') === Theme.Light? Theme.Light : Theme.Dark);
document.body.setAttribute('data-theme', localStorage.getItem('theme') === Theme.Light ? Theme.Light : Theme.Dark);
handleAutoLogin(setRoute, setUser, setIsAuthenticated, setAuthTab);
}, [setRoute, setUser, setIsAuthenticated, setAuthTab]);

Expand Down Expand Up @@ -65,7 +65,8 @@ export default function App() {
<Route path='/login' element={<Navigate to='/auth?type=login' />} />
<Route path='/signup' element={<Navigate to='/auth?type=signup' />} />
<Route path='/search' element={<SearchPage />} />
<Route path='/create' element={<ProtectedRoute><CreateDebatePage /></ProtectedRoute>} />
{/* <Route path='/create' element={<ProtectedRoute><CreateDebatePage /></ProtectedRoute>} /> */}
<Route path='/create' element={<CreateDebatePage />} />
<Route path='/hot-topics' element={<HotTopicsPage />} />
<Route path='/open-topics' element={<OpenTopicsPage />} />
<Route path='/notifications' element={<NotificationPage />} />
Expand Down
1 change: 1 addition & 0 deletions client/src/components/sidebar/left-sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
}

#left-sidebar ul {
list-style: none;
max-width: fit-content;
height: 100%;
max-height: 100dvh;
Expand Down
30 changes: 17 additions & 13 deletions client/src/components/sidebar/left-sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./left-sidebar.css"
import { useLocation, Link, useNavigate } from "react-router-dom"
import { toast } from "sonner"
// import { toast } from "sonner"
import { AuthStatus, AuthTab, useAuthStore } from "../../store/useAuthStore"
import { useNavStore } from "../../store/useNavStore"
import { leftSidebarLinks } from "../../data/left-sidebar-links"
Expand All @@ -16,19 +16,22 @@ const LeftSidebar: React.FC<SidebarProps> = ({ isVisible }) => {
const location = useLocation();
const navigate = useNavigate();

const { setRoute, isAuthenticated, setAuthTab } = useAuthStore();
// const { setRoute, isAuthenticated, setAuthTab } = useAuthStore();
const { isAuthenticated, setAuthTab } = useAuthStore();
const { sidebar } = useNavStore();

const handleLinkClick = (href: string, name: string) => {
if (name === "Create Debate") {
if (isAuthenticated === AuthStatus.Failed) {
setRoute(href);
setAuthTab(AuthTab.Login);
}
else if (isAuthenticated === AuthStatus.Authenticated) navigate(href);
else return toast.warning('Try again...');
}
else navigate(href);
// const handleLinkClick = (href: string, name: string) => {
const handleLinkClick = (href: string) => {
// if (name === "Create Debate") {
// if (isAuthenticated === AuthStatus.Failed) {
// setRoute(href);
// setAuthTab(AuthTab.Login);
// }
// else if (isAuthenticated === AuthStatus.Authenticated) navigate(href);
// else return toast.warning('Try again...');
// }
// else navigate(href);
navigate(href);
};

return (
Expand All @@ -39,7 +42,8 @@ const LeftSidebar: React.FC<SidebarProps> = ({ isVisible }) => {
<ul>
{leftSidebarLinks.map(item => (
<li key={item.id} title={item.name}>
<div onClick={() => handleLinkClick(item.href, item.name)} className='links__wrapper'>
{/* <div onClick={() => handleLinkClick(item.href, item.name)} className='links__wrapper'> */}
<div onClick={() => handleLinkClick(item.href)} className='links__wrapper'>
<item.icon />
<p className={`${location.pathname === item.href ? 'name-active' : ''} underline`}>
{item.name}
Expand Down
4 changes: 0 additions & 4 deletions client/src/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ input {
font-family: inherit;
}

ul {
list-style: none;
}

@keyframes shake {

0%,
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/create-debate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default function CreateDebatePage() {
return (
<div>Create Debate</div>
<div id='create'></div>
)
}
20 changes: 14 additions & 6 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,32 @@
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
"include": [
"src"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}

0 comments on commit 608ecbe

Please sign in to comment.