feat: env variables
This commit is contained in:
parent
f97dd52b12
commit
b0baf412f7
51
.env.example
51
.env.example
|
|
@ -1,28 +1,27 @@
|
|||
DATABASE_URL="postgres://<user>:<password>@<host>:<port>/<database_name>"
|
||||
REDIS_URL="redis://<host>:<port>"
|
||||
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=""
|
||||
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=
|
||||
|
|
@ -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: (
|
||||
<IntegrationContext.Provider
|
||||
value={{
|
||||
date: dayjs(),
|
||||
integration,
|
||||
value: [],
|
||||
}}
|
||||
>
|
||||
<PreviewPopup
|
||||
providerId={post?.providerId!}
|
||||
post={post}
|
||||
postId={post.id}
|
||||
/>
|
||||
</IntegrationContext.Provider>
|
||||
),
|
||||
});
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
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: (
|
||||
<ExistingDataContextProvider value={data}>
|
||||
<AddEditModal
|
||||
reopenModal={editPost(id)}
|
||||
reopenModal={editPost(post)}
|
||||
integrations={integrations.filter(
|
||||
(f) => 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: <AddEditModal integrations={integrations} date={getDate} reopenModal={() => ({})} />,
|
||||
children: (
|
||||
<AddEditModal
|
||||
integrations={integrations}
|
||||
date={getDate}
|
||||
reopenModal={() => ({})}
|
||||
/>
|
||||
),
|
||||
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) => {
|
|||
<CalendarItem
|
||||
date={getDate}
|
||||
state={post.state}
|
||||
editPost={editPost(post.id)}
|
||||
editPost={editPost(post)}
|
||||
post={post}
|
||||
integrations={integrations}
|
||||
/>
|
||||
|
|
@ -397,7 +456,7 @@ const CalendarItem: FC<{
|
|||
<div
|
||||
ref={dragRef}
|
||||
onClick={editPost}
|
||||
className={clsx("relative", state === 'DRAFT' && '!grayscale')}
|
||||
className={clsx('relative', state === 'DRAFT' && '!grayscale')}
|
||||
data-tooltip-id="tooltip"
|
||||
style={{ opacity }}
|
||||
data-tooltip-content={`${state === 'DRAFT' ? 'Draft: ' : ''}${
|
||||
|
|
@ -408,11 +467,7 @@ const CalendarItem: FC<{
|
|||
>
|
||||
<img
|
||||
className="w-[20px] h-[20px] rounded-full"
|
||||
src={
|
||||
integrations.find(
|
||||
(p) => p.identifier === post.integration?.providerIdentifier
|
||||
)?.picture!
|
||||
}
|
||||
src={post.integration.picture!}
|
||||
/>
|
||||
<img
|
||||
className="w-[12px] h-[12px] rounded-full absolute z-10 bottom-[0] right-0 border border-fifth"
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ export const Published: FC<{
|
|||
);
|
||||
};
|
||||
|
||||
const PreviewPopup: FC<{
|
||||
export const PreviewPopup: FC<{
|
||||
postId: string;
|
||||
providerId: string;
|
||||
post: {
|
||||
|
|
|
|||
|
|
@ -58,6 +58,21 @@ export class MessagesRepository {
|
|||
return { id };
|
||||
}
|
||||
|
||||
getOrgByOrder(orderId: string) {
|
||||
return this._orders.model.orders.findFirst({
|
||||
where: {
|
||||
id: orderId,
|
||||
},
|
||||
select: {
|
||||
messageGroup: {
|
||||
select: {
|
||||
buyerOrganizationId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getMessagesGroup(userId: string, organizationId: string) {
|
||||
return this._messagesGroup.model.messagesGroup.findMany({
|
||||
where: {
|
||||
|
|
@ -615,6 +630,7 @@ export class MessagesRepository {
|
|||
},
|
||||
data: {
|
||||
approvedSubmitForOrder: 'NO',
|
||||
submittedForOrganizationId: null,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -882,18 +898,18 @@ export class MessagesRepository {
|
|||
id: postId,
|
||||
submittedForOrder: {
|
||||
messageGroup: {
|
||||
OR: [{ sellerId: userId }, {buyerOrganizationId: orgId}],
|
||||
}
|
||||
OR: [{ sellerId: userId }, { buyerOrganizationId: orgId }],
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
organizationId: true,
|
||||
integration: {
|
||||
select: {
|
||||
providerIdentifier: true
|
||||
}
|
||||
}
|
||||
}
|
||||
providerIdentifier: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,6 +157,10 @@ export class MessagesService {
|
|||
);
|
||||
}
|
||||
|
||||
getOrgByOrder(orderId: string) {
|
||||
return this._messagesRepository.getOrgByOrder(orderId);
|
||||
}
|
||||
|
||||
getMarketplaceAvailableOffers(orgId: string, id: string) {
|
||||
return this._messagesRepository.getMarketplaceAvailableOffers(orgId, id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,14 @@ export class PostsRepository {
|
|||
|
||||
return this._post.model.post.findMany({
|
||||
where: {
|
||||
organizationId: orgId,
|
||||
OR: [
|
||||
{
|
||||
organizationId: orgId,
|
||||
},
|
||||
{
|
||||
submittedForOrganizationId: orgId,
|
||||
}
|
||||
],
|
||||
publishDate: {
|
||||
gte: startDate,
|
||||
lte: endDate,
|
||||
|
|
@ -80,11 +87,15 @@ export class PostsRepository {
|
|||
content: true,
|
||||
publishDate: true,
|
||||
releaseURL: true,
|
||||
submittedForOrganizationId: true,
|
||||
submittedForOrderId: true,
|
||||
state: true,
|
||||
integration: {
|
||||
select: {
|
||||
id: true,
|
||||
providerIdentifier: true,
|
||||
name: true,
|
||||
picture: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -280,7 +291,7 @@ export class PostsRepository {
|
|||
return { previousPost, posts };
|
||||
}
|
||||
|
||||
async submit(id: string, order: string) {
|
||||
async submit(id: string, order: string, buyerOrganizationId: string) {
|
||||
return this._post.model.post.update({
|
||||
where: {
|
||||
id,
|
||||
|
|
@ -288,6 +299,7 @@ export class PostsRepository {
|
|||
data: {
|
||||
submittedForOrderId: order,
|
||||
approvedSubmitForOrder: 'WAITING_CONFIRMATION',
|
||||
submittedForOrganizationId: buyerOrganizationId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
|
@ -331,7 +343,7 @@ export class PostsRepository {
|
|||
seller: {
|
||||
select: {
|
||||
id: true,
|
||||
account: true
|
||||
account: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -256,7 +256,8 @@ export class PostsService {
|
|||
console.log('hello');
|
||||
throw new Error('You can not add a post to this publication');
|
||||
}
|
||||
const submit = await this._postRepository.submit(id, order);
|
||||
const getOrgByOrder = await this._messagesService.getOrgByOrder(order);
|
||||
const submit = await this._postRepository.submit(id, order, getOrgByOrder?.messageGroup?.buyerOrganizationId!);
|
||||
const messageModel = await this._messagesService.createNewMessage(
|
||||
submit?.submittedForOrder?.messageGroupId || '',
|
||||
From.SELLER,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ model Organization {
|
|||
github GitHub[]
|
||||
subscription Subscription?
|
||||
Integration Integration[]
|
||||
post Post[]
|
||||
post Post[] @relation("organization")
|
||||
submittedPost Post[] @relation("submittedForOrg")
|
||||
Comments Comments[]
|
||||
notifications Notifications[]
|
||||
buyerOrganization MessagesGroup[]
|
||||
|
|
@ -224,7 +225,7 @@ model Post {
|
|||
integrationId String
|
||||
content String
|
||||
group String
|
||||
organization Organization @relation(fields: [organizationId], references: [id])
|
||||
organization Organization @relation("organization", fields: [organizationId], references: [id])
|
||||
integration Integration @relation(fields: [integrationId], references: [id])
|
||||
title String?
|
||||
description String?
|
||||
|
|
@ -237,6 +238,8 @@ model Post {
|
|||
image String?
|
||||
submittedForOrderId String?
|
||||
submittedForOrder Orders? @relation(fields: [submittedForOrderId], references: [id])
|
||||
submittedForOrganizationId String?
|
||||
submittedForOrganization Organization? @relation("submittedForOrg", fields: [submittedForOrganizationId], references: [id])
|
||||
approvedSubmitForOrder APPROVED_SUBMIT_FOR_ORDER @default(NO)
|
||||
lastMessageId String?
|
||||
lastMessage Messages? @relation(fields: [lastMessageId], references: [id])
|
||||
|
|
|
|||
Loading…
Reference in New Issue