Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: move signature to global load and fix add a post

Nevo David9d98020be1d2
diff --git a/apps/frontend/src/components/launches/calendar.context.tsx b/apps/frontend/src/components/launches/calendar.context.tsx
index f054d22b7..785fdac58 100644
--- a/apps/frontend/src/components/launches/calendar.context.tsx
+++ b/apps/frontend/src/components/launches/calendar.context.tsx
@@ -28,6 +28,7 @@ export const CalendarContext = createContext({
currentMonth: dayjs().month(),
customer: null as string | null,
sets: [] as { name: string; id: string; content: string[] }[],
+ signature: undefined as any,
comments: [] as Array<{
date: string;
total: number;
@@ -144,11 +145,16 @@ export const CalendarWeekProvider: FC<{
revalidateOnFocus: false,
});
+ const defaultSign = useCallback(async () => {
+ return await (await fetch('/signatures/default')).json();
+ }, []);
+
const setList = useCallback(async () => {
return (await fetch('/sets')).json();
}, []);
const { data: sets, mutate } = useSWR('sets', setList);
+ const { data: sign} = useSWR('default-sign', defaultSign);
const setFiltersWrapper = useCallback(
(filters: {
@@ -211,6 +217,7 @@ export const CalendarWeekProvider: FC<{
changeDate,
comments,
sets: sets || [],
+ signature: sign,
}}
>
{children}
diff --git a/apps/frontend/src/components/launches/calendar.tsx b/apps/frontend/src/components/launches/calendar.tsx
index 3b40cf8e8..434cc5039 100644
--- a/apps/frontend/src/components/launches/calendar.tsx
+++ b/apps/frontend/src/components/launches/calendar.tsx
@@ -337,6 +337,7 @@ export const CalendarColumn: FC<{
display,
reloadCalendarView,
sets,
+ signature,
} = useCalendar();
const toaster = useToaster();
const modal = useModals();
@@ -550,7 +551,6 @@ export const CalendarColumn: FC<{
);
const addModal = useCallback(async () => {
- const signature = await (await fetch('/signatures/default')).json();
const set: any = !sets.length
? undefined
: await new Promise((resolve) => {
@@ -597,7 +597,7 @@ export const CalendarColumn: FC<{
...p,
}))}
mutate={reloadCalendarView}
- {...(signature?.id
+ {...(signature?.id && !set
? {
onlyValues: [
{
@@ -609,14 +609,13 @@ export const CalendarColumn: FC<{
date={
randomHour ? getDate.hour(Math.floor(Math.random() * 24)) : getDate
}
- {...set?.content ? {set: JSON.parse(set.content)} : {}}
+ {...(set?.content ? { set: JSON.parse(set.content) } : {})}
reopenModal={() => ({})}
/>
),
size: '80%',
- // title: `Adding posts for ${getDate.format('DD/MM/YYYY HH:mm')}`,
});
- }, [integrations, getDate, sets]);
+ }, [integrations, getDate, sets, signature]);
const openStatistics = useCallback(
(id: string) => () => {
modal.openModal({
@@ -967,7 +966,7 @@ export const Statistics = () => {
);
};
-const SetSelectionModal: FC<{
+export const SetSelectionModal: FC<{
sets: any[];
onSelect: (set: any) => void;
onContinueWithoutSet: () => void;
diff --git a/apps/frontend/src/components/launches/new.post.tsx b/apps/frontend/src/components/launches/new.post.tsx
index 5920be6b7..f1cb8c8d6 100644
--- a/apps/frontend/src/components/launches/new.post.tsx
+++ b/apps/frontend/src/components/launches/new.post.tsx
@@ -5,14 +5,47 @@ import dayjs from 'dayjs';
import { useCalendar } from '@gitroom/frontend/components/launches/calendar.context';
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
import { useT } from '@gitroom/react/translation/get.transation.service.client';
+import { SetSelectionModal } from '@gitroom/frontend/components/launches/calendar';
+import { useSet } from '@gitroom/frontend/components/launches/set.context';
export const NewPost = () => {
const fetch = useFetch();
const modal = useModals();
- const { integrations, reloadCalendarView } = useCalendar();
+ const { integrations, reloadCalendarView, sets } = useCalendar();
const t = useT();
const createAPost = useCallback(async () => {
const date = (await (await fetch('/posts/find-slot')).json()).date;
+
+ const set: any = !sets.length
+ ? undefined
+ : await new Promise((resolve) => {
+ modal.openModal({
+ title: t('select_set', 'Select a Set'),
+ closeOnClickOutside: true,
+ closeOnEscape: true,
+ withCloseButton: true,
+ onClose: () => resolve('exit'),
+ classNames: {
+ modal: 'bg-secondary text-textColor',
+ },
+ children: (
+ <SetSelectionModal
+ sets={sets}
+ onSelect={(selectedSet) => {
+ resolve(selectedSet);
+ modal.closeAll();
+ }}
+ onContinueWithoutSet={() => {
+ resolve(undefined);
+ modal.closeAll();
+ }}
+ />
+ ),
+ });
+ });
+
+ if (set === 'exit') return;
+
modal.openModal({
closeOnClickOutside: false,
closeOnEscape: false,
@@ -25,6 +58,7 @@ export const NewPost = () => {
allIntegrations={integrations.map((p) => ({
...p,
}))}
+ {...(set?.content ? { set: JSON.parse(set.content) } : {})}
reopenModal={createAPost}
mutate={reloadCalendarView}
integrations={integrations}
@@ -34,7 +68,7 @@ export const NewPost = () => {
size: '80%',
title: ``,
});
- }, [integrations]);
+ }, [integrations, sets]);
return (
<button
onClick={createAPost}
diff --git a/package.json b/package.json
index cbd0e479d..e99da8a37 100644
--- a/package.json
+++ b/package.json
@@ -40,7 +40,7 @@
"prisma-reset": "cd ./libraries/nestjs-libraries/src/database/prisma && pnpm dlx prisma db push --force-reset && npx prisma db push",
"docker-build": "./var/docker/docker-build.sh",
"docker-create": "./var/docker/docker-create.sh",
- "postinstall": "npm run update-plugins && npm run prisma-generate",
+ "postinstall": "pnpm run update-plugins && pnpm run prisma-generate",
"test": "jest --coverage --detectOpenHandles --reporters=default --reporters=jest-junit"
},
"dependencies": {