save current topic and small styling

This commit is contained in:
Sara
2023-12-20 11:48:46 +01:00
parent 32d272fd8c
commit a5360944d4
3 changed files with 28 additions and 9 deletions

View File

@@ -51,7 +51,7 @@ export default function TranscriptCorrect({
return ( return (
<div className="h-full grid grid-cols-2 gap-4"> <div className="h-full grid grid-cols-2 gap-4">
<div className="flex flex-col h-full"> <div className="flex flex-col h-full ">
<TopicHeader <TopicHeader
stateCurrentTopic={stateCurrentTopic} stateCurrentTopic={stateCurrentTopic}
transcriptId={transcriptId} transcriptId={transcriptId}

View File

@@ -23,9 +23,20 @@ export default function TopicHeader({
useEffect(() => { useEffect(() => {
if (!topics.loading && !currentTopic) { if (!topics.loading && !currentTopic) {
setCurrentTopic(topics?.topics?.at(0)); const sessionTopic = window.localStorage.getItem(
transcriptId + "correct",
);
console.log(sessionTopic, window.localStorage);
if (sessionTopic && topics?.topics?.find((t) => t.id == sessionTopic)) {
setCurrentTopic(topics?.topics?.find((t) => t.id == sessionTopic));
console.log("he", sessionTopic, !!sessionTopic);
} else {
setCurrentTopic(topics?.topics?.at(0));
console.log("hi");
}
} }
}, [topics.loading]); }, [topics.loading]);
// console.log(currentTopic)
const number = topics.topics?.findIndex( const number = topics.topics?.findIndex(
(topic) => topic.id == currentTopic?.id, (topic) => topic.id == currentTopic?.id,
@@ -43,6 +54,13 @@ export default function TopicHeader({
canGoNext && setCurrentTopic(topics.topics?.at(number + 1)); canGoNext && setCurrentTopic(topics.topics?.at(number + 1));
}; };
useEffect(() => {
console.log(currentTopic?.id);
currentTopic?.id &&
window.localStorage.setItem(transcriptId + "correct", currentTopic?.id);
}, [currentTopic?.id]);
const keyHandler = (e) => { const keyHandler = (e) => {
if (e.key == "ArrowLeft") { if (e.key == "ArrowLeft") {
onPrev(); onPrev();

View File

@@ -150,17 +150,18 @@ const topicWords = ({
participants.response participants.response
) { ) {
return ( return (
<div onMouseUp={onMouseUp} className="p-5 h-full w-full"> <div onMouseUp={onMouseUp} className="p-5 h-full w-full overflow-scroll">
{topicWithWords.response.wordsPerSpeaker.map( {topicWithWords.response.wordsPerSpeaker.map(
(speakerWithWords, index) => ( (speakerWithWords, index) => (
<p key={index}> <p key={index} className="mb-2 last:mb-0">
<span <span
data-speaker={speakerWithWords.speaker} data-speaker={speakerWithWords.speaker}
className={ className={`
selectedText == speakerWithWords.speaker font-semibold ${
? "bg-yellow-200" selectedText == speakerWithWords.speaker
: "" ? "bg-yellow-200"
} : ""
}`}
> >
{getSpeakerName(speakerWithWords.speaker)}&nbsp;:&nbsp; {getSpeakerName(speakerWithWords.speaker)}&nbsp;:&nbsp;
</span> </span>