From 0ed729196fe8198278f146643c6e84a55e1e73b2 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Tue, 1 Jul 2025 14:54:28 +0700 Subject: [PATCH] feat: convert to object --- .../providers/bluesky/bluesky.provider.tsx | 17 ++++--- .../providers/devto/devto.provider.tsx | 15 +++++- .../providers/discord/discord.provider.tsx | 22 +++++---- .../providers/dribbble/dribbble.provider.tsx | 17 ++++--- .../providers/facebook/facebook.provider.tsx | 15 +++++- .../providers/hashnode/hashnode.provider.tsx | 20 +++++--- .../providers/high.order.provider.tsx | 40 ++++++++++----- .../instagram/instagram.collaborators.tsx | 17 ++++--- .../providers/lemmy/lemmy.provider.tsx | 22 +++++---- .../providers/linkedin/linkedin.provider.tsx | 17 ++++--- .../providers/mastodon/mastodon.provider.tsx | 17 ++++--- .../providers/medium/medium.provider.tsx | 15 +++--- .../providers/nostr/nostr.provider.tsx | 22 +++++---- .../pinterest/pinterest.provider.tsx | 17 ++++--- .../providers/reddit/reddit.provider.tsx | 22 +++++---- .../providers/slack/slack.provider.tsx | 22 +++++---- .../providers/telegram/telegram.provider.tsx | 22 +++++---- .../providers/threads/threads.provider.tsx | 17 ++++--- .../providers/tiktok/tiktok.provider.tsx | 17 ++++--- .../new-launch/providers/vk/vk.provider.tsx | 22 +++++---- .../providers/warpcast/warpcast.provider.tsx | 17 ++++--- .../new-launch/providers/x/x.provider.tsx | 49 +++++++++++++------ .../providers/youtube/youtube.provider.tsx | 17 ++++--- 23 files changed, 291 insertions(+), 187 deletions(-) diff --git a/apps/frontend/src/components/new-launch/providers/bluesky/bluesky.provider.tsx b/apps/frontend/src/components/new-launch/providers/bluesky/bluesky.provider.tsx index de7e1f3b..8b2d7d0b 100644 --- a/apps/frontend/src/components/new-launch/providers/bluesky/bluesky.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/bluesky/bluesky.provider.tsx @@ -10,12 +10,13 @@ const SettingsComponent = () => { return ; }; -export default withProvider( - PostComment.POST, - SettingsComponent, - undefined, - undefined, - async (posts) => { +export default withProvider({ + postComment: PostComment.POST, + minimumCharacters: [], + SettingsComponent: SettingsComponent, + CustomPreviewComponent: undefined, + dto: undefined, + checkValidity: async (posts) => { if ( posts.some( (p) => p.some((a) => a.path.indexOf('mp4') > -1) && p.length > 1 @@ -29,5 +30,5 @@ export default withProvider( } return true; }, - 300 -); + maximumCharacters: 300, +}); diff --git a/apps/frontend/src/components/new-launch/providers/devto/devto.provider.tsx b/apps/frontend/src/components/new-launch/providers/devto/devto.provider.tsx index 722795a5..0f50ad88 100644 --- a/apps/frontend/src/components/new-launch/providers/devto/devto.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/devto/devto.provider.tsx @@ -1,7 +1,10 @@ 'use client'; import { FC } from 'react'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; import { DevToSettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/dev.to.settings.dto'; import { Input } from '@gitroom/react/form/input'; import { MediaComponent } from '@gitroom/frontend/components/media/media.component'; @@ -83,4 +86,12 @@ const DevtoSettings: FC = () => { ); }; -export default withProvider(PostComment.COMMENT, DevtoSettings, DevtoPreview, DevToSettingsDto); +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: DevtoSettings, + CustomPreviewComponent: DevtoPreview, + dto: DevToSettingsDto, + checkValidity: undefined, + maximumCharacters: undefined, +}); diff --git a/apps/frontend/src/components/new-launch/providers/discord/discord.provider.tsx b/apps/frontend/src/components/new-launch/providers/discord/discord.provider.tsx index 37784339..467804a6 100644 --- a/apps/frontend/src/components/new-launch/providers/discord/discord.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/discord/discord.provider.tsx @@ -1,6 +1,9 @@ 'use client'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; import { FC } from 'react'; import { DiscordDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/discord.dto'; import { DiscordChannelSelect } from '@gitroom/frontend/components/new-launch/providers/discord/discord.channel.select'; @@ -13,11 +16,12 @@ const DiscordComponent: FC = () => { ); }; -export default withProvider( - PostComment.COMMENT, - DiscordComponent, - undefined, - DiscordDto, - undefined, - 1980 -); +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: DiscordComponent, + CustomPreviewComponent: undefined, + dto: DiscordDto, + checkValidity: undefined, + maximumCharacters: 1980, +}); diff --git a/apps/frontend/src/components/new-launch/providers/dribbble/dribbble.provider.tsx b/apps/frontend/src/components/new-launch/providers/dribbble/dribbble.provider.tsx index ce05ab9a..ddc040c3 100644 --- a/apps/frontend/src/components/new-launch/providers/dribbble/dribbble.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/dribbble/dribbble.provider.tsx @@ -18,12 +18,13 @@ const DribbbleSettings: FC = () => { ); }; -export default withProvider( - PostComment.COMMENT, - DribbbleSettings, - undefined, - DribbbleDto, - async ([firstItem, ...otherItems]) => { +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: DribbbleSettings, + CustomPreviewComponent: undefined, + dto: DribbbleDto, + checkValidity: async ([firstItem, ...otherItems]) => { const isMp4 = firstItem?.find((item) => item.path.indexOf('mp4') > -1); if (firstItem.length !== 1) { return 'Requires one item'; @@ -50,5 +51,5 @@ export default withProvider( } return 'Invalid image size. Requires 400x300 or 800x600 px images.'; }, - 40000 -); + maximumCharacters: 40000, +}); diff --git a/apps/frontend/src/components/new-launch/providers/facebook/facebook.provider.tsx b/apps/frontend/src/components/new-launch/providers/facebook/facebook.provider.tsx index c33e737e..9d0e66de 100644 --- a/apps/frontend/src/components/new-launch/providers/facebook/facebook.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/facebook/facebook.provider.tsx @@ -1,4 +1,15 @@ 'use client'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; -export default withProvider(PostComment.COMMENT,null, undefined, undefined, undefined, 63206); +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: null, + CustomPreviewComponent: undefined, + dto: undefined, + checkValidity: undefined, + maximumCharacters: 63206, +}); diff --git a/apps/frontend/src/components/new-launch/providers/hashnode/hashnode.provider.tsx b/apps/frontend/src/components/new-launch/providers/hashnode/hashnode.provider.tsx index b10a41b8..2c2f6b70 100644 --- a/apps/frontend/src/components/new-launch/providers/hashnode/hashnode.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/hashnode/hashnode.provider.tsx @@ -1,7 +1,10 @@ 'use client'; import { FC } from 'react'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values'; import { Input } from '@gitroom/react/form/input'; import { HashnodePublications } from '@gitroom/frontend/components/new-launch/providers/hashnode/hashnode.publications'; @@ -85,9 +88,12 @@ const HashnodeSettings: FC = () => { ); }; -export default withProvider( - PostComment.COMMENT, - HashnodeSettings, - HashnodePreview, - HashnodeSettingsDto -); +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: HashnodeSettings, + CustomPreviewComponent: HashnodePreview, + dto: HashnodeSettingsDto, + checkValidity: undefined, + maximumCharacters: undefined, +}); diff --git a/apps/frontend/src/components/new-launch/providers/high.order.provider.tsx b/apps/frontend/src/components/new-launch/providers/high.order.provider.tsx index e4600673..6af03aa2 100644 --- a/apps/frontend/src/components/new-launch/providers/high.order.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/high.order.provider.tsx @@ -30,18 +30,25 @@ class Empty { export enum PostComment { ALL, POST, - COMMENT + COMMENT, } -export const withProvider = function ( - postComment: PostComment, +interface CharacterCondition { + format: 'no-pictures' | 'with-pictures'; + type: 'post' | 'comment'; + maximumCharacters: number; +} + +export const withProvider = function (params: { + postComment: PostComment; + minimumCharacters: CharacterCondition[]; SettingsComponent: FC<{ values?: any; - }> | null, + }> | null; CustomPreviewComponent?: FC<{ maximumCharacters?: number; - }>, - dto?: any, + }>; + dto?: any; checkValidity?: ( value: Array< Array<{ @@ -50,9 +57,18 @@ export const withProvider = function ( >, settings: T, additionalSettings: any - ) => Promise, - maximumCharacters?: number | ((settings: any) => number) -) { + ) => Promise; + maximumCharacters?: number | ((settings: any) => number); +}) { + const { + postComment, + SettingsComponent, + CustomPreviewComponent, + dto, + checkValidity, + maximumCharacters, + } = params; + return forwardRef((props: { id: string }, ref) => { const t = useT(); const fetch = useFetch(); @@ -245,7 +261,8 @@ export const withProvider = function ( )} - {(tab === 0 || (!SettingsComponent && !data?.internalPlugs?.length)) && + {(tab === 0 || + (!SettingsComponent && !data?.internalPlugs?.length)) && !value?.[0]?.content?.length && (
{t( @@ -254,7 +271,8 @@ export const withProvider = function ( )}
)} - {(tab === 0 || (!SettingsComponent && !data?.internalPlugs?.length)) && + {(tab === 0 || + (!SettingsComponent && !data?.internalPlugs?.length)) && !!value?.[0]?.content?.length && (CustomPreviewComponent ? ( ); }; -export default withProvider( - PostComment.COMMENT, - InstagramCollaborators, - undefined, - InstagramDto, - async ([firstPost, ...otherPosts], settings) => { +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: InstagramCollaborators, + CustomPreviewComponent: undefined, + dto: InstagramDto, + checkValidity: async ([firstPost, ...otherPosts], settings) => { if (!firstPost.length) { return 'Should have at least one media'; } @@ -90,5 +91,5 @@ export default withProvider( } return true; }, - 2200 -); + maximumCharacters: 2200, +}); diff --git a/apps/frontend/src/components/new-launch/providers/lemmy/lemmy.provider.tsx b/apps/frontend/src/components/new-launch/providers/lemmy/lemmy.provider.tsx index 93dcbf90..45a15e1c 100644 --- a/apps/frontend/src/components/new-launch/providers/lemmy/lemmy.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/lemmy/lemmy.provider.tsx @@ -1,7 +1,10 @@ 'use client'; import { FC, useCallback } from 'react'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values'; import { useFieldArray } from 'react-hook-form'; import { Button } from '@gitroom/react/form/button'; @@ -63,12 +66,13 @@ const LemmySettings: FC = () => { ); }; -export default withProvider( - PostComment.COMMENT, - LemmySettings, - undefined, - LemmySettingsDto, - async (items) => { +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: LemmySettings, + CustomPreviewComponent: undefined, + dto: LemmySettingsDto, + checkValidity: async (items) => { const [firstItems] = items; if ( firstItems.length && @@ -81,5 +85,5 @@ export default withProvider( } return true; }, - 10000 -); + maximumCharacters: 10000, +}); diff --git a/apps/frontend/src/components/new-launch/providers/linkedin/linkedin.provider.tsx b/apps/frontend/src/components/new-launch/providers/linkedin/linkedin.provider.tsx index d75fd54a..b4b0e07d 100644 --- a/apps/frontend/src/components/new-launch/providers/linkedin/linkedin.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/linkedin/linkedin.provider.tsx @@ -25,12 +25,13 @@ const LinkedInSettings = () => { ); }; -export default withProvider( - PostComment.COMMENT, - LinkedInSettings, - undefined, - LinkedinDto, - async (posts, vals) => { +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: LinkedInSettings, + CustomPreviewComponent: undefined, + dto: LinkedinDto, + checkValidity: async (posts, vals) => { const [firstPost, ...restPosts] = posts; if ( @@ -52,5 +53,5 @@ export default withProvider( } return true; }, - 3000 -); + maximumCharacters: 3000, +}); diff --git a/apps/frontend/src/components/new-launch/providers/mastodon/mastodon.provider.tsx b/apps/frontend/src/components/new-launch/providers/mastodon/mastodon.provider.tsx index 61d39799..73613ef9 100644 --- a/apps/frontend/src/components/new-launch/providers/mastodon/mastodon.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/mastodon/mastodon.provider.tsx @@ -4,11 +4,12 @@ import { PostComment, withProvider, } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; -export default withProvider( - PostComment.POST, - null, - undefined, - undefined, - undefined, - 500 -); +export default withProvider({ + postComment: PostComment.POST, + minimumCharacters: [], + SettingsComponent: null, + CustomPreviewComponent: undefined, + dto: undefined, + checkValidity: undefined, + maximumCharacters: 500, +}); diff --git a/apps/frontend/src/components/new-launch/providers/medium/medium.provider.tsx b/apps/frontend/src/components/new-launch/providers/medium/medium.provider.tsx index d486019b..01213875 100644 --- a/apps/frontend/src/components/new-launch/providers/medium/medium.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/medium/medium.provider.tsx @@ -66,9 +66,12 @@ const MediumSettings: FC = () => { ); }; -export default withProvider( - PostComment.COMMENT, - MediumSettings, - MediumPreview, - MediumSettingsDto -); +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: MediumSettings, + CustomPreviewComponent: MediumPreview, + dto: MediumSettingsDto, + checkValidity: undefined, + maximumCharacters: undefined, +}); diff --git a/apps/frontend/src/components/new-launch/providers/nostr/nostr.provider.tsx b/apps/frontend/src/components/new-launch/providers/nostr/nostr.provider.tsx index 8407222b..b7417d0e 100644 --- a/apps/frontend/src/components/new-launch/providers/nostr/nostr.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/nostr/nostr.provider.tsx @@ -1,13 +1,17 @@ 'use client'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; -export default withProvider( - PostComment.POST, - null, - undefined, - undefined, - async () => { +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +export default withProvider({ + postComment: PostComment.POST, + minimumCharacters: [], + SettingsComponent: null, + CustomPreviewComponent: undefined, + dto: undefined, + checkValidity: async () => { return true; }, - 100000 -); + maximumCharacters: 100000, +}); diff --git a/apps/frontend/src/components/new-launch/providers/pinterest/pinterest.provider.tsx b/apps/frontend/src/components/new-launch/providers/pinterest/pinterest.provider.tsx index 080ed92d..e628eb83 100644 --- a/apps/frontend/src/components/new-launch/providers/pinterest/pinterest.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/pinterest/pinterest.provider.tsx @@ -26,12 +26,13 @@ const PinterestSettings: FC = () => { ); }; -export default withProvider( - PostComment.COMMENT, - PinterestSettings, - undefined, - PinterestSettingsDto, - async ([firstItem, ...otherItems]) => { +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: PinterestSettings, + CustomPreviewComponent: undefined, + dto: PinterestSettingsDto, + checkValidity: async ([firstItem, ...otherItems]) => { const isMp4 = firstItem?.find((item) => item.path.indexOf('mp4') > -1); const isPicture = firstItem?.find( (item) => item.path.indexOf('mp4') === -1 @@ -76,5 +77,5 @@ export default withProvider( } return true; }, - 500 -); + maximumCharacters: 500, +}); diff --git a/apps/frontend/src/components/new-launch/providers/reddit/reddit.provider.tsx b/apps/frontend/src/components/new-launch/providers/reddit/reddit.provider.tsx index e72bcf15..98a66d20 100644 --- a/apps/frontend/src/components/new-launch/providers/reddit/reddit.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/reddit/reddit.provider.tsx @@ -1,7 +1,10 @@ 'use client'; import { FC, useCallback } from 'react'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; import { useIntegration } from '@gitroom/frontend/components/launches/helpers/use.integration'; import { Subreddit } from '@gitroom/frontend/components/new-launch/providers/reddit/subreddit'; import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values'; @@ -212,11 +215,12 @@ const RedditSettings: FC = () => { ); }; -export default withProvider( - PostComment.POST, - RedditSettings, - RedditPreview, - RedditSettingsDto, - undefined, - 10000 -); +export default withProvider({ + postComment: PostComment.POST, + minimumCharacters: [], + SettingsComponent: RedditSettings, + CustomPreviewComponent: RedditPreview, + dto: RedditSettingsDto, + checkValidity: undefined, + maximumCharacters: 10000, +}); diff --git a/apps/frontend/src/components/new-launch/providers/slack/slack.provider.tsx b/apps/frontend/src/components/new-launch/providers/slack/slack.provider.tsx index 234310b0..4507700e 100644 --- a/apps/frontend/src/components/new-launch/providers/slack/slack.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/slack/slack.provider.tsx @@ -1,6 +1,9 @@ 'use client'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; import { FC } from 'react'; import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values'; import { SlackChannelSelect } from '@gitroom/frontend/components/new-launch/providers/slack/slack.channel.select'; @@ -13,11 +16,12 @@ const SlackComponent: FC = () => { ); }; -export default withProvider( - PostComment.COMMENT, - SlackComponent, - undefined, - SlackDto, - undefined, - 280 -); +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: SlackComponent, + CustomPreviewComponent: undefined, + dto: SlackDto, + checkValidity: undefined, + maximumCharacters: 280, +}); diff --git a/apps/frontend/src/components/new-launch/providers/telegram/telegram.provider.tsx b/apps/frontend/src/components/new-launch/providers/telegram/telegram.provider.tsx index 46ac8df8..2b4a1ce9 100644 --- a/apps/frontend/src/components/new-launch/providers/telegram/telegram.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/telegram/telegram.provider.tsx @@ -1,13 +1,17 @@ 'use client'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; -export default withProvider( - PostComment.COMMENT, - null, - undefined, - undefined, - async () => { +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: null, + CustomPreviewComponent: undefined, + dto: undefined, + checkValidity: async () => { return true; }, - 4096 -); + maximumCharacters: 4096, +}); diff --git a/apps/frontend/src/components/new-launch/providers/threads/threads.provider.tsx b/apps/frontend/src/components/new-launch/providers/threads/threads.provider.tsx index eaf577e0..ed45bcaa 100644 --- a/apps/frontend/src/components/new-launch/providers/threads/threads.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/threads/threads.provider.tsx @@ -9,12 +9,13 @@ const SettingsComponent = () => { return ; }; -export default withProvider( - PostComment.POST, - SettingsComponent, - undefined, - undefined, - async ([firstPost, ...otherPosts], settings) => { +export default withProvider({ + postComment: PostComment.POST, + minimumCharacters: [], + SettingsComponent: SettingsComponent, + CustomPreviewComponent: undefined, + dto: undefined, + checkValidity: async ([firstPost, ...otherPosts], settings) => { if (!firstPost.length) { return 'Should have at least one media'; } @@ -43,5 +44,5 @@ export default withProvider( return true; }, - 500 -); + maximumCharacters: 500, +}); diff --git a/apps/frontend/src/components/new-launch/providers/tiktok/tiktok.provider.tsx b/apps/frontend/src/components/new-launch/providers/tiktok/tiktok.provider.tsx index 9a35ff92..e808c83d 100644 --- a/apps/frontend/src/components/new-launch/providers/tiktok/tiktok.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/tiktok/tiktok.provider.tsx @@ -346,12 +346,13 @@ const TikTokSettings: FC<{ ); }; -export default withProvider( - PostComment.COMMENT, - TikTokSettings, - undefined, - TikTokDto, - async (items) => { +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: TikTokSettings, + CustomPreviewComponent: undefined, + dto: TikTokDto, + checkValidity: async (items) => { const [firstItems] = items; if (items.length !== 1) { return 'Should have one item'; @@ -372,5 +373,5 @@ export default withProvider( } return true; }, - 2000 -); + maximumCharacters: 2000, +}); diff --git a/apps/frontend/src/components/new-launch/providers/vk/vk.provider.tsx b/apps/frontend/src/components/new-launch/providers/vk/vk.provider.tsx index 5850c969..e7564d59 100644 --- a/apps/frontend/src/components/new-launch/providers/vk/vk.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/vk/vk.provider.tsx @@ -1,13 +1,17 @@ 'use client'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; -export default withProvider( - PostComment.POST, - null, - undefined, - undefined, - async (posts) => { +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +export default withProvider({ + postComment: PostComment.POST, + minimumCharacters: [], + SettingsComponent: null, + CustomPreviewComponent: undefined, + dto: undefined, + checkValidity: async (posts) => { return true; }, - 2048 -); + maximumCharacters: 2048, +}); diff --git a/apps/frontend/src/components/new-launch/providers/warpcast/warpcast.provider.tsx b/apps/frontend/src/components/new-launch/providers/warpcast/warpcast.provider.tsx index e98f3d90..1d3e25ef 100644 --- a/apps/frontend/src/components/new-launch/providers/warpcast/warpcast.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/warpcast/warpcast.provider.tsx @@ -57,12 +57,13 @@ const WrapcastProvider: FC = () => { ); }; -export default withProvider( - PostComment.POST, - WrapcastProvider, - undefined, - undefined, - async (list) => { +export default withProvider({ + postComment: PostComment.POST, + minimumCharacters: [], + SettingsComponent: WrapcastProvider, + CustomPreviewComponent: undefined, + dto: undefined, + checkValidity: async (list) => { if ( list.some((item) => item.some((field) => field.path.indexOf('mp4') > -1)) ) { @@ -70,5 +71,5 @@ export default withProvider( } return true; }, - 800 -); + maximumCharacters: 800, +}); diff --git a/apps/frontend/src/components/new-launch/providers/x/x.provider.tsx b/apps/frontend/src/components/new-launch/providers/x/x.provider.tsx index 05c80512..2ddc7e71 100644 --- a/apps/frontend/src/components/new-launch/providers/x/x.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/x/x.provider.tsx @@ -1,6 +1,9 @@ 'use client'; -import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; +import { + PostComment, + withProvider, +} from '@gitroom/frontend/components/new-launch/providers/high.order.provider'; import { ThreadFinisher } from '@gitroom/frontend/components/new-launch/finisher/thread.finisher'; import { Select } from '@gitroom/react/form/select'; import { useT } from '@gitroom/react/translation/get.transation.service.client'; @@ -28,8 +31,8 @@ const whoCanReply = [ { label: 'Verified accounts', value: 'verified', - } -] + }, +]; const SettingsComponent = () => { const t = useT(); @@ -38,7 +41,10 @@ const SettingsComponent = () => { return ( <> - + ); }; -export default withProvider( - PostComment.POST, - SettingsComponent, - undefined, - XDto, - async (posts, settings, additionalSettings: any) => { - const premium = additionalSettings?.find((p: any) => p?.title === 'Verified')?.value || false; +export default withProvider({ + postComment: PostComment.POST, + minimumCharacters: [], + SettingsComponent: SettingsComponent, + CustomPreviewComponent: undefined, + dto: XDto, + checkValidity: async (posts, settings, additionalSettings: any) => { + const premium = + additionalSettings?.find((p: any) => p?.title === 'Verified')?.value || + false; if (posts.some((p) => p.length > 4)) { return 'There can be maximum 4 pictures in a post.'; } @@ -86,14 +100,17 @@ export default withProvider( } return true; }, - (settings) => { + maximumCharacters: (settings) => { if (settings?.[0]?.value) { return 4000; } return 280; - } -); -const checkVideoDuration = async (url: string, isPremium = false): Promise => { + }, +}); +const checkVideoDuration = async ( + url: string, + isPremium = false +): Promise => { return new Promise((resolve, reject) => { const video = document.createElement('video'); video.src = url; diff --git a/apps/frontend/src/components/new-launch/providers/youtube/youtube.provider.tsx b/apps/frontend/src/components/new-launch/providers/youtube/youtube.provider.tsx index a175d216..d9772d3a 100644 --- a/apps/frontend/src/components/new-launch/providers/youtube/youtube.provider.tsx +++ b/apps/frontend/src/components/new-launch/providers/youtube/youtube.provider.tsx @@ -56,12 +56,13 @@ const YoutubeSettings: FC = () => { ); }; -export default withProvider( - PostComment.COMMENT, - YoutubeSettings, - undefined, - YoutubeSettingsDto, - async (items) => { +export default withProvider({ + postComment: PostComment.COMMENT, + minimumCharacters: [], + SettingsComponent: YoutubeSettings, + CustomPreviewComponent: undefined, + dto: YoutubeSettingsDto, + checkValidity: async (items) => { const [firstItems] = items; if (items.length !== 1) { return 'Should have one item'; @@ -74,5 +75,5 @@ export default withProvider( } return true; }, - 5000 -); + maximumCharacters: 5000, +});