feat: fixing date
This commit is contained in:
parent
11de46f5b3
commit
aab1ef1c3a
|
|
@ -53,8 +53,7 @@ export class PostsController {
|
|||
this._commentsService.getAllCommentsByWeekYear(
|
||||
org.id,
|
||||
query.year,
|
||||
query.week,
|
||||
query.isIsoWeek === 'true'
|
||||
query.week
|
||||
),
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
)}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,4 @@ export class GetPostsDto {
|
|||
@Max(dayjs().add(10, 'year').year())
|
||||
@Min(2022)
|
||||
year: number;
|
||||
|
||||
@IsIn(['true', 'false'])
|
||||
@IsString()
|
||||
isIsoWeek: 'true' | 'false';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue