import { createAsyncThunk } from "@reduxjs/toolkit";
import httpService from "./httpService";

export const createDB = createAsyncThunk('wooArchive/database',async (archiveData)=>{
    try {
        const { data } = await httpService.post("/wooArchive/api/v1/schema/db",archiveData)
        return data
    }catch (e) {
        return e.message;
    }
})

export const getDBStatus = createAsyncThunk('wooArchive/database/status',async ()=>{
    try {
        const { data } = await httpService.get("/wooArchive/api/v1/schema/db")
        return data
    }catch (e) {
        return e.message;
    }
})

export const switchDB = createAsyncThunk('wooArchive/database/switch',async (status)=>{
    try {
        const { data } = await httpService.post("/wooArchive/api/v1/settings/db/switch", status)
        return data
    }catch (e) {
        return e.message;
    }
})

export const getDBSwitchStatus = createAsyncThunk('wooArchive/database/switch/status',async ()=>{
    try {
        const { data } = await httpService.get("/wooArchive/api/v1/settings/db/switch")
        return data
    }catch (e) {
        return e.message;
    }
})