diff --git a/app/Root/config/routes.ts b/app/Root/config/routes.ts index 7e42768..cac5c3d 100644 --- a/app/Root/config/routes.ts +++ b/app/Root/config/routes.ts @@ -81,9 +81,22 @@ const editUser: RouteConfig = { const ourWorks: RouteConfig = { index: true, path: '/our-works', - load: () => import('#views/OurWorks'), + load: () => import('#views/OurWorks/WorksList'), visibility: 'is-authenticated', }; + +const createWorks: RouteConfig = { + path: '/our-works/new', + load: () => import('#views/OurWorks/WorksForm'), + visibility: 'is-authenticated', +}; + +const editWorks: RouteConfig = { + path: '/our-works/:id/edit', + load: () => import('#views/OurWorks/WorksForm'), + visibility: 'is-authenticated', +}; + const preparedness: RouteConfig = { index: true, path: '/preparedness', @@ -128,6 +141,8 @@ const routes = { createUser, editUser, ourWorks, + createWorks, + editWorks, preparedness, dataAndReports, documents, diff --git a/app/components/EmbedPreview/index.tsx b/app/components/EmbedPreview/index.tsx new file mode 100644 index 0000000..6a6ad82 --- /dev/null +++ b/app/components/EmbedPreview/index.tsx @@ -0,0 +1,54 @@ +import { useMemo } from 'react'; +import { Container } from '@ifrc-go/ui'; +import { + _cs, + isDefined, + isNotDefined, +} from '@togglecorp/fujs'; + +import useDebouncedValue from '#hooks/useDebouncedValue'; +import { getSafeUrl } from '#utils/common'; + +import styles from './styles.module.css'; + +export interface Props { + className?: string; + url: string | undefined | null; + title?: string; + placeholder?: string; +} + +function EmbedPreview({ + className, + url, + title = 'Embed Preview', + placeholder = 'Enter a valid embed link to see a live preview', +}: Props) { + const debouncedUrl = useDebouncedValue(url, 500); + const previewUrl = useMemo(() => getSafeUrl(debouncedUrl), [debouncedUrl]); + + return ( + + {isDefined(previewUrl) && ( +