File tree 3 files changed +13
-12
lines changed
(app)/(questions)/question/[slug]
components/app/onboarding 3 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -60,11 +60,10 @@ export default async function QuestionUidLayout({
60
60
url : getBaseUrl ( ) ,
61
61
} ,
62
62
assesses : [ 'coding' ] ,
63
- dateCreated : new Date ( question ?. createdAt || '' ) . toISOString ( ) ,
64
- dateModified : new Date ( question ?. updatedAt || '' ) . toISOString ( ) ,
65
- datePublished : new Date (
66
- question ?. questionDate || question ?. createdAt || ''
67
- ) . toISOString ( ) ,
63
+ dateCreated : question ?. createdAt . toISOString ( ) || '' ,
64
+ dateModified : question ?. updatedAt . toISOString ( ) || '' ,
65
+ datePublished :
66
+ question ?. questionDate || question ?. createdAt . toISOString ( ) || '' ,
68
67
headline : question ?. question || '' ,
69
68
interactivityType : 'mixed' ,
70
69
isAccessibleForFree : true ,
Original file line number Diff line number Diff line change @@ -4,20 +4,23 @@ import StarsBackground from '@/components/ui/stars-background';
4
4
import Link from 'next/link' ;
5
5
import { UserOnboardingContextProvider } from '@/components/app/onboarding/onboarding-context' ;
6
6
import OnboardingForm from '@/components/app/onboarding/onboarding-form' ;
7
+ import { getTodaysQuestion } from '@/utils/data/questions/get-today' ;
7
8
8
9
export const metadata = {
9
10
title : 'Onboarding | TechBlitz' ,
10
11
} ;
11
12
12
- export default function OnboardingPage ( ) {
13
+ export default async function OnboardingPage ( ) {
14
+ const dailyQuestion = await getTodaysQuestion ( ) ;
15
+
13
16
return (
14
17
< div className = "relative container" >
15
18
< StarsBackground className = "-z-10" />
16
19
< div className = "flex flex-col min-h-screen" >
17
20
< Link href = "/" className = "pl-0 md:pl-8 p-8 pb-0 flex justify-center" >
18
21
< Logo />
19
22
</ Link >
20
- < UserOnboardingContextProvider >
23
+ < UserOnboardingContextProvider dailyQuestion = { dailyQuestion } >
21
24
< div className = "flex-1 flex items-center justify-center" >
22
25
< OnboardingForm />
23
26
</ div >
Original file line number Diff line number Diff line change 7
7
*/
8
8
import { createContext , useContext , useState } from 'react' ;
9
9
import type { UpdatableUserFields } from '@/types/User' ;
10
- import { QuestionWithTags } from '@/types/Questions' ;
10
+ import { Question , QuestionWithTags } from '@/types/Questions' ;
11
11
import { getOnboardingQuestions } from '@/utils/data/questions/get-onboarding' ;
12
- import { getTodaysQuestion } from '@/utils/data/questions/get-today' ;
13
12
import { useRouter } from 'next/navigation' ;
14
13
// context type
15
14
type OnboardingContextType = {
@@ -42,8 +41,10 @@ const OnboardingContext = createContext<OnboardingContextType | null>(null);
42
41
// provide the context to all the children components
43
42
export const UserOnboardingContextProvider = ( {
44
43
children,
44
+ dailyQuestion,
45
45
} : {
46
46
children : React . ReactNode ;
47
+ dailyQuestion : Question | null ;
47
48
} ) => {
48
49
const router = useRouter ( ) ;
49
50
// get the current user
@@ -81,10 +82,8 @@ export const UserOnboardingContextProvider = ({
81
82
} ;
82
83
83
84
const handleGetDailyQuestion = async ( ) => {
84
- const question = await getTodaysQuestion ( ) ;
85
-
86
85
// redirect to the question page
87
- router . push ( `/question/${ question ?. slug } ` ) ;
86
+ router . push ( `/question/${ dailyQuestion ?. slug } ` ) ;
88
87
} ;
89
88
90
89
return (
You can’t perform that action at this time.
0 commit comments