All files / src/api/teacher TeacherThemesAPI.js

22.22% Statements 2/9
0% Branches 0/2
25% Functions 1/4
22.22% Lines 2/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                                              5x 3x      
import axios from "axios";
import { API_ENDPOINTS } from "@/api/endpoints";
 
export class TeacherThemesAPI {
    async getCurrentTheme() {
        const response = await axios.get(API_ENDPOINTS.teacher.account.theme.fetch);
        return response;
    }
 
    async applyTheme(themeData) {
        // themeData can be either a string (backward compatibility) or an object with theme_id and color_mode
        const payload = typeof themeData === "string" ? { theme_id: themeData } : themeData;
 
        const response = await axios.post(API_ENDPOINTS.teacher.account.theme.apply, payload);
        return response;
    }
 
    async updateTheme(themeUpdate) {
        const response = await axios.put(API_ENDPOINTS.teacher.account.theme.update, themeUpdate);
        return response;
    }
 
    async deleteTheme() {
        const response = await axios.delete(API_ENDPOINTS.teacher.account.theme.delete);
        return response;
    }
}