Skip to content

Commit 671e73d

Browse files
committed
fix: fixes type issues with new question level
1 parent c9afc11 commit 671e73d

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- CreateEnum
2+
CREATE TYPE "UserExperienceLevel" AS ENUM ('BEGINNER', 'INTERMEDIATE', 'ADVANCED', 'MASTER');
3+
4+
-- AlterTable
5+
ALTER TABLE "Users" ADD COLUMN "experienceLevel" "UserExperienceLevel" NOT NULL DEFAULT 'BEGINNER';

prisma/schema/users.prisma

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ enum userLevel {
66
PREMIUM
77
}
88

9+
enum UserExperienceLevel {
10+
BEGINNER
11+
INTERMEDIATE
12+
ADVANCED
13+
MASTER
14+
}
15+
916
// the user model
1017
model Users {
1118
uid String @id()
@@ -40,7 +47,11 @@ model Users {
4047
// a user can have multiple statistics reports
4148
StatisticsReport StatisticsReport[]
4249
50+
// the number of ai question help tokens the user has (infinite for premium users)
4351
aiQuestionHelpTokens Int @default(20)
52+
53+
// the user's experience level (asked on onboarding)
54+
experienceLevel UserExperienceLevel @default(BEGINNER)
4455
}
4556

4657
// the streak model for tracking the user's streak

src/components/global/filters/buttons/filter/difficulty.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { Check, ChevronDown } from 'lucide-react';
1212
import { useRouter, useSearchParams } from 'next/navigation';
1313

14-
type QuestionDifficulty = 'EASY' | 'MEDIUM' | 'HARD';
14+
type QuestionDifficulty = 'BEGINNER' | 'EASY' | 'MEDIUM' | 'HARD';
1515

1616
interface DifficultyConfig {
1717
color: string;
@@ -20,6 +20,10 @@ interface DifficultyConfig {
2020

2121
const DIFFICULTY_MAP: Record<QuestionDifficulty | 'DEFAULT', DifficultyConfig> =
2222
{
23+
BEGINNER: {
24+
color: '#10B981',
25+
label: 'Beginner',
26+
},
2327
EASY: {
2428
color: '#10B981',
2529
label: 'Easy',

src/types/Questions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { QuestionResources, StatisticsReport } from '@prisma/client';
22
import { QuestionAnswer } from './QuestionAnswers';
33
import { Tags } from './Tags';
44

5-
export type QuestionDifficulty = 'EASY' | 'MEDIUM' | 'HARD';
5+
export type QuestionDifficulty = 'BEGINNER' | 'EASY' | 'MEDIUM' | 'HARD';
66

77
/**
88
* This type represents the shape of the data of a question.

src/utils/seo.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ export const createMetadata = ({
129129

130130
export const getQuestionEducationLevel = (question: Question['difficulty']) => {
131131
switch (question) {
132+
case 'BEGINNER':
133+
return 'beginner';
132134
case 'EASY':
133135
return 'beginner';
134136
case 'MEDIUM':
135137
return 'intermediate';
136138
case 'HARD':
137-
return 'intermediate';
139+
return 'advanced';
138140
}
139141
};
140142

0 commit comments

Comments
 (0)