2024-08-07 16:02:13 -05:00
|
|
|
import React, { useEffect, useState } from "react";
|
2024-04-24 12:57:46 -05:00
|
|
|
import axios from "axios";
|
2024-03-20 14:20:45 -05:00
|
|
|
import { InputText } from "primereact/inputtext";
|
|
|
|
import { InputNumber } from "primereact/inputnumber";
|
|
|
|
import { InputSwitch } from "primereact/inputswitch";
|
|
|
|
import { Button } from "primereact/button";
|
2024-04-24 12:57:46 -05:00
|
|
|
import { Dropdown } from "primereact/dropdown";
|
2024-08-06 19:52:06 -05:00
|
|
|
import { ProgressSpinner } from "primereact/progressspinner";
|
2024-08-13 22:59:00 -05:00
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
2024-08-07 16:02:13 -05:00
|
|
|
import { useSession } from 'next-auth/react';
|
2024-08-06 19:52:06 -05:00
|
|
|
import { useNDKContext } from "@/context/NDKContext";
|
2024-07-21 19:56:55 -05:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { useToast } from "@/hooks/useToast";
|
2024-08-06 19:52:06 -05:00
|
|
|
import { useWorkshopsQuery } from "@/hooks/nostrQueries/content/useWorkshopsQuery";
|
|
|
|
import { useResourcesQuery } from "@/hooks/nostrQueries/content/useResourcesQuery";
|
|
|
|
import { useDraftsQuery } from "@/hooks/apiQueries/useDraftsQuery";
|
|
|
|
import { NDKEvent } from "@nostr-dev-kit/ndk";
|
2024-04-24 12:57:46 -05:00
|
|
|
import { parseEvent } from "@/utils/nostr";
|
|
|
|
import ContentDropdownItem from "@/components/content/dropdowns/ContentDropdownItem";
|
2024-03-20 14:20:45 -05:00
|
|
|
import 'primeicons/primeicons.css';
|
|
|
|
|
2024-08-13 22:59:00 -05:00
|
|
|
const CourseForm = ({ draft = null, isPublished = false }) => {
|
2024-03-20 14:20:45 -05:00
|
|
|
const [title, setTitle] = useState('');
|
|
|
|
const [summary, setSummary] = useState('');
|
|
|
|
const [checked, setChecked] = useState(false);
|
|
|
|
const [price, setPrice] = useState(0);
|
2024-03-25 10:23:42 -05:00
|
|
|
const [coverImage, setCoverImage] = useState('');
|
2024-04-24 12:57:46 -05:00
|
|
|
const [lessons, setLessons] = useState([{ id: uuidv4(), title: 'Select a lesson' }]);
|
2024-08-13 22:59:00 -05:00
|
|
|
const [loadingLessons, setLoadingLessons] = useState(true);
|
2024-04-24 12:57:46 -05:00
|
|
|
const [selectedLessons, setSelectedLessons] = useState([]);
|
2024-03-21 12:54:06 -05:00
|
|
|
const [topics, setTopics] = useState(['']);
|
2024-03-20 14:20:45 -05:00
|
|
|
|
2024-08-06 19:52:06 -05:00
|
|
|
const { resources, resourcesLoading, resourcesError } = useResourcesQuery();
|
|
|
|
const { workshops, workshopsLoading, workshopsError } = useWorkshopsQuery();
|
|
|
|
const { drafts, draftsLoading, draftsError } = useDraftsQuery();
|
2024-08-07 16:02:13 -05:00
|
|
|
const { data: session, status } = useSession();
|
|
|
|
const [user, setUser] = useState(null);
|
2024-08-13 16:28:25 -05:00
|
|
|
const { ndk, addSigner } = useNDKContext();
|
2024-07-21 19:56:55 -05:00
|
|
|
const router = useRouter();
|
|
|
|
const { showToast } = useToast();
|
|
|
|
|
2024-08-07 16:02:13 -05:00
|
|
|
useEffect(() => {
|
|
|
|
if (session) {
|
|
|
|
setUser(session.user);
|
|
|
|
}
|
|
|
|
}, [session]);
|
|
|
|
|
2024-08-09 14:28:57 -05:00
|
|
|
useEffect(() => {
|
2024-08-13 22:59:00 -05:00
|
|
|
const fetchLessons = async () => {
|
2024-08-13 23:15:40 -05:00
|
|
|
if (draft && draft?.resources) {
|
2024-08-13 22:59:00 -05:00
|
|
|
const parsedLessons = await Promise.all(
|
|
|
|
draft.resources.map(async (lesson) => {
|
|
|
|
const parsedLesson = await fetchLessonEventFromNostr(lesson.noteId);
|
|
|
|
return parsedLesson;
|
|
|
|
})
|
|
|
|
);
|
2024-08-13 23:15:40 -05:00
|
|
|
setSelectedLessons(parsedLessons);
|
2024-08-13 22:59:00 -05:00
|
|
|
setLoadingLessons(false); // Data is loaded
|
|
|
|
} else {
|
|
|
|
setLoadingLessons(false); // No draft means no lessons to load
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
fetchLessons();
|
|
|
|
}, [draft]);
|
|
|
|
|
|
|
|
const fetchLessonEventFromNostr = async (eventId) => {
|
|
|
|
try {
|
|
|
|
await ndk.connect();
|
|
|
|
|
|
|
|
const fetchedEvent = await ndk.fetchEvent(eventId);
|
|
|
|
|
|
|
|
if (fetchedEvent) {
|
|
|
|
const parsedEvent = parseEvent(fetchedEvent);
|
|
|
|
return parsedEvent;
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
showToast('error', 'Error', `Failed to fetch lesson: ${eventId}`);
|
|
|
|
}
|
|
|
|
}
|
2024-08-09 14:28:57 -05:00
|
|
|
|
2024-08-13 22:59:00 -05:00
|
|
|
useEffect(() => {
|
|
|
|
if (draft) {
|
|
|
|
console.log('draft:', draft);
|
|
|
|
setTitle(draft.title);
|
|
|
|
setSummary(draft.summary);
|
|
|
|
setChecked(draft.price > 0);
|
|
|
|
setPrice(draft.price || 0);
|
|
|
|
setCoverImage(draft.image);
|
2024-08-13 23:15:40 -05:00
|
|
|
// setSelectedLessons(draft.resources || []);
|
2024-08-13 22:59:00 -05:00
|
|
|
setTopics(draft.topics || ['']);
|
|
|
|
}
|
|
|
|
}, [draft]);
|
|
|
|
|
|
|
|
const handleSubmit = async (e) => {
|
2024-03-20 14:20:45 -05:00
|
|
|
e.preventDefault();
|
2024-04-28 17:00:58 -05:00
|
|
|
|
2024-08-13 16:28:25 -05:00
|
|
|
if (!ndk.signer) {
|
|
|
|
await addSigner();
|
|
|
|
}
|
|
|
|
|
2024-08-09 14:28:57 -05:00
|
|
|
// Prepare the lessons from selected lessons
|
|
|
|
const resources = await Promise.all(selectedLessons.map(async (lesson) => {
|
|
|
|
if (lesson?.type) {
|
|
|
|
const event = createLessonEvent(lesson);
|
|
|
|
const published = await event.publish();
|
2024-04-28 17:00:58 -05:00
|
|
|
|
2024-08-09 14:28:57 -05:00
|
|
|
if (!published) {
|
|
|
|
throw new Error(`Failed to publish lesson: ${lesson.title}`);
|
2024-07-22 16:11:46 -05:00
|
|
|
}
|
2024-08-09 14:28:57 -05:00
|
|
|
|
|
|
|
const resource = await axios.post('/api/resources', {
|
|
|
|
id: event.tags.find(tag => tag[0] === 'd')[1],
|
|
|
|
userId: user.id,
|
|
|
|
price: lesson.price || 0,
|
|
|
|
noteId: event.id,
|
2024-07-29 17:26:49 -05:00
|
|
|
});
|
2024-04-28 17:00:58 -05:00
|
|
|
|
2024-08-09 14:28:57 -05:00
|
|
|
if (resource.status !== 201) {
|
|
|
|
throw new Error(`Failed to post resource: ${lesson.title}`);
|
|
|
|
}
|
2024-08-06 19:52:06 -05:00
|
|
|
|
2024-08-09 14:28:57 -05:00
|
|
|
const deleted = await axios.delete(`/api/drafts/${lesson.id}`);
|
2024-07-20 10:51:16 -05:00
|
|
|
|
2024-08-09 14:28:57 -05:00
|
|
|
if (deleted.status !== 204) {
|
|
|
|
throw new Error(`Failed to delete draft: ${lesson.title}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
id: lesson.id,
|
|
|
|
userId: user.id,
|
|
|
|
price: lesson.price || 0,
|
|
|
|
noteId: event.id,
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return {
|
|
|
|
id: lesson.d,
|
|
|
|
userId: user.id,
|
|
|
|
price: lesson.price || 0,
|
|
|
|
noteId: lesson.id,
|
|
|
|
}
|
2024-07-20 10:51:16 -05:00
|
|
|
}
|
2024-08-09 14:28:57 -05:00
|
|
|
}));
|
2024-07-22 16:11:46 -05:00
|
|
|
|
2024-08-09 14:28:57 -05:00
|
|
|
const payload = {
|
2024-08-13 23:15:40 -05:00
|
|
|
user: {
|
|
|
|
connect: { id: user.id },
|
|
|
|
},
|
2024-08-09 14:28:57 -05:00
|
|
|
title,
|
|
|
|
summary,
|
|
|
|
image: coverImage,
|
|
|
|
price: price || 0,
|
2024-08-13 23:15:40 -05:00
|
|
|
resources: {
|
|
|
|
set: resources.map(resource => ({ id: resource.id })),
|
|
|
|
},
|
2024-08-13 22:59:00 -05:00
|
|
|
topics,
|
2024-08-13 23:15:40 -05:00
|
|
|
};
|
2024-08-09 14:28:57 -05:00
|
|
|
|
|
|
|
try {
|
2024-08-13 22:59:00 -05:00
|
|
|
let response;
|
|
|
|
if (draft) {
|
2024-08-13 23:15:40 -05:00
|
|
|
// payload minus topics
|
|
|
|
delete payload.topics
|
2024-08-13 22:59:00 -05:00
|
|
|
response = await axios.put(`/api/courses/drafts/${draft.id}`, payload);
|
|
|
|
showToast('success', 'Success', 'Course draft updated successfully');
|
|
|
|
} else {
|
|
|
|
response = await axios.post('/api/courses/drafts', payload);
|
|
|
|
showToast('success', 'Success', 'Course draft saved successfully');
|
|
|
|
}
|
2024-08-09 14:28:57 -05:00
|
|
|
router.push(`/course/${response.data.id}/draft`);
|
2024-07-22 16:11:46 -05:00
|
|
|
} catch (error) {
|
2024-08-09 14:28:57 -05:00
|
|
|
console.error('Error saving course draft:', error);
|
|
|
|
showToast('error', 'Failed to save course draft. Please try again.');
|
2024-04-28 17:00:58 -05:00
|
|
|
}
|
2024-04-24 12:57:46 -05:00
|
|
|
};
|
2024-03-20 14:20:45 -05:00
|
|
|
|
2024-08-13 22:59:00 -05:00
|
|
|
const handlePublishedCourse = async (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if (!ndk.signer) {
|
|
|
|
await addSigner();
|
|
|
|
}
|
|
|
|
|
|
|
|
const event = new NDKEvent(ndk);
|
|
|
|
event.kind = price > 0 ? 30402 : 30023;
|
|
|
|
event.content = JSON.stringify({
|
|
|
|
title,
|
|
|
|
summary,
|
|
|
|
image: coverImage,
|
|
|
|
resources: selectedLessons.map(lesson => lesson.id),
|
|
|
|
});
|
|
|
|
event.tags = [
|
|
|
|
['d', draft.id],
|
|
|
|
['title', title],
|
|
|
|
['summary', summary],
|
|
|
|
['image', coverImage],
|
|
|
|
...topics.map(topic => ['t', topic]),
|
|
|
|
['published_at', Math.floor(Date.now() / 1000).toString()],
|
|
|
|
['price', price.toString()],
|
|
|
|
];
|
|
|
|
|
|
|
|
try {
|
|
|
|
const published = await ndk.publish(event);
|
|
|
|
|
|
|
|
if (published) {
|
|
|
|
const response = await axios.put(`/api/courses/${draft.id}`, { noteId: event.id });
|
|
|
|
showToast('success', 'Success', 'Course published successfully');
|
|
|
|
router.push(`/course/${event.id}`);
|
|
|
|
} else {
|
|
|
|
showToast('error', 'Error', 'Failed to publish course. Please try again.');
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error('Error publishing course:', error);
|
|
|
|
showToast('error', 'Failed to publish course. Please try again.');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-08-06 19:52:06 -05:00
|
|
|
const createLessonEvent = (lesson) => {
|
|
|
|
const event = new NDKEvent(ndk);
|
|
|
|
event.kind = lesson.price ? 30402 : 30023;
|
|
|
|
event.content = lesson.content;
|
|
|
|
event.tags = [
|
2024-07-22 16:11:46 -05:00
|
|
|
['d', lesson.id],
|
|
|
|
['title', lesson.title],
|
|
|
|
['summary', lesson.summary],
|
|
|
|
['image', lesson.image],
|
|
|
|
...lesson.topics.map(topic => ['t', topic]),
|
|
|
|
['published_at', Math.floor(Date.now() / 1000).toString()],
|
2024-08-06 19:52:06 -05:00
|
|
|
];
|
|
|
|
return event;
|
|
|
|
};
|
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
const handleLessonChange = (e, index) => {
|
|
|
|
const selectedLessonId = e.value;
|
|
|
|
const selectedLesson = getContentOptions(index).flatMap(group => group.items).find(lesson => lesson.value === selectedLessonId);
|
2024-04-24 14:30:40 -05:00
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
const updatedLessons = lessons.map((lesson, i) =>
|
|
|
|
i === index ? { ...lesson, id: selectedLessonId, title: selectedLesson.label.props.content.title } : lesson
|
|
|
|
);
|
|
|
|
setLessons(updatedLessons);
|
2024-03-21 12:54:06 -05:00
|
|
|
};
|
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
const handleLessonSelect = (content) => {
|
|
|
|
setSelectedLessons([...selectedLessons, content]);
|
|
|
|
addLesson();
|
2024-03-21 12:54:06 -05:00
|
|
|
};
|
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
const addLesson = () => {
|
|
|
|
setLessons([...lessons, { id: uuidv4(), title: 'Select a lesson' }]);
|
2024-03-21 12:54:06 -05:00
|
|
|
};
|
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
const removeLesson = (index) => {
|
|
|
|
const updatedLessons = lessons.filter((_, i) => i !== index);
|
|
|
|
const updatedSelectedLessons = selectedLessons.filter((_, i) => i !== index);
|
2024-04-24 14:30:40 -05:00
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
if (updatedLessons.length === 0) {
|
|
|
|
updatedLessons.push({ id: uuidv4(), title: 'Select a lesson' });
|
|
|
|
}
|
2024-04-24 14:30:40 -05:00
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
setLessons(updatedLessons);
|
|
|
|
setSelectedLessons(updatedSelectedLessons);
|
2024-03-21 12:54:06 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
const addTopic = () => {
|
2024-04-24 12:57:46 -05:00
|
|
|
setTopics([...topics, '']);
|
2024-03-21 12:54:06 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
const removeTopic = (index) => {
|
|
|
|
const updatedTopics = topics.filter((_, i) => i !== index);
|
|
|
|
setTopics(updatedTopics);
|
|
|
|
};
|
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
const handleTopicChange = (index, value) => {
|
|
|
|
const updatedTopics = topics.map((topic, i) => i === index ? value : topic);
|
|
|
|
setTopics(updatedTopics);
|
|
|
|
};
|
|
|
|
|
|
|
|
const getContentOptions = (index) => {
|
2024-08-06 19:52:06 -05:00
|
|
|
if (resourcesLoading || !resources || workshopsLoading || !workshops || draftsLoading || !drafts) {
|
|
|
|
return [];
|
|
|
|
}
|
2024-04-24 12:57:46 -05:00
|
|
|
const draftOptions = drafts.map(draft => ({
|
|
|
|
label: <ContentDropdownItem content={draft} onSelect={(content) => handleLessonSelect(content, index)} selected={lessons[index] && lessons[index].id === draft.id} />,
|
|
|
|
value: draft.id
|
|
|
|
}));
|
2024-04-24 14:30:40 -05:00
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
const resourceOptions = resources.map(resource => {
|
2024-07-22 16:11:46 -05:00
|
|
|
const { id, kind, pubkey, content, title, summary, image, published_at, d, topics } = parseEvent(resource);
|
2024-04-24 12:57:46 -05:00
|
|
|
return {
|
2024-07-22 16:11:46 -05:00
|
|
|
label: <ContentDropdownItem content={{ id, kind, pubkey, content, title, summary, image, published_at, d, topics }} onSelect={(content) => handleLessonSelect(content, index)} selected={lessons[index] && lessons[index].id === id} />,
|
2024-04-24 12:57:46 -05:00
|
|
|
value: id
|
|
|
|
};
|
|
|
|
});
|
2024-04-24 14:30:40 -05:00
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
const workshopOptions = workshops.map(workshop => {
|
2024-07-22 16:11:46 -05:00
|
|
|
const { id, kind, pubkey, content, title, summary, image, published_at, d, topics } = parseEvent(workshop);
|
2024-04-24 12:57:46 -05:00
|
|
|
return {
|
2024-07-22 16:11:46 -05:00
|
|
|
label: <ContentDropdownItem content={{ id, kind, pubkey, content, title, summary, image, published_at, d, topics }} onSelect={(content) => handleLessonSelect(content, index)} selected={lessons[index] && lessons[index].id === id} />,
|
2024-04-24 12:57:46 -05:00
|
|
|
value: id
|
|
|
|
};
|
|
|
|
});
|
2024-04-24 14:30:40 -05:00
|
|
|
|
2024-04-24 12:57:46 -05:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: 'Drafts',
|
|
|
|
items: draftOptions
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Resources',
|
|
|
|
items: resourceOptions
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Workshops',
|
|
|
|
items: workshopOptions
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-08-06 19:52:06 -05:00
|
|
|
// const lessonOptions = getContentOptions();
|
2024-08-13 22:59:00 -05:00
|
|
|
if (loadingLessons || resourcesLoading || workshopsLoading || draftsLoading) {
|
2024-08-06 19:52:06 -05:00
|
|
|
return <ProgressSpinner />;
|
|
|
|
}
|
2024-04-24 12:57:46 -05:00
|
|
|
|
2024-03-20 14:20:45 -05:00
|
|
|
return (
|
2024-08-13 22:59:00 -05:00
|
|
|
<form onSubmit={isPublished ? handlePublishedCourse : handleSubmit}>
|
2024-03-20 14:20:45 -05:00
|
|
|
<div className="p-inputgroup flex-1">
|
|
|
|
<InputText value={title} onChange={(e) => setTitle(e.target.value)} placeholder="Title" />
|
|
|
|
</div>
|
2024-07-21 17:02:40 -05:00
|
|
|
<div className="p-inputgroup flex-1 mt-4">
|
2024-03-20 14:20:45 -05:00
|
|
|
<InputText value={summary} onChange={(e) => setSummary(e.target.value)} placeholder="Summary" />
|
|
|
|
</div>
|
2024-07-21 17:02:40 -05:00
|
|
|
<div className="p-inputgroup flex-1 mt-4">
|
2024-03-25 10:23:42 -05:00
|
|
|
<InputText value={coverImage} onChange={(e) => setCoverImage(e.target.value)} placeholder="Cover Image URL" />
|
|
|
|
</div>
|
2024-07-21 17:02:40 -05:00
|
|
|
<div className="p-inputgroup flex-1 mt-4 flex-col">
|
2024-03-20 14:20:45 -05:00
|
|
|
<p className="py-2">Paid Course</p>
|
|
|
|
<InputSwitch checked={checked} onChange={(e) => setChecked(e.value)} />
|
2024-04-24 12:57:46 -05:00
|
|
|
{checked && (
|
|
|
|
<div className="p-inputgroup flex-1 py-4">
|
|
|
|
<InputNumber value={price} onValueChange={(e) => setPrice(e.value)} placeholder="Price (sats)" />
|
|
|
|
</div>
|
|
|
|
)}
|
2024-03-20 14:20:45 -05:00
|
|
|
</div>
|
2024-03-21 12:54:06 -05:00
|
|
|
<div className="mt-8 flex-col w-full">
|
2024-07-21 17:02:40 -05:00
|
|
|
<div className="mt-4 flex-col w-full">
|
2024-08-13 23:15:40 -05:00
|
|
|
{selectedLessons.map((lesson, index) => {
|
2024-08-13 22:59:00 -05:00
|
|
|
return (
|
2024-07-21 17:02:40 -05:00
|
|
|
<div key={lesson.id} className="p-inputgroup flex-1 mt-4">
|
2024-04-24 12:57:46 -05:00
|
|
|
<ContentDropdownItem content={lesson} selected={true} />
|
|
|
|
<Button icon="pi pi-times" className="p-button-danger" onClick={() => removeLesson(index)} />
|
|
|
|
</div>
|
2024-08-13 22:59:00 -05:00
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
2024-04-24 12:57:46 -05:00
|
|
|
{lessons.map((lesson, index) => (
|
2024-07-21 17:02:40 -05:00
|
|
|
<div key={lesson.id} className="p-inputgroup flex-1 mt-4">
|
2024-04-24 12:57:46 -05:00
|
|
|
<Dropdown
|
|
|
|
value={lesson.title}
|
|
|
|
options={getContentOptions(index)}
|
|
|
|
onChange={(e) => handleLessonChange(e, index)}
|
|
|
|
placeholder="Select a Lesson"
|
|
|
|
itemTemplate={(option) => option.label}
|
|
|
|
optionLabel="label"
|
|
|
|
optionGroupLabel="label"
|
|
|
|
optionGroupChildren="items"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
))}
|
2024-03-20 14:20:45 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-07-21 17:02:40 -05:00
|
|
|
<div className="mt-4 flex-col w-full">
|
2024-03-21 12:54:06 -05:00
|
|
|
{topics.map((topic, index) => (
|
2024-07-21 17:02:40 -05:00
|
|
|
<div key={index} className="p-inputgroup flex-1 mt-4">
|
2024-04-24 12:57:46 -05:00
|
|
|
<InputText value={topic} onChange={(e) => handleTopicChange(index, e.target.value)} placeholder={`Topic #${index + 1}`} className="w-full" />
|
2024-03-21 12:54:06 -05:00
|
|
|
{index > 0 && (
|
|
|
|
<Button icon="pi pi-times" className="p-button-danger mt-2" onClick={() => removeTopic(index)} />
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
))}
|
2024-04-24 12:57:46 -05:00
|
|
|
<Button type="button" icon="pi pi-plus" onClick={addTopic} className="p-button-outlined mt-2" />
|
2024-03-21 12:54:06 -05:00
|
|
|
</div>
|
2024-03-20 14:20:45 -05:00
|
|
|
<div className="flex justify-center mt-8">
|
2024-08-13 22:59:00 -05:00
|
|
|
<Button type="submit" label={draft ? (isPublished ? "Publish" : "Update") : "Submit"} className="p-button-raised p-button-success" />
|
2024-03-20 14:20:45 -05:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-07-22 16:11:46 -05:00
|
|
|
export default CourseForm;
|