From 1fc98e6e16d42d807bb46fdc6b6e91e30f027de5 Mon Sep 17 00:00:00 2001 From: Vojta Holik Date: Wed, 8 Jan 2025 14:43:49 +0100 Subject: [PATCH] feat(aih): edit and create lists --- .../_components/edit-list-form-metadata.tsx | 118 +++++ .../edit/_components/edit-list-form.tsx | 104 ++++ .../lists/[slug]/edit/_components/hit.tsx | 40 ++ .../edit/_components/lesson-list/data/tree.ts | 379 ++++++++++++++ .../lesson-list/pieces/tree/constants.ts | 1 + .../lesson-list/pieces/tree/tree-context.tsx | 54 ++ .../lesson-list/pieces/tree/tree-item.tsx | 463 ++++++++++++++++++ .../edit/_components/lesson-list/tree.tsx | 311 ++++++++++++ .../edit/_components/list-resources-edit.tsx | 197 ++++++++ .../_components/resources-infinite-hits.tsx | 97 ++++ .../edit/_components/selection-context.tsx | 50 ++ .../app/(content)/lists/[slug]/edit/page.tsx | 51 ++ .../lists/_components/create-list-form.tsx | 60 +++ .../lists/_components/lists-table.tsx | 58 +++ apps/ai-hero/src/app/(content)/lists/page.tsx | 33 ++ .../app/(content)/posts/[slug]/edit/page.tsx | 3 + .../posts/_components/add-to-list.tsx | 139 ++++++ .../_components/edit-post-form-metadata.tsx | 8 + .../posts/_components/edit-post-form.tsx | 5 + .../q/_components/instantsearch/searchbox.tsx | 9 +- .../pages/_components/edit-pages-form.tsx | 2 +- apps/ai-hero/src/lib/lists-query.ts | 158 ++++++ apps/ai-hero/src/lib/lists.ts | 24 + apps/ai-hero/src/lib/posts-query.ts | 16 + .../pages/_components/edit-pages-form.tsx | 2 +- .../edit-resources-form-desktop.tsx | 3 + .../panels/edit-resources-body-panel.tsx | 9 +- 27 files changed, 2387 insertions(+), 7 deletions(-) create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/edit-list-form-metadata.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/edit-list-form.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/hit.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/lesson-list/data/tree.ts create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/lesson-list/pieces/tree/constants.ts create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/lesson-list/pieces/tree/tree-context.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/lesson-list/pieces/tree/tree-item.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/lesson-list/tree.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/list-resources-edit.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/resources-infinite-hits.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/selection-context.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/[slug]/edit/page.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/_components/create-list-form.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/_components/lists-table.tsx create mode 100644 apps/ai-hero/src/app/(content)/lists/page.tsx create mode 100644 apps/ai-hero/src/app/(content)/posts/_components/add-to-list.tsx create mode 100644 apps/ai-hero/src/lib/lists-query.ts create mode 100644 apps/ai-hero/src/lib/lists.ts diff --git a/apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/edit-list-form-metadata.tsx b/apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/edit-list-form-metadata.tsx new file mode 100644 index 000000000..35a585f85 --- /dev/null +++ b/apps/ai-hero/src/app/(content)/lists/[slug]/edit/_components/edit-list-form-metadata.tsx @@ -0,0 +1,118 @@ +import * as React from 'react' +import { useRouter } from 'next/navigation' +import type { List, ListSchema } from '@/lib/lists' +import type { UseFormReturn } from 'react-hook-form' +import { z } from 'zod' + +import { VideoResource } from '@coursebuilder/core/schemas/video-resource' +import { + Button, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, + Input, + Textarea, +} from '@coursebuilder/ui' +import { useSocket } from '@coursebuilder/ui/hooks/use-socket' +import { MetadataFieldState } from '@coursebuilder/ui/resources-crud/metadata-fields/metadata-field-state' +import { MetadataFieldVisibility } from '@coursebuilder/ui/resources-crud/metadata-fields/metadata-field-visibility' +import AdvancedTagSelector from '@coursebuilder/ui/resources-crud/tag-selector' + +export const ListMetadataFormFields: React.FC<{ + form: UseFormReturn> + list: List +}> = ({ form, list }) => { + const router = useRouter() + + return ( + <> + } + /> + + ( + + Title + + A title should summarize the post and explain what it is about + clearly. + + + + + )} + /> + ( + + Slug + Short with keywords is best. + + + + )} + /> + ( + + + SEO Description ({`${field.value?.length ?? '0'} / 160`}) + + + A short snippet that summarizes the post in under 160 characters. + Keywords should be included to support SEO. + +