Merge remote-tracking branch 'origin/main'
Some checks failed
Build / build (22.12.0) (push) Has been cancelled
Code Quality Analysis / Analyze (javascript-typescript) (push) Has been cancelled

This commit is contained in:
Nevo David 2026-05-18 20:49:30 +07:00
commit 09088a5391
7 changed files with 122 additions and 13 deletions

View file

@ -26,6 +26,8 @@ import { expandPostsList, expandPosts } from '@gitroom/helpers/utils/posts.list.
extend(isoWeek);
extend(weekOfYear);
export type ListStateFilter = 'all' | 'scheduled' | 'draft' | 'published';
export const CalendarContext = createContext({
startDate: newDayjs().startOf('isoWeek').format('YYYY-MM-DD'),
endDate: newDayjs().endOf('isoWeek').format('YYYY-MM-DD'),
@ -78,6 +80,10 @@ export const CalendarContext = createContext({
setListPage: (page: number) => {
/** empty **/
},
listState: 'all' as ListStateFilter,
setListState: (state: ListStateFilter) => {
/** empty **/
},
});
export interface Integrations {
@ -144,6 +150,11 @@ export const CalendarWeekProvider: FC<{
// List view state
const [listPage, setListPage] = useState(0);
const [listState, setListStateRaw] = useState<ListStateFilter>('all');
const setListState = useCallback((next: ListStateFilter) => {
setListStateRaw(next);
setListPage(0);
}, []);
// Initialize with current date range based on URL params or defaults
const initStartDate = searchParams.get('startDate');
@ -190,8 +201,9 @@ export const CalendarWeekProvider: FC<{
page: listPage.toString(),
limit: '100',
customer: filters?.customer?.toString() || '',
state: listState,
}).toString();
}, [listPage, filters.customer]);
}, [listPage, filters.customer, listState]);
const loadListData = useCallback(async () => {
const response = await fetch(`/posts/list?${listParams}`);
@ -341,6 +353,8 @@ export const CalendarWeekProvider: FC<{
listPage,
listTotalPages,
setListPage,
listState,
setListState,
}}
>
{children}

View file

@ -493,7 +493,15 @@ export const MonthView = () => {
export const ListView = () => {
const t = useT();
const user = useUser();
const { integrations, loading, listPosts } = useCalendar();
const { integrations, loading, listPosts, listState } = useCalendar();
const emptyMessage =
listState === 'scheduled'
? t('no_upcoming_posts', 'No upcoming posts scheduled')
: listState === 'draft'
? t('no_draft_posts', 'No draft posts')
: listState === 'published'
? t('no_published_posts', 'No published posts')
: t('no_posts', 'No posts');
// Use shared post actions hook
const { editPost, deletePost, copyDebugJson, openStatistics, openMissingRelease } = usePostActions();
@ -522,9 +530,7 @@ export const ListView = () => {
if (listPosts.length === 0) {
return (
<div className="flex flex-col flex-1 items-center justify-center">
<div className="text-textColor text-[16px]">
{t('no_upcoming_posts', 'No upcoming posts scheduled')}
</div>
<div className="text-textColor text-[16px]">{emptyMessage}</div>
</div>
);
}

View file

@ -1,6 +1,6 @@
'use client';
import { useCalendar } from '@gitroom/frontend/components/launches/calendar.context';
import { useCalendar, ListStateFilter } from '@gitroom/frontend/components/launches/calendar.context';
import clsx from 'clsx';
import dayjs from 'dayjs';
import { useCallback } from 'react';
@ -259,6 +259,21 @@ export const Filters = () => {
const isListView = calendar.display === 'list';
const setListStateFilter = useCallback(
(next: ListStateFilter) => () => {
if (calendar.listState === next) return;
calendar.setListState(next);
},
[calendar]
);
const listStateOptions: { value: ListStateFilter; label: string }[] = [
{ value: 'all', label: t('all', 'All') },
{ value: 'scheduled', label: t('scheduled', 'Scheduled') },
{ value: 'draft', label: t('draft', 'Draft') },
{ value: 'published', label: t('published', 'Published') },
];
const previousPage = useCallback(() => {
if (calendar.listPage > 0) {
calendar.setListPage(calendar.listPage - 1);
@ -393,6 +408,21 @@ export const Filters = () => {
</svg>
</div>
</div>
<div className="flex flex-row p-[4px] border border-newTableBorder rounded-[8px] text-[14px] font-[500]">
{listStateOptions.map((option) => (
<div
key={option.value}
onClick={setListStateFilter(option.value)}
className={clsx(
'pt-[6px] pb-[5px] cursor-pointer min-w-[80px] px-[12px] text-center rounded-[6px]',
calendar.listState === option.value &&
'text-textItemFocused bg-boxFocused'
)}
>
{option.label}
</div>
))}
</div>
<div className="flex-1" />
</div>
)}

View file

@ -29,12 +29,29 @@ const TikTokSettings: FC<{
return value?.[0]?.image?.some((p) => (p?.path?.indexOf?.('mp4') ?? -1) === -1);
}, [value]);
const hasMedia = (value?.[0]?.image?.length ?? 0) > 0;
const isVideo = hasMedia && !isTitle;
const disclose = watch('disclose');
const brand_organic_toggle = watch('brand_organic_toggle');
const brand_content_toggle = watch('brand_content_toggle');
const content_posting_method = watch('content_posting_method');
const isUploadMode = content_posting_method === 'UPLOAD';
const tiktokRestrictionNotice = useMemo(() => {
if (!hasMedia || !isVideo) return null;
if (!isUploadMode) {
return t(
'tiktok_restriction_direct_video',
'TikTok restriction: For direct post with video, your post content is used as the title. A separate title field is not available.'
);
}
return t(
'tiktok_restriction_upload_video',
'TikTok restriction: For upload-only video, TikTok does not accept a title or message. The content will default to "#Postiz" and you can edit it inside the TikTok app before publishing.'
);
}, [hasMedia, isUploadMode, isVideo, t]);
const privacyLevel = [
{
value: 'PUBLIC_TO_EVERYONE',
@ -83,6 +100,25 @@ const TikTokSettings: FC<{
return (
<div className="flex flex-col">
{/*<CheckTikTokValidity picture={props?.values?.[0]?.image?.[0]?.path} />*/}
{tiktokRestrictionNotice && (
<div className="bg-tableBorder p-[10px] mb-[18px] rounded-[10px] flex gap-[10px] items-start text-[13px] text-balance">
<div className="shrink-0 mt-[2px]">
<svg
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M22.201 17.6335L14.0026 3.39569C13.7977 3.04687 13.5052 2.75764 13.1541 2.55668C12.803 2.35572 12.4055 2.25 12.001 2.25C11.5965 2.25 11.199 2.35572 10.8479 2.55668C10.4968 2.75764 10.2043 3.04687 9.99944 3.39569L1.80101 17.6335C1.60388 17.9709 1.5 18.3546 1.5 18.7454C1.5 19.1361 1.60388 19.5199 1.80101 19.8572C2.00325 20.2082 2.29523 20.499 2.64697 20.6998C2.99871 20.9006 3.39755 21.0043 3.80257 21.0001H20.1994C20.6041 21.0039 21.0026 20.9001 21.354 20.6993C21.7054 20.4985 21.997 20.2079 22.1991 19.8572C22.3965 19.52 22.5007 19.1364 22.5011 18.7456C22.5014 18.3549 22.3978 17.9711 22.201 17.6335ZM11.251 9.75006C11.251 9.55115 11.33 9.36038 11.4707 9.21973C11.6113 9.07908 11.8021 9.00006 12.001 9.00006C12.1999 9.00006 12.3907 9.07908 12.5313 9.21973C12.672 9.36038 12.751 9.55115 12.751 9.75006V13.5001C12.751 13.699 12.672 13.8897 12.5313 14.0304C12.3907 14.171 12.1999 14.2501 12.001 14.2501C11.8021 14.2501 11.6113 14.171 11.4707 14.0304C11.33 13.8897 11.251 13.699 11.251 13.5001V9.75006ZM12.001 18.0001C11.7785 18.0001 11.561 17.9341 11.376 17.8105C11.191 17.6868 11.0468 17.5111 10.9616 17.3056C10.8765 17.1 10.8542 16.8738 10.8976 16.6556C10.941 16.4374 11.0482 16.2369 11.2055 16.0796C11.3628 15.9222 11.5633 15.8151 11.7815 15.7717C11.9998 15.7283 12.226 15.7505 12.4315 15.8357C12.6371 15.9208 12.8128 16.065 12.9364 16.25C13.06 16.4351 13.126 16.6526 13.126 16.8751C13.126 17.1734 13.0075 17.4596 12.7965 17.6706C12.5855 17.8815 12.2994 18.0001 12.001 18.0001Z"
fill="currentColor"
/>
</svg>
</div>
<div>{tiktokRestrictionNotice}</div>
</div>
)}
{isTitle && <Input label="Title" {...register('title')} maxLength={89} />}
<Select
label={t('label_who_can_see_this_video', 'Who can see this video?')}

View file

@ -224,6 +224,26 @@ export class PostsRepository {
const limit = query.limit || 20;
const skip = page * limit;
const stateFilter = query.state || 'all';
const stateAndDate =
stateFilter === 'scheduled'
? {
state: State.QUEUE,
publishDate: { gte: dayjs.utc().toDate() },
}
: stateFilter === 'draft'
? { state: State.DRAFT }
: stateFilter === 'published'
? { state: State.PUBLISHED }
: {
state: {
in: [State.QUEUE, State.DRAFT, State.PUBLISHED, State.ERROR],
},
};
const orderDirection: 'asc' | 'desc' =
stateFilter === 'published' ? 'desc' : 'asc';
const where = {
AND: [
{
@ -233,12 +253,8 @@ export class PostsRepository {
},
],
},
{
publishDate: {
gte: dayjs.utc().toDate(),
},
},
],
...stateAndDate,
deletedAt: null as Date | null,
parentPostId: null as string | null,
intervalInDays: null as number | null,
@ -257,7 +273,7 @@ export class PostsRepository {
skip,
take: limit,
orderBy: {
publishDate: 'asc',
publishDate: orderDirection,
},
select: {
id: true,

View file

@ -4,9 +4,12 @@ import {
IsNumber,
Min,
Max,
IsIn,
} from 'class-validator';
import { Transform } from 'class-transformer';
export type PostListStateFilter = 'all' | 'scheduled' | 'draft' | 'published';
export class GetPostsListDto {
@IsOptional()
@IsNumber()
@ -24,4 +27,8 @@ export class GetPostsListDto {
@IsOptional()
@IsString()
customer?: string;
@IsOptional()
@IsIn(['all', 'scheduled', 'draft', 'published'])
state?: PostListStateFilter = 'all';
}

View file

@ -147,7 +147,7 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
return {
type: 'bad-body' as const,
value:
'TikTok limit the maximum of pending posts to 5, TikTok limits you for now, please check your TikTok inbox at your TikTok mobile app and try again later',
'TikTok limits pending posts to 5 within any 24-hour period. Please check your TikTok inbox in the TikTok mobile app and try again after 24 hours.',
};
}