mirror of
https://github.com/th30d4y/OpenLearnX.git
synced 2026-05-26 19:26:33 +00:00
harini
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import axios from "axios"
|
||||
|
||||
const API_BASE_URL = process.env.NEXT_PUBLIC_BACKEND_URL || "http://127.0.0.1:5000"
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
|
||||
api.interceptors.request.use(
|
||||
(config) => {
|
||||
const token = localStorage.getItem("openlearnx_jwt_token")
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
return config
|
||||
},
|
||||
(error) => {
|
||||
return Promise.reject(error)
|
||||
},
|
||||
)
|
||||
|
||||
export default api
|
||||
@@ -0,0 +1,21 @@
|
||||
// lib/firebase.ts
|
||||
import { initializeApp, getApps, getApp } from "firebase/app"
|
||||
import { getAuth } from "firebase/auth"
|
||||
// import { getAnalytics } from "firebase/analytics"; // Analytics can be initialized if needed
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: "AIzaSyB0srpcLeNF8nR6DF_fP7_FsemKY4--4wU",
|
||||
authDomain: "nexulen-f8790.firebaseapp.com",
|
||||
projectId: "nexulen-f8790",
|
||||
storageBucket: "nexulen-f8790.firebasestorage.app",
|
||||
messagingSenderId: "718749886008",
|
||||
appId: "1:718749886008:web:df0563c31aaff0c2e628cd",
|
||||
measurementId: "G-D7B9CCNQ2G",
|
||||
}
|
||||
|
||||
// Initialize Firebase
|
||||
const app = !getApps().length ? initializeApp(firebaseConfig) : getApp()
|
||||
const auth = getAuth(app)
|
||||
// const analytics = getAnalytics(app); // Uncomment if you need analytics
|
||||
|
||||
export { app, auth }
|
||||
@@ -0,0 +1,150 @@
|
||||
export interface AuthNonceRequest {
|
||||
wallet_address: string
|
||||
}
|
||||
|
||||
export interface AuthNonceResponse {
|
||||
nonce: string
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface AuthVerifyRequest {
|
||||
wallet_address: string
|
||||
signature: string
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface AuthVerifyResponse {
|
||||
success: boolean
|
||||
token: string
|
||||
user: {
|
||||
wallet_address: string
|
||||
// Add other user details if available from your backend
|
||||
}
|
||||
}
|
||||
|
||||
export interface QuestionOption {
|
||||
id: string
|
||||
text: string
|
||||
}
|
||||
|
||||
export interface Question {
|
||||
id: string
|
||||
text: string
|
||||
options: QuestionOption[]
|
||||
type: string // e.g., "multiple_choice"
|
||||
}
|
||||
|
||||
export interface TestStartRequest {
|
||||
subject: string
|
||||
}
|
||||
|
||||
export interface TestStartResponse {
|
||||
session_id: string
|
||||
question: Question
|
||||
question_number: number
|
||||
total_questions: number
|
||||
}
|
||||
|
||||
export interface Feedback {
|
||||
correct: boolean
|
||||
confidence_score: number
|
||||
explanation: string
|
||||
correct_answer?: string // Optional, if backend provides it
|
||||
}
|
||||
|
||||
export interface TestAnswerRequest {
|
||||
session_id: string
|
||||
question_id: string
|
||||
answer: number // Index of the selected option
|
||||
}
|
||||
|
||||
export interface TestAnswerResponse {
|
||||
feedback: Feedback
|
||||
next_question: Question | null
|
||||
test_completed: boolean
|
||||
}
|
||||
|
||||
export interface User {
|
||||
wallet_address: string
|
||||
// Add other user details
|
||||
}
|
||||
|
||||
// New types for Course Platform
|
||||
export interface Lesson {
|
||||
id: string
|
||||
title: string
|
||||
type: "video" | "text" | "code" | "quiz"
|
||||
content: string // URL for video, markdown for text, code snippet for code
|
||||
completed: boolean
|
||||
}
|
||||
|
||||
export interface Module {
|
||||
id: string
|
||||
title: string
|
||||
lessons: Lesson[]
|
||||
}
|
||||
|
||||
export interface Course {
|
||||
id: string
|
||||
title: string
|
||||
subject: string
|
||||
description: string
|
||||
progress: number // 0-100
|
||||
modules: Module[]
|
||||
}
|
||||
|
||||
// New types for Coding Platform
|
||||
export interface CodingProblem {
|
||||
id: string
|
||||
title: string
|
||||
category: string
|
||||
difficulty: "Easy" | "Medium" | "Hard"
|
||||
description: string
|
||||
initial_code: { [key: string]: string } // e.g., { "python": "def solve():\n pass" }
|
||||
test_cases: { input: string; expected_output: string }[]
|
||||
solved: boolean
|
||||
}
|
||||
|
||||
export interface CodeExecutionResult {
|
||||
output: string
|
||||
error: string | null
|
||||
runtime: number
|
||||
correct: boolean
|
||||
}
|
||||
|
||||
// New types for Quiz Platform (reusing existing Test types)
|
||||
export interface Quiz {
|
||||
id: string
|
||||
title: string
|
||||
topic: string
|
||||
difficulty: "Easy" | "Medium" | "Hard"
|
||||
recent_performance?: number // 0-100
|
||||
}
|
||||
|
||||
export interface QuizResult {
|
||||
score: number
|
||||
total_questions: number
|
||||
correct_answers: number
|
||||
per_question_breakdown: {
|
||||
question_id: string
|
||||
correct: boolean
|
||||
explanation: string
|
||||
user_answer: string
|
||||
correct_answer: string
|
||||
}[]
|
||||
}
|
||||
|
||||
// New types for Dashboard
|
||||
export interface DashboardStats {
|
||||
total_xp: number
|
||||
courses_in_progress: number
|
||||
courses_completed: number
|
||||
coding_problems_solved: number
|
||||
quiz_accuracy: number // overall average
|
||||
coding_streak: number
|
||||
}
|
||||
|
||||
export interface ActivityData {
|
||||
date: string // YYYY-MM-DD
|
||||
count: number // Number of activities
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
Reference in New Issue
Block a user