From b0baf412f7924567a36a4910f91ace4a4842259b Mon Sep 17 00:00:00 2001 From: Nevo David Date: Tue, 14 May 2024 18:22:13 +0700 Subject: [PATCH] feat: env variables --- .env.example | 51 ++++++------ .../src/components/launches/calendar.tsx | 81 ++++++++++++++++--- .../marketplace/special.message.tsx | 2 +- .../prisma/marketplace/messages.repository.ts | 28 +++++-- .../prisma/marketplace/messages.service.ts | 4 + .../database/prisma/posts/posts.repository.ts | 18 ++++- .../database/prisma/posts/posts.service.ts | 3 +- .../src/database/prisma/schema.prisma | 7 +- 8 files changed, 142 insertions(+), 52 deletions(-) diff --git a/.env.example b/.env.example index 4a475d7f..775dfe87 100644 --- a/.env.example +++ b/.env.example @@ -1,28 +1,27 @@ DATABASE_URL="postgres://:@:/" REDIS_URL="redis://:" -UPLOAD_DIRECTORY="" -NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY="" -STRIPE_PUBLISHABLE_KEY="" -STRIPE_SECRET_KEY="" -STRIPE_SIGNING_KEY="" -JWT_SECRET="" -FRONTEND_URL="http://localhost:4200" -NEXT_PUBLIC_BACKEND_URL="http://localhost:3000" -BACKEND_INTERNAL_URL="http://localhost:3000" -X_API_KEY="" -X_API_SECRET="" -LINKEDIN_CLIENT_ID="" -LINKEDIN_CLIENT_SECRET="" -REDDIT_CLIENT_ID="" -REDDIT_CLIENT_SECRET="" -GITHUB_CLIENT_ID="" -GITHUB_CLIENT_SECRET="" -RESEND_API_KEY="" -BEEHIIVE_API_KEY="" -BEEHIIVE_PUBLICATION_ID="" -NX_ADD_PLUGINS=false -CLOUDFLARE_ACCOUNT_ID="" -CLOUDFLARE_ACCESS_KEY="" -CLOUDFLARE_SECRET_ACCESS_KEY="" -CLOUDFLARE_BUCKETNAME="" -CLOUDFLARE_BUCKET_URL="" \ No newline at end of file +UPLOAD_DIRECTORY= +NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY= +JWT_SECRET= +FRONTEND_URL= +NEXT_PUBLIC_BACKEND_URL= +BACKEND_INTERNAL_URL= +X_API_KEY= +X_API_SECRET= +LINKEDIN_CLIENT_ID= +LINKEDIN_CLIENT_SECRET= +REDDIT_CLIENT_ID= +REDDIT_CLIENT_SECRET= +GITHUB_CLIENT_ID= +GITHUB_CLIENT_SECRET= +RESEND_API_KEY= +BEEHIIVE_API_KEY= +BEEHIIVE_PUBLICATION_ID= +NX_ADD_PLUGINS= +CLOUDFLARE_ACCOUNT_ID= +CLOUDFLARE_ACCESS_KEY= +CLOUDFLARE_SECRET_ACCESS_KEY= +CLOUDFLARE_BUCKETNAME= +CLOUDFLARE_BUCKET_URL= +CLOUDFLARE_REGION= +FEE_AMOUNT= \ No newline at end of file diff --git a/apps/frontend/src/components/launches/calendar.tsx b/apps/frontend/src/components/launches/calendar.tsx index 7f5a02a3..faa51302 100644 --- a/apps/frontend/src/components/launches/calendar.tsx +++ b/apps/frontend/src/components/launches/calendar.tsx @@ -1,6 +1,6 @@ 'use client'; -import { FC, useCallback, useMemo } from 'react'; +import React, { FC, useCallback, useMemo } from 'react'; import { Integrations, useCalendar, @@ -19,6 +19,9 @@ import { CommentComponent } from '@gitroom/frontend/components/launches/comments import { useSWRConfig } from 'swr'; import { useIntersectionObserver } from '@uidotdev/usehooks'; import { useToaster } from '@gitroom/react/toaster/toaster'; +import { useUser } from '@gitroom/frontend/components/layout/user.context'; +import { IntegrationContext } from '@gitroom/frontend/components/launches/helpers/use.integration'; +import { PreviewPopup } from '@gitroom/frontend/components/marketplace/special.message'; export const days = [ '', @@ -195,6 +198,7 @@ const CalendarColumn: FC<{ day: number; hour: string }> = (props) => { }; const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => { const { day, hour } = props; + const user = useUser(); const { currentWeek, currentYear, @@ -259,16 +263,65 @@ const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => { return; } - toaster.show('Can\'t change date, remove post from publication', 'warning'); + toaster.show( + "Can't change date, remove post from publication", + 'warning' + ); }, collect: (monitor) => ({ canDrop: isBeforeNow ? false : !!monitor.canDrop() && !!monitor.isOver(), }), })); + const getIntegration = useCallback(async (post: Post & { integration: Integration }) => { + console.log('hello'); + return ( + await fetch( + `/integrations/${post.integration.id}?order=${post.submittedForOrderId}`, + { + method: 'GET', + } + ) + ).json(); + }, []); + + const previewPublication = useCallback( + async (postInfo: Post & { integration: Integration }) => { + const post = await (await fetch(`/marketplace/posts/${postInfo.id}`)).json(); + + const integration = await getIntegration(postInfo); + modal.openModal({ + classNames: { + modal: 'bg-transparent text-white', + }, + size: 'auto', + withCloseButton: false, + children: ( + + + + ), + }); + }, + [] + ); + const editPost = useCallback( - (id: string) => async () => { - const data = await (await fetch(`/posts/${id}`)).json(); + (post: Post & { integration: Integration }) => async () => { + if (user?.orgId === post.submittedForOrganizationId) { + return previewPublication(post); + } + const data = await (await fetch(`/posts/${post.id}`)).json(); modal.openModal({ closeOnClickOutside: false, @@ -280,7 +333,7 @@ const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => { children: ( f.id === data.integration )} @@ -303,7 +356,13 @@ const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => { classNames: { modal: 'w-[100%] max-w-[1400px] bg-transparent text-white', }, - children: ({})} />, + children: ( + ({})} + /> + ), size: '80%', // title: `Adding posts for ${getDate.format('DD/MM/YYYY HH:mm')}`, }); @@ -341,7 +400,7 @@ const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => { @@ -397,7 +456,7 @@ const CalendarItem: FC<{
p.identifier === post.integration?.providerIdentifier - )?.picture! - } + src={post.integration.picture!} />