diff --git a/apps/web/app/orgs/[orgslug]/(withmenu)/course/[courseuuid]/course.tsx b/apps/web/app/orgs/[orgslug]/(withmenu)/course/[courseuuid]/course.tsx
index b98bb364..6adb5836 100644
--- a/apps/web/app/orgs/[orgslug]/(withmenu)/course/[courseuuid]/course.tsx
+++ b/apps/web/app/orgs/[orgslug]/(withmenu)/course/[courseuuid]/course.tsx
@@ -30,7 +30,7 @@ const CourseClient = (props: any) => {
function getLearningTags() {
// create array of learnings from a string object (comma separated)
- let learnings = course?.learnings ? course?.learnings.split(',') : []
+ let learnings = course?.learnings ? course?.learnings.split('|') : []
setLearnings(learnings)
}
diff --git a/apps/web/components/Dashboard/Pages/Course/EditCourseGeneral/EditCourseGeneral.tsx b/apps/web/components/Dashboard/Pages/Course/EditCourseGeneral/EditCourseGeneral.tsx
index e1403d1c..1c250168 100644
--- a/apps/web/components/Dashboard/Pages/Course/EditCourseGeneral/EditCourseGeneral.tsx
+++ b/apps/web/components/Dashboard/Pages/Course/EditCourseGeneral/EditCourseGeneral.tsx
@@ -10,6 +10,7 @@ import * as Form from '@radix-ui/react-form';
import React, { useEffect, useState } from 'react';
import ThumbnailUpdate from './ThumbnailUpdate';
import { useCourse, useCourseDispatch } from '@components/Contexts/CourseContext';
+import FormTagInput from '@components/Objects/StyledElements/Form/TagInput';
type EditCourseStructureProps = {
orgslug: string
@@ -138,24 +139,22 @@ function EditCourseGeneral(props: EditCourseStructureProps) {
-
+ formik.setFieldValue('learnings', value)}
+ value={formik.values.learnings}
+ />
-
+ formik.setFieldValue('tags', value)}
+ value={formik.values.tags}
+ />
diff --git a/apps/web/components/Objects/Modals/Course/Create/CreateCourse.tsx b/apps/web/components/Objects/Modals/Course/Create/CreateCourse.tsx
index f20f1490..0e7676c2 100644
--- a/apps/web/components/Objects/Modals/Course/Create/CreateCourse.tsx
+++ b/apps/web/components/Objects/Modals/Course/Create/CreateCourse.tsx
@@ -19,6 +19,7 @@ import { useFormik } from 'formik'
import * as Yup from 'yup'
import { UploadCloud, Image as ImageIcon } from 'lucide-react'
import UnsplashImagePicker from "@components/Dashboard/Pages/Course/EditCourseGeneral/UnsplashImagePicker"
+import FormTagInput from "@components/Objects/StyledElements/Form/TagInput"
const validationSchema = Yup.object().shape({
name: Yup.string()
@@ -51,15 +52,16 @@ function CreateCourseModal({ closeModal, orgslug }: any) {
validationSchema,
onSubmit: async (values, { setSubmitting }) => {
const toast_loading = toast.loading('Creating course...')
-
+
try {
const res = await createNewCourse(
orgId,
- {
- name: values.name,
- description: values.description,
- tags: values.tags,
- visibility: values.visibility
+ {
+ name: values.name,
+ description: values.description,
+ learnings: values.learnings,
+ tags: values.tags,
+ visibility: values.visibility
},
values.thumbnail,
session.data?.tokens?.access_token
@@ -123,8 +125,8 @@ function CreateCourseModal({ closeModal, orgslug }: any) {
return (
-
@@ -138,21 +140,21 @@ function CreateCourseModal({ closeModal, orgslug }: any) {
-
-
@@ -200,22 +202,34 @@ function CreateCourseModal({ closeModal, orgslug }: any) {
-
-
-
-
-
-
+
+
+ formik.setFieldValue('learnings', value)}
+ error={formik.errors.learnings}
+ />
+
+
+
+
+ formik.setFieldValue('tags', value)}
+ error={formik.errors.tags}
+ />
+
-
diff --git a/apps/web/components/Objects/StyledElements/Form/TagInput.tsx b/apps/web/components/Objects/StyledElements/Form/TagInput.tsx
new file mode 100644
index 00000000..ffd78059
--- /dev/null
+++ b/apps/web/components/Objects/StyledElements/Form/TagInput.tsx
@@ -0,0 +1,68 @@
+import React, { useState, Dispatch, SetStateAction } from 'react'
+import { Tag, TagInput } from 'emblor'
+
+interface FormTagInputProps {
+ value: string
+ onChange: (value: string) => void
+ separator?: string
+ error?: string
+ placeholder?: string
+}
+
+const FormTagInput = ({
+ value,
+ onChange,
+ separator = '|',
+ error,
+ placeholder,
+}: FormTagInputProps) => {
+ const initialTags = value
+ ? value.split(separator).map((text, i) => ({
+ id: i.toString(),
+ text: text.trim(),
+ }))
+ : []
+
+ const [tags, setTags] = useState(initialTags)
+ const [activeTagIndex, setActiveTagIndex] = useState(null)
+
+ const handleTagsChange: Dispatch> = (
+ newTagsOrUpdater
+ ) => {
+ const newTags =
+ typeof newTagsOrUpdater === 'function'
+ ? newTagsOrUpdater(tags)
+ : newTagsOrUpdater
+
+ setTags(newTags)
+ onChange(newTags.map((tag) => tag.text).join(separator))
+ }
+
+ return (
+
+ )
+}
+
+export default FormTagInput
diff --git a/apps/web/services/courses/courses.ts b/apps/web/services/courses/courses.ts
index e9796148..bdcb9c37 100644
--- a/apps/web/services/courses/courses.ts
+++ b/apps/web/services/courses/courses.ts
@@ -102,7 +102,7 @@ export async function createNewCourse(
formData.append('name', course_body.name)
formData.append('description', course_body.description)
formData.append('public', course_body.visibility)
- formData.append('learnings', course_body.tags)
+ formData.append('learnings', course_body.learnings)
formData.append('tags', course_body.tags)
formData.append('about', course_body.description)