diff --git a/apps/frontend/public/icons/platforms/youtube.svg b/apps/frontend/public/icons/platforms/youtube.svg new file mode 100644 index 00000000..3bce3e61 --- /dev/null +++ b/apps/frontend/public/icons/platforms/youtube.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/frontend/src/components/launches/add.provider.component.tsx b/apps/frontend/src/components/launches/add.provider.component.tsx index 87cf37c9..740f5b3d 100644 --- a/apps/frontend/src/components/launches/add.provider.component.tsx +++ b/apps/frontend/src/components/launches/add.provider.component.tsx @@ -195,13 +195,21 @@ export const AddProviderComponent: FC<{
- + {item.identifier === 'youtube' ? ( + + ) : ( + + )}
{item.name}
diff --git a/apps/frontend/src/components/launches/helpers/pick.platform.component.tsx b/apps/frontend/src/components/launches/helpers/pick.platform.component.tsx index 8fe11bbe..08105ef8 100644 --- a/apps/frontend/src/components/launches/helpers/pick.platform.component.tsx +++ b/apps/frontend/src/components/launches/helpers/pick.platform.component.tsx @@ -56,15 +56,17 @@ export const PickPlatforms: FC<{ checkLeftRight(); }, [selectedIntegrations, integrations]); - useMoveToIntegrationListener([integrations], props.singleSelect, (identifier) => { - const findIntegration = integrations.find( - (p) => p.id === identifier - ); + useMoveToIntegrationListener( + [integrations], + props.singleSelect, + (identifier) => { + const findIntegration = integrations.find((p) => p.id === identifier); - if (findIntegration) { - addPlatform(findIntegration)(); + if (findIntegration) { + addPlatform(findIntegration)(); + } } - }); + ); const addPlatform = useCallback( (integration: Integrations) => async () => { @@ -102,7 +104,9 @@ export const PickPlatforms: FC<{ } return ( -
+
{props.singleSelect && (
{isLeft && ( @@ -138,75 +142,81 @@ export const PickPlatforms: FC<{ >
- {integrations.filter(f => !f.inBetweenSteps).map((integration) => - !props.singleSelect ? ( -
+ {integrations + .filter((f) => !f.inBetweenSteps) + .map((integration) => + !props.singleSelect ? (
p.id === integration.id - ) === -1 - ? 'opacity-40' - : '' - )} + key={integration.id} + className="flex gap-[8px] items-center mr-[10px]" > - {integration.identifier} - {integration.identifier} -
-
- ) : ( -
-
p.id === integration.id - ) === -1 - ? 'bg-third border border-third' - : 'bg-[#291259] border border-[#5826C2]' - )} - > -
-
- {integration.identifier} +
p.id === integration.id + ) === -1 + ? 'opacity-40' + : '' + )} + > + {integration.identifier} + {integration.identifier === 'youtube' ? ( + + ) : ( {integration.identifier} -
-
{integration.name}
+ )}
-
- ) - )} + ) : ( +
+
p.id === integration.id + ) === -1 + ? 'bg-third border border-third' + : 'bg-[#291259] border border-[#5826C2]' + )} + > +
+
+ {integration.identifier} + {integration.identifier} +
+
{integration.name}
+
+
+
+ ) + )}
diff --git a/apps/frontend/src/components/launches/launches.component.tsx b/apps/frontend/src/components/launches/launches.component.tsx index 2b8b1239..e54e3556 100644 --- a/apps/frontend/src/components/launches/launches.component.tsx +++ b/apps/frontend/src/components/launches/launches.component.tsx @@ -148,13 +148,21 @@ export const LaunchesComponent = () => { width={32} height={32} /> - {integration.identifier} + {integration.identifier === 'youtube' ? ( + + ) : ( + {integration.identifier} + )}
{ const { register, control } = useSettings(); return (
+
{ - if (items.length === 1) { + const [firstItems] = items; + + if (items.length !== 1) { return 'Youtube items should be one'; } @@ -145,6 +161,10 @@ export default withProvider( return 'You need one item'; } + if (firstItems[0].path.indexOf('mp4') === -1) { + return 'Item must be a video'; + } + return true; } ); diff --git a/libraries/nestjs-libraries/src/dtos/posts/providers-settings/youtube.settings.dto.ts b/libraries/nestjs-libraries/src/dtos/posts/providers-settings/youtube.settings.dto.ts index d4fd7c67..dec5f77b 100644 --- a/libraries/nestjs-libraries/src/dtos/posts/providers-settings/youtube.settings.dto.ts +++ b/libraries/nestjs-libraries/src/dtos/posts/providers-settings/youtube.settings.dto.ts @@ -1,10 +1,5 @@ import { - IsArray, - IsDefined, - IsOptional, - IsString, - MinLength, - ValidateNested, + IsArray, IsDefined, IsIn, IsOptional, IsString, MinLength, ValidateNested } from 'class-validator'; import { MediaDto } from '@gitroom/nestjs-libraries/dtos/media/media.dto'; import { Type } from 'class-transformer'; @@ -23,6 +18,10 @@ export class YoutubeSettingsDto { @IsDefined() title: string; + @IsIn(['public', 'private', 'unlisted']) + @IsDefined() + type: string; + @IsOptional() @ValidateNested() @Type(() => MediaDto) diff --git a/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts b/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts index fc2df021..782dda64 100644 --- a/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts @@ -8,8 +8,7 @@ import { import { makeId } from '@gitroom/nestjs-libraries/services/make.is'; import { google } from 'googleapis'; import { OAuth2Client } from 'google-auth-library/build/src/auth/oauth2client'; -import * as console from 'node:console'; -import axios, { all } from 'axios'; +import axios from 'axios'; import { YoutubeSettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/youtube.settings.dto'; import { SocialAbstract } from '@gitroom/nestjs-libraries/integrations/social.abstract'; import * as process from 'node:process'; @@ -45,7 +44,7 @@ const clientAndYoutube = () => { export class YoutubeProvider extends SocialAbstract implements SocialProvider { identifier = 'youtube'; - name = 'Youtube'; + name = 'YouTube'; isBetweenSteps = false; async refreshToken(refresh_token: string): Promise { @@ -152,14 +151,18 @@ export class YoutubeProvider extends SocialAbstract implements SocialProvider { title: settings.title, description: firstPost?.message, tags: settings.tags.map((p) => p.label), - thumbnails: { - default: { - url: settings?.thumbnail?.path, - }, - }, + ...(settings?.thumbnail?.path + ? { + thumbnails: { + default: { + url: settings?.thumbnail?.path, + }, + }, + } + : {}), }, status: { - privacyStatus: 'public', + privacyStatus: settings.type, }, }, media: { @@ -167,7 +170,12 @@ export class YoutubeProvider extends SocialAbstract implements SocialProvider { }, }); - console.log(all); + return [{ + id: firstPost.id, + releaseURL: `https://www.youtube.com/watch?v=${all.data.id}`, + postId: all?.data?.id!, + status: 'success', + }]; } catch (err) { console.log(err); }