mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Implemented API from code generated by OpenAPI
This commit is contained in:
@@ -1,34 +1,39 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import axios from "axios";
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
||||
import { DefaultApi } from "../api/apis/DefaultApi";
|
||||
import { Configuration } from "../api/runtime";
|
||||
|
||||
const useTranscript = () => {
|
||||
const [response, setResponse] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
const apiConfiguration = new Configuration({
|
||||
basePath: process.env.NEXT_PUBLIC_API_URL,
|
||||
});
|
||||
const api = new DefaultApi(apiConfiguration);
|
||||
|
||||
const createTranscript = () => {
|
||||
setLoading(true);
|
||||
const url = API_URL + "/v1/transcripts/";
|
||||
const data = {
|
||||
name: "Weekly All-Hands", // Hardcoded for now
|
||||
const requestParameters = {
|
||||
createTranscript: {
|
||||
name: "Weekly All-Hands", // Hardcoded for now
|
||||
},
|
||||
};
|
||||
|
||||
console.debug(
|
||||
"POST - /v1/transcripts/ - Requesting new transcription creation",
|
||||
data,
|
||||
requestParameters,
|
||||
);
|
||||
|
||||
axios
|
||||
.post(url, data)
|
||||
api
|
||||
.transcriptsCreateV1TranscriptsPost(requestParameters)
|
||||
.then((result) => {
|
||||
setResponse(result.data);
|
||||
setResponse(result);
|
||||
setLoading(false);
|
||||
console.debug("New transcript created:", result.data);
|
||||
console.debug("New transcript created:", result);
|
||||
})
|
||||
.catch((err) => {
|
||||
const errorString = err.response || err || "Unknown error";
|
||||
const errorString = err.response || err.message || "Unknown error";
|
||||
setError(errorString);
|
||||
setLoading(false);
|
||||
console.error("Error creating transcript:", errorString);
|
||||
|
||||
Reference in New Issue
Block a user