Skip to content

Commit 75e83da

Browse files
committed
PEER-249 Add Question Details basic card
Signed-off-by: SeeuSim <[email protected]>
1 parent fc3bc9f commit 75e83da

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import { ReactNode } from 'react';
2-
import { Navigate } from 'react-router-dom';
1+
import { Navigate, Outlet } from 'react-router-dom';
32

4-
interface PrivateRouteProps {
5-
children: ReactNode;
6-
}
7-
8-
export function PrivateRoute({ children }: PrivateRouteProps) {
3+
export function PrivateRoute() {
94
//const isAuthenticated = checkUserAuthentication();
105
const isAuthenticated = true;
11-
return isAuthenticated ? children : <Navigate to='/login' />;
6+
return isAuthenticated ? <Outlet /> : <Navigate to='/login' />;
127
}

frontend/src/components/providers/query-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
33
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
44

55
const IS_SHOW_DEVTOOLS = false;
6-
const queryClient = new QueryClient();
6+
export const queryClient = new QueryClient();
77

88
export const QueryProvider: FC<PropsWithChildren> = ({ children }) => {
99
return (

frontend/src/lib/router.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,25 @@ import { Layout } from '@/components/blocks/layout';
44
import { PrivateRoute } from '@/components/blocks/private-route';
55
import { ForgotPassword } from '@/routes/forgot-password';
66
import { Login } from '@/routes/login';
7-
import { Root } from '@/routes/root';
87
import { SignUp } from '@/routes/signup';
98
import { ROUTES } from './routes';
9+
import { loader as qnDetailsLoader, QuestionDetails } from '@/routes/questions/details';
10+
import { queryClient } from '@/components/providers';
1011

1112
export const router = createBrowserRouter([
1213
{
1314
element: <Layout />,
1415
children: [
1516
{
1617
path: ROUTES.HOME,
17-
element: (
18-
<PrivateRoute>
19-
<Root />
20-
</PrivateRoute>
21-
),
18+
element: <PrivateRoute />,
19+
children: [
20+
{
21+
path: ROUTES.QUESTION_DETAILS,
22+
loader: qnDetailsLoader(queryClient),
23+
element: <QuestionDetails />,
24+
},
25+
],
2226
},
2327
{
2428
path: ROUTES.LOGIN,

frontend/src/lib/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ export const ROUTES = {
33
LOGIN: '/login',
44
SIGNUP: '/signup',
55
FORGOT_PASSWORD: '/forgot-password',
6+
QUESTION_DETAILS: 'questions/:questionId',
67
};

frontend/src/services/api-clients.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@ export const userApiClient: AxiosInstance = axios.create({
77
},
88
});
99

10+
export const questionApiClient = axios.create({
11+
baseURL: '/question-service',
12+
headers: {
13+
'Content-Type': 'application/json',
14+
},
15+
});
16+
1017
// define more api clients for other microservices

0 commit comments

Comments
 (0)