Skip to content

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

feat: fixing date

Nevo Davidaab1ef1c3a42
diff --git a/apps/backend/src/api/routes/posts.controller.ts b/apps/backend/src/api/routes/posts.controller.ts
index c13c614a4..8814a6b03 100644
--- a/apps/backend/src/api/routes/posts.controller.ts
+++ b/apps/backend/src/api/routes/posts.controller.ts
@@ -53,8 +53,7 @@ export class PostsController {
this._commentsService.getAllCommentsByWeekYear(
org.id,
query.year,
- query.week,
- query.isIsoWeek === 'true'
+ query.week
),
]);
diff --git a/apps/frontend/src/components/launches/calendar.context.tsx b/apps/frontend/src/components/launches/calendar.context.tsx
index 0105bda94..3d625ad89 100644
--- a/apps/frontend/src/components/launches/calendar.context.tsx
+++ b/apps/frontend/src/components/launches/calendar.context.tsx
@@ -109,8 +109,7 @@ export const CalendarWeekProvider: FC<{
const params = useMemo(() => {
return new URLSearchParams({
week: filters.currentWeek.toString(),
- year: filters.currentYear.toString(),
- isIsoWeek: isIsoWeek.toString(),
+ year: filters.currentYear.toString()
}).toString();
}, [filters]);
diff --git a/apps/frontend/src/components/launches/calendar.tsx b/apps/frontend/src/components/launches/calendar.tsx
index c24d49234..bdba443e4 100644
--- a/apps/frontend/src/components/launches/calendar.tsx
+++ b/apps/frontend/src/components/launches/calendar.tsx
@@ -144,44 +144,44 @@ export const Calendar = () => {
);
};
+// export const CalendarColumn: FC<{ day: number; hour: string }> = (props) => {
+// const { day, hour } = props;
+// const { currentWeek, currentYear } = useCalendar();
+//
+// const getDate = useMemo(() => {
+// const date =
+// dayjs()
+// .year(currentYear)
+// .isoWeek(currentWeek)
+// .isoWeekday(day)
+// .format('YYYY-MM-DD') +
+// 'T' +
+// hour +
+// ':00';
+// return dayjs(date);
+// }, [currentWeek]);
+//
+// const isBeforeNow = useMemo(() => {
+// return getDate.isBefore(dayjs());
+// }, [getDate]);
+//
+// const [ref, entry] = useIntersectionObserver({
+// threshold: 0.5,
+// root: null,
+// rootMargin: '0px',
+// });
+//
+// return (
+// <div className="w-full h-full" ref={ref}>
+// {!entry?.isIntersecting ? (
+// <div />
+// ) : (
+// <CalendarColumnRender {...props} />
+// )}
+// </div>
+// );
+// };
export const CalendarColumn: FC<{ day: number; hour: string }> = (props) => {
- const { day, hour } = props;
- const { currentWeek, currentYear } = useCalendar();
-
- const getDate = useMemo(() => {
- const date =
- dayjs()
- .year(currentYear)
- .isoWeek(currentWeek)
- .isoWeekday(day)
- .format('YYYY-MM-DD') +
- 'T' +
- hour +
- ':00';
- return dayjs(date);
- }, [currentWeek]);
-
- const isBeforeNow = useMemo(() => {
- return getDate.isBefore(dayjs());
- }, [getDate]);
-
- const [ref, entry] = useIntersectionObserver({
- threshold: 0.5,
- root: null,
- rootMargin: '0px',
- });
-
- return (
- <div className="w-full h-full" ref={ref}>
- {!entry?.isIntersecting ? (
- <div />
- ) : (
- <CalendarColumnRender {...props} />
- )}
- </div>
- );
-};
-const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => {
const { day, hour } = props;
const user = useUser();
const {
@@ -201,12 +201,13 @@ const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => {
const date =
dayjs()
.year(currentYear)
- .isoWeek(currentWeek)
- .isoWeekday(day)
+ .week(currentWeek)
+ .day(day + 1)
.format('YYYY-MM-DD') +
'T' +
hour +
':00';
+
return dayjs(date);
}, [currentWeek]);
@@ -311,6 +312,7 @@ const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => {
return previewPublication(post);
}
const data = await (await fetch(`/posts/${post.id}`)).json();
+ const publishDate = dayjs.utc(data.posts[0].publishDate).local();
modal.openModal({
closeOnClickOutside: false,
@@ -327,7 +329,7 @@ const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => {
.slice(0)
.filter((f) => f.id === data.integration)
.map((p) => ({ ...p, picture: data.integrationPicture }))}
- date={getDate}
+ date={publishDate}
/>
</ExistingDataContextProvider>
),
@@ -361,7 +363,7 @@ const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => {
const addProvider = useAddProvider();
return (
- <div className="relative flex flex-col w-full min-h-full">
+ <div className={clsx("relative flex flex-col w-full min-h-full", canDrop && 'bg-white/80')} ref={drop}>
<div
{...(canBeTrending
? {
@@ -369,11 +371,9 @@ const CalendarColumnRender: FC<{ day: number; hour: string }> = (props) => {
'data-tooltip-content': 'Predicted GitHub Trending Change',
}
: {})}
- ref={drop}
className={clsx(
- 'flex-col flex-1 text-[12px] pointer w-full overflow-hidden justify-center overflow-x-auto flex scrollbar scrollbar-thumb-tableBorder scrollbar-track-secondary',
+ 'flex-col flex-1 text-[12px] pointer w-full cursor-pointer overflow-hidden justify-center overflow-x-auto flex scrollbar scrollbar-thumb-tableBorder scrollbar-track-secondary',
isBeforeNow && 'bg-customColor23',
- canDrop && 'bg-white/80',
canBeTrending && 'bg-customColor24'
)}
>
diff --git a/apps/frontend/src/components/launches/new.calendar.component.tsx b/apps/frontend/src/components/launches/new.calendar.component.tsx
index 63dae17fa..720443d66 100644
--- a/apps/frontend/src/components/launches/new.calendar.component.tsx
+++ b/apps/frontend/src/components/launches/new.calendar.component.tsx
@@ -1,6 +1,4 @@
'use client';
-import { ChevronLeft, ChevronRight, Plus } from 'lucide-react';
-import { Button } from '@gitroom/react/form/button';
import { Fragment } from 'react';
import { CalendarColumn } from '@gitroom/frontend/components/launches/calendar';
import { DNDProvider } from '@gitroom/frontend/components/launches/helpers/dnd.provider';
diff --git a/libraries/nestjs-libraries/src/database/prisma/comments/comments.repository.ts b/libraries/nestjs-libraries/src/database/prisma/comments/comments.repository.ts
index 58230c0c1..655ed7a8a 100644
--- a/libraries/nestjs-libraries/src/database/prisma/comments/comments.repository.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/comments/comments.repository.ts
@@ -116,10 +116,9 @@ export class CommentsRepository {
orgId: string,
year: number,
week: number,
- isIsoWeek: boolean
) {
const dateYear = dayjs().year(year);
- const date = isIsoWeek ? dateYear.isoWeek(week) : dateYear.week(week);
+ const date = dateYear.isoWeek(week);
const startDate = date.startOf('isoWeek').subtract(2, 'days').toDate();
const endDate = date.endOf('isoWeek').add(2, 'days').toDate();
diff --git a/libraries/nestjs-libraries/src/database/prisma/comments/comments.service.ts b/libraries/nestjs-libraries/src/database/prisma/comments/comments.service.ts
index 85b4c7556..7882a01eb 100644
--- a/libraries/nestjs-libraries/src/database/prisma/comments/comments.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/comments/comments.service.ts
@@ -44,7 +44,7 @@ export class CommentsService {
);
}
- getAllCommentsByWeekYear(orgId: string, year: number, week: number, isIsoWeek: boolean) {
- return this._commentsRepository.getAllCommentsByWeekYear(orgId, year, week, isIsoWeek);
+ getAllCommentsByWeekYear(orgId: string, year: number, week: number) {
+ return this._commentsRepository.getAllCommentsByWeekYear(orgId, year, week);
}
}
diff --git a/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts b/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts
index 70b86ed41..e5931498e 100644
--- a/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts
@@ -64,10 +64,10 @@ export class PostsRepository {
getPosts(orgId: string, query: GetPostsDto) {
const dateYear = dayjs().year(query.year);
- const date = query.isIsoWeek === 'true' ? dateYear.isoWeek(query.week) : dateYear.week(query.week);
+ const date = dateYear.isoWeek(query.week);
- const startDate = date.startOf('week').subtract(2, 'days').toDate();
- const endDate = date.endOf('week').add(2, 'days').toDate();
+ const startDate = date.startOf('isoWeek').subtract(2, 'days').toDate();
+ const endDate = date.endOf('isoWeek').add(2, 'days').toDate();
return this._post.model.post.findMany({
where: {
diff --git a/libraries/nestjs-libraries/src/dtos/posts/get.posts.dto.ts b/libraries/nestjs-libraries/src/dtos/posts/get.posts.dto.ts
index 557f551d5..4872a7873 100644
--- a/libraries/nestjs-libraries/src/dtos/posts/get.posts.dto.ts
+++ b/libraries/nestjs-libraries/src/dtos/posts/get.posts.dto.ts
@@ -14,8 +14,4 @@ export class GetPostsDto {
@Max(dayjs().add(10, 'year').year())
@Min(2022)
year: number;
-
- @IsIn(['true', 'false'])
- @IsString()
- isIsoWeek: 'true' | 'false';
}