mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Edit title + summary UI
This commit is contained in:
@@ -1,11 +1,43 @@
|
||||
import { useState } from "react";
|
||||
import getApi from "../../lib/getApi";
|
||||
|
||||
type TranscriptTitle = {
|
||||
protectedPath: boolean;
|
||||
title: string;
|
||||
transcriptId: string;
|
||||
};
|
||||
|
||||
const TranscriptTitle = (props: TranscriptTitle) => {
|
||||
const [currentTitle, setCurrentTitle] = useState(props.title);
|
||||
const api = getApi(props.protectedPath);
|
||||
|
||||
const updateTitle = async (newTitle: string, transcriptId: string) => {
|
||||
try {
|
||||
const updatedTranscript = await api.v1TranscriptUpdate({
|
||||
transcriptId,
|
||||
updateTranscript: {
|
||||
title: newTitle,
|
||||
},
|
||||
});
|
||||
console.log("Updated transcript:", updatedTranscript);
|
||||
} catch (err) {
|
||||
console.error("Failed to update transcript:", err);
|
||||
}
|
||||
};
|
||||
const handleClick = () => {
|
||||
const newTitle = prompt("Please enter the new title:", currentTitle);
|
||||
if (newTitle !== null) {
|
||||
setCurrentTitle(newTitle);
|
||||
updateTitle(newTitle, props.transcriptId);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<h2 className="text-2xl lg:text-4xl font-extrabold text-center mb-4">
|
||||
{props.title}
|
||||
<h2
|
||||
className="text-2xl lg:text-4xl font-extrabold text-center mb-4"
|
||||
onClick={handleClick}
|
||||
>
|
||||
{currentTitle}
|
||||
</h2>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user