feat: convert to object
This commit is contained in:
parent
019baa818c
commit
0ed729196f
|
|
@ -10,12 +10,13 @@ const SettingsComponent = () => {
|
|||
return <ThreadFinisher />;
|
||||
};
|
||||
|
||||
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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 = () => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,12 +18,13 @@ const DribbbleSettings: FC = () => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,18 +30,25 @@ class Empty {
|
|||
export enum PostComment {
|
||||
ALL,
|
||||
POST,
|
||||
COMMENT
|
||||
COMMENT,
|
||||
}
|
||||
|
||||
export const withProvider = function <T extends object>(
|
||||
postComment: PostComment,
|
||||
interface CharacterCondition {
|
||||
format: 'no-pictures' | 'with-pictures';
|
||||
type: 'post' | 'comment';
|
||||
maximumCharacters: number;
|
||||
}
|
||||
|
||||
export const withProvider = function <T extends object>(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 <T extends object>(
|
|||
>,
|
||||
settings: T,
|
||||
additionalSettings: any
|
||||
) => Promise<string | true>,
|
||||
maximumCharacters?: number | ((settings: any) => number)
|
||||
) {
|
||||
) => Promise<string | true>;
|
||||
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 <T extends object>(
|
|||
)}
|
||||
</div>
|
||||
|
||||
{(tab === 0 || (!SettingsComponent && !data?.internalPlugs?.length)) &&
|
||||
{(tab === 0 ||
|
||||
(!SettingsComponent && !data?.internalPlugs?.length)) &&
|
||||
!value?.[0]?.content?.length && (
|
||||
<div>
|
||||
{t(
|
||||
|
|
@ -254,7 +271,8 @@ export const withProvider = function <T extends object>(
|
|||
)}
|
||||
</div>
|
||||
)}
|
||||
{(tab === 0 || (!SettingsComponent && !data?.internalPlugs?.length)) &&
|
||||
{(tab === 0 ||
|
||||
(!SettingsComponent && !data?.internalPlugs?.length)) &&
|
||||
!!value?.[0]?.content?.length &&
|
||||
(CustomPreviewComponent ? (
|
||||
<CustomPreviewComponent
|
||||
|
|
|
|||
|
|
@ -53,12 +53,13 @@ const InstagramCollaborators: FC<{
|
|||
</>
|
||||
);
|
||||
};
|
||||
export default withProvider<InstagramDto>(
|
||||
PostComment.COMMENT,
|
||||
InstagramCollaborators,
|
||||
undefined,
|
||||
InstagramDto,
|
||||
async ([firstPost, ...otherPosts], settings) => {
|
||||
export default withProvider<InstagramDto>({
|
||||
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<InstagramDto>(
|
|||
}
|
||||
return true;
|
||||
},
|
||||
2200
|
||||
);
|
||||
maximumCharacters: 2200,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,12 +25,13 @@ const LinkedInSettings = () => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
export default withProvider<LinkedinDto>(
|
||||
PostComment.COMMENT,
|
||||
LinkedInSettings,
|
||||
undefined,
|
||||
LinkedinDto,
|
||||
async (posts, vals) => {
|
||||
export default withProvider<LinkedinDto>({
|
||||
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<LinkedinDto>(
|
|||
}
|
||||
return true;
|
||||
},
|
||||
3000
|
||||
);
|
||||
maximumCharacters: 3000,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,12 +26,13 @@ const PinterestSettings: FC = () => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 = () => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,12 +9,13 @@ const SettingsComponent = () => {
|
|||
return <ThreadFinisher />;
|
||||
};
|
||||
|
||||
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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -346,12 +346,13 @@ const TikTokSettings: FC<{
|
|||
</div>
|
||||
);
|
||||
};
|
||||
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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<>
|
||||
<Select
|
||||
label={t('label_who_can_reply_to_this_post', 'Who can reply to this post?')}
|
||||
label={t(
|
||||
'label_who_can_reply_to_this_post',
|
||||
'Who can reply to this post?'
|
||||
)}
|
||||
className="mb-5"
|
||||
hideErrors={true}
|
||||
{...register('who_can_reply_post', {
|
||||
|
|
@ -52,20 +58,28 @@ const SettingsComponent = () => {
|
|||
))}
|
||||
</Select>
|
||||
|
||||
<Input label={'Post to a community, URL (Ex: https://x.com/i/communities/1493446837214187523)'} {...register('community')} />
|
||||
<Input
|
||||
label={
|
||||
'Post to a community, URL (Ex: https://x.com/i/communities/1493446837214187523)'
|
||||
}
|
||||
{...register('community')}
|
||||
/>
|
||||
|
||||
<ThreadFinisher />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
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<boolean> => {
|
||||
},
|
||||
});
|
||||
const checkVideoDuration = async (
|
||||
url: string,
|
||||
isPremium = false
|
||||
): Promise<boolean> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const video = document.createElement('video');
|
||||
video.src = url;
|
||||
|
|
|
|||
|
|
@ -56,12 +56,13 @@ const YoutubeSettings: FC = () => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
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,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue