+
+
+
+ {!!SettingsComponent && (
+
- {(!!SettingsComponent || !!data?.internalPlugs?.length) && (
-
-
-
- )}
- {!existingData.integration && (
-
-
-
- )}
+ )}
+
+
- )}
- {editInPlace &&
- createPortal(
-
- {uploading && (
-
-
+
+ )}
+ {editInPlace &&
+ createPortal(
+
+
+ {!existingData?.integration && (
+
+ You are now editing only {integration?.name} (
+ {capitalize(integration?.identifier.replace('-', ' '))})
)}
-
- {!existingData?.integration && (
-
- You are now editing only {integration?.name} (
- {capitalize(integration?.identifier.replace('-', ' '))})
-
- )}
- {InPlaceValue.map((val, index) => (
-
-
-
-
- {(integration?.identifier === 'linkedin' ||
- integration?.identifier ===
- 'linkedin-page') && (
-
- )}
-
(
+
+
+
+
+ {integration?.identifier === 'linkedin' && (
+
+ )}
+
1 ? 200 : 250}
+ value={val.content}
+ commands={[
+ // ...commands
+ // .getCommands()
+ // .filter((f) => f.name !== 'image'),
+ // newImage,
+ postSelector(date),
+ ...linkedinCompany(
+ integration?.identifier!,
+ integration?.id!
+ ),
+ ]}
+ preview="edit"
+ // @ts-ignore
+ onChange={changeValue(index)}
+ />
+ {(!val.content || val.content.length < 6) && (
+
+ The post should be at least 6 characters long
+
+ )}
+
+
+
-
- {(!val.content || val.content.length < 6) && (
-
- The post should be at least 6 characters long
-
- )}
-
-
-
-
-
- {InPlaceValue.length > 1 && (
-
+
+ {InPlaceValue.length > 1 && (
+
+
+ )}
-
-
-
+
+
+
-
-
- ))}
-
- ,
- document.querySelector('#renderEditor')!
- )}
- {(showTab === 0 || showTab === 2) && (
-
-
- {!!data?.internalPlugs?.length && (
-
- )}
-
+
+
+
+ ))}
+
+ ,
+ document.querySelector('#renderEditor')!
)}
- {showTab === 0 && (
-
-
- {(editInPlace ? InPlaceValue : props.value)
- .map((p) => p.content)
- .join('').length ? (
- CustomPreviewComponent ? (
-
- ) : (
-
- )
+ {(showTab === 0 || showTab === 2) && (
+
+
+
+ )}
+ {showTab === 0 && (
+
+
+ {(editInPlace ? InPlaceValue : props.value)
+ .map((p) => p.content)
+ .join('').length ? (
+ CustomPreviewComponent ? (
+
) : (
- <>No Content Yet>
- )}
-
-
- )}
-
-
- );
- }
- );
+
+ )
+ ) : (
+ <>No Content Yet>
+ )}
+
+
+ )}
+
+
+ );
+ };
};
diff --git a/apps/frontend/src/components/preview/preview.tsx b/apps/frontend/src/components/preview/preview.tsx
new file mode 100644
index 000000000..444ee6021
--- /dev/null
+++ b/apps/frontend/src/components/preview/preview.tsx
@@ -0,0 +1,61 @@
+'use client';
+
+import { GeneralPreviewComponent } from '@gitroom/frontend/components/launches/general.preview.component';
+import { IntegrationContext } from '@gitroom/frontend/components/launches/helpers/use.integration';
+import dayjs from 'dayjs';
+import { useCallback } from 'react';
+import useSWR from 'swr';
+import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
+import { LoadingComponent } from '../layout/loading';
+
+interface PreviewProps {
+ id: string;
+}
+
+export const Preview = ({ id }: PreviewProps) => {
+ const fetch = useFetch();
+
+ const getPostsMarketplace = useCallback(async () => {
+ return (await fetch(`/posts/${id}`)).json();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [id]);
+
+ const { data, isLoading, error } = useSWR(
+ `/posts/${id}`,
+ getPostsMarketplace
+ );
+
+ if (isLoading) return
;
+
+ if (!data?.posts || error)
+ return (
+
+
+ {!data?.posts ? 'No post founded.' : 'Oops! Something went wrong.'}{' '}
+
+
+ );
+
+ const post = data?.posts?.[0];
+ if (!post) return null;
+
+ return (
+
+
+
+
+
+ );
+};