From d3137973ab7e7e20a66345521b8309ce03d98b50 Mon Sep 17 00:00:00 2001 From: Amiram_se Date: Fri, 9 Oct 2026 18:46:36 +0400 Subject: [PATCH] feat(island): media strip, media frame with expand badge, list row keep-end, offline freeze, upload tile and toast placement follow-ups Co-Authored-By: Claude Opus 5.5 --- packages/island/src/hooks/use-online/index.ts | 2 + packages/island/src/hooks/use-online/types.ts | 4 + .../hooks/use-online/use-offline-freeze.ts | 19 +++ packages/island/src/index.ts | 14 +- .../island/src/molecules/list-row/ListRow.tsx | 2 + .../island/src/molecules/list-row/types.ts | 5 + .../media-carousel/MediaCarousel.tsx | 7 +- .../components/MediaExpandBadge.tsx | 18 +++ .../media-carousel/components/MediaSlide.tsx | 26 ++-- .../media-carousel/components/MediaTrack.tsx | 10 +- .../src/molecules/media-carousel/types.ts | 4 +- .../src/molecules/media-carousel/variants.ts | 42 ++++-- .../src/molecules/media-strip/MediaStrip.tsx | 125 ++++++++++++++++ .../island/src/molecules/media-strip/index.ts | 8 + .../island/src/molecules/media-strip/types.ts | 47 ++++++ .../src/molecules/media-strip/variants.ts | 37 +++++ .../subscriber-list/SubscriberList.tsx | 140 ------------------ .../SubscriberListSkeleton.tsx | 39 ----- .../plans/organisms/subscriber-list/index.ts | 3 - .../plans/organisms/subscriber-list/types.ts | 10 -- .../overview/models/subscribers/index.ts | 2 - .../overview/models/subscribers/types.ts | 11 -- .../subscribers/use-subscribers-part.ts | 38 ----- .../creator-subscribers/constants.ts | 6 - .../creator-subscribers.ts | 25 ---- .../repositories/creator-subscribers/index.ts | 7 - .../creator-subscribers/mappers.ts | 29 ---- .../repositories/creator-subscribers/types.ts | 38 ----- 28 files changed, 330 insertions(+), 388 deletions(-) create mode 100644 packages/island/src/hooks/use-online/types.ts create mode 100644 packages/island/src/hooks/use-online/use-offline-freeze.ts create mode 100644 packages/island/src/molecules/media-carousel/components/MediaExpandBadge.tsx create mode 100644 packages/island/src/molecules/media-strip/MediaStrip.tsx create mode 100644 packages/island/src/molecules/media-strip/index.ts create mode 100644 packages/island/src/molecules/media-strip/types.ts create mode 100644 packages/island/src/molecules/media-strip/variants.ts delete mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/SubscriberList.tsx delete mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/SubscriberListSkeleton.tsx delete mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/index.ts delete mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/types.ts delete mode 100644 platforms/market/src/features/overview/models/subscribers/index.ts delete mode 100644 platforms/market/src/features/overview/models/subscribers/types.ts delete mode 100644 platforms/market/src/features/overview/models/subscribers/use-subscribers-part.ts delete mode 100644 platforms/market/src/features/overview/repositories/creator-subscribers/constants.ts delete mode 100644 platforms/market/src/features/overview/repositories/creator-subscribers/creator-subscribers.ts delete mode 100644 platforms/market/src/features/overview/repositories/creator-subscribers/index.ts delete mode 100644 platforms/market/src/features/overview/repositories/creator-subscribers/mappers.ts delete mode 100644 platforms/market/src/features/overview/repositories/creator-subscribers/types.ts diff --git a/packages/island/src/hooks/use-online/index.ts b/packages/island/src/hooks/use-online/index.ts index b52e385..fa2f915 100644 --- a/packages/island/src/hooks/use-online/index.ts +++ b/packages/island/src/hooks/use-online/index.ts @@ -1 +1,3 @@ +export { useOfflineFreeze } from './use-offline-freeze'; export { useOnline } from './use-online'; +export type { OfflineFreeze } from './types'; diff --git a/packages/island/src/hooks/use-online/types.ts b/packages/island/src/hooks/use-online/types.ts new file mode 100644 index 0000000..ce19598 --- /dev/null +++ b/packages/island/src/hooks/use-online/types.ts @@ -0,0 +1,4 @@ +import type { ReactNode } from 'react'; + +/** Button props that freeze a network action offline; empty while online. */ +export type OfflineFreeze = { frozen?: true; frozenReason?: ReactNode }; diff --git a/packages/island/src/hooks/use-online/use-offline-freeze.ts b/packages/island/src/hooks/use-online/use-offline-freeze.ts new file mode 100644 index 0000000..68ee38f --- /dev/null +++ b/packages/island/src/hooks/use-online/use-offline-freeze.ts @@ -0,0 +1,19 @@ +'use client'; + +import type { ReactNode } from 'react'; + +import type { OfflineFreeze } from './types'; +import { useOnline } from './use-online'; + +/** + * Freezes a network action while the device is offline: spread it on the action's Button, which + * stays visible at 40% and explains itself on tap, hover and focus. Online it adds nothing, so a + * button keeps its own `frozen` and `frozenReason`; combine them when it has its own: + * `frozen={offline.frozen || own}`. + * + * @param reason Why, from the translations: «برای این کار به اینترنت نیاز دارید.». + */ +export function useOfflineFreeze(reason: ReactNode): OfflineFreeze { + const isOnline = useOnline(); + return isOnline ? {} : { frozen: true, frozenReason: reason }; +} diff --git a/packages/island/src/index.ts b/packages/island/src/index.ts index fc6cb2b..b5d92a2 100644 --- a/packages/island/src/index.ts +++ b/packages/island/src/index.ts @@ -76,7 +76,8 @@ export type { SeparatorProps } from './atoms/separator'; export { Spinner, spinnerVariants } from './atoms/spinner'; export { useCountdown } from './hooks/use-countdown'; export type { CountdownOptions } from './hooks/use-countdown'; -export { useOnline } from './hooks/use-online'; +export { useOfflineFreeze, useOnline } from './hooks/use-online'; +export type { OfflineFreeze } from './hooks/use-online'; export { StateArt } from './atoms/state-art'; export type { StateArtProps, StateTone } from './atoms/state-art'; export type { SpinnerProps } from './atoms/spinner'; @@ -185,6 +186,17 @@ export { LockedTeaser } from './molecules/locked-teaser'; export type { LockedTeaserProps } from './molecules/locked-teaser'; export { MediaCarousel } from './molecules/media-carousel'; export type { MediaCarouselProps, MediaItem } from './molecules/media-carousel'; +export { + MediaStrip, + mediaStripAddVariants, + mediaStripTileVariants, +} from './molecules/media-strip'; +export type { + MediaStripItem, + MediaStripProps, + MediaStripSize, + MediaStripStatus, +} from './molecules/media-strip'; export { Meter, meterBarVariants } from './molecules/meter'; export type { MeterProps, MeterTone } from './molecules/meter'; export { Modal } from './molecules/modal'; diff --git a/packages/island/src/molecules/list-row/ListRow.tsx b/packages/island/src/molecules/list-row/ListRow.tsx index a0bfa7a..abc1834 100644 --- a/packages/island/src/molecules/list-row/ListRow.tsx +++ b/packages/island/src/molecules/list-row/ListRow.tsx @@ -26,6 +26,7 @@ export function ListRow(props: ListRowProps) { icon, iconTone, end, + keepEnd = false, chevron, unread = false, unreadLabel, @@ -114,6 +115,7 @@ export function ListRow(props: ListRowProps) { alignItems="items-end" gap="gap-1" className="flex-none" + data-keep={keepEnd || undefined} > {end} diff --git a/packages/island/src/molecules/list-row/types.ts b/packages/island/src/molecules/list-row/types.ts index 074fd63..b1f37f7 100644 --- a/packages/island/src/molecules/list-row/types.ts +++ b/packages/island/src/molecules/list-row/types.ts @@ -38,6 +38,11 @@ type ListRowBaseProps = { iconTone?: ListRowIconTone; /** The end column, stacked and end-aligned: an `Amount`, a `StatusBadge`, a caption. */ end?: ReactNode; + /** + * The end column holds a live control (an unfollow button): it keeps full strength when the row + * is `dimmed`. + */ + keepEnd?: boolean; /** The `chevron-left` at the end. On by itself for a link row; pass false to hide it. */ chevron?: boolean; /** Tinted with a dot at the inline start. */ diff --git a/packages/island/src/molecules/media-carousel/MediaCarousel.tsx b/packages/island/src/molecules/media-carousel/MediaCarousel.tsx index eb6a2e6..a7fced0 100644 --- a/packages/island/src/molecules/media-carousel/MediaCarousel.tsx +++ b/packages/island/src/molecules/media-carousel/MediaCarousel.tsx @@ -4,9 +4,10 @@ import { MAX_MEDIA } from './constants'; import type { MediaCarouselProps } from './types'; /** - * A post's images. One shows full width at its own ratio, letterboxed at 400px on - * `surface-sunken`; 2–4 swipe in 280px slides with dots and a «۱ / ۳» count, and from 480px wide - * also move with ‹ › buttons on the image. Server-renderable: + * A post's images, each whole (contained) in a 4:3 frame at most 420px tall on `surface-sunken`, + * with an expand badge at its bottom inline end (DS v6.1). One shows alone; 2–4 swipe with dots + * and a «۱ / ۳» count, and from 480px wide also move with ‹ › buttons on the image. + * Server-renderable: * a single image ships no JavaScript, and only the swipe track is a client component, so every * prop it takes is serializable except `onOpen`, which only a client caller can pass. */ diff --git a/packages/island/src/molecules/media-carousel/components/MediaExpandBadge.tsx b/packages/island/src/molecules/media-carousel/components/MediaExpandBadge.tsx new file mode 100644 index 0000000..6fcd599 --- /dev/null +++ b/packages/island/src/molecules/media-carousel/components/MediaExpandBadge.tsx @@ -0,0 +1,18 @@ +import { GridBox } from '../../../atoms/grid-box'; +import { Icon } from '../../../atoms/icon'; +import { mediaExpandVariants } from '../variants'; + +/** The expand mark on the frame (DS `lm-media__expand`); hidden from screen readers. */ +export function MediaExpandBadge() { + return ( + + + + ); +} diff --git a/packages/island/src/molecules/media-carousel/components/MediaSlide.tsx b/packages/island/src/molecules/media-carousel/components/MediaSlide.tsx index 3ba0a42..3c69eee 100644 --- a/packages/island/src/molecules/media-carousel/components/MediaSlide.tsx +++ b/packages/island/src/molecules/media-carousel/components/MediaSlide.tsx @@ -1,14 +1,15 @@ import NextLink from 'next/link'; -import { GridBox } from '../../../atoms/grid-box'; import { Element } from '../../../primitives/element'; import { cn } from '../../../tools/cn'; import type { MediaSlideProps } from '../types'; import { mediaImageVariants, mediaSlideVariants } from '../variants'; +import { MediaExpandBadge } from './MediaExpandBadge'; /** - * One image, contained in its box. With `onOpen` the box is the button that opens the Lightbox; - * with `href` a hidden link covers it, so a tap opens the post while the image keeps its alt. + * One image, contained in its 4:3 frame. With `onOpen` the frame is the button that opens the + * Lightbox; with `href` a hidden link covers it, so a tap opens the post while the image keeps its + * alt. A single image carries the expand badge itself; the track draws one for all its slides. */ export function MediaSlide({ item, @@ -30,17 +31,16 @@ export function MediaSlide({ loading={index === 0 ? undefined : 'lazy'} decoding="async" draggable={false} - className={mediaImageVariants({ single })} + className={mediaImageVariants()} /> ); + const badge = single && ; if (onOpen) { return ( - onOpen(index)} aria-label={label ?? (item.alt || undefined)} className={cn( @@ -51,17 +51,15 @@ export function MediaSlide({ )} > {image} - + {badge} + ); } return ( - + {image} + {badge} {href && ( // The post's own link carries the keyboard path; this one is only a bigger tap area. )} - + ); } diff --git a/packages/island/src/molecules/media-carousel/components/MediaTrack.tsx b/packages/island/src/molecules/media-carousel/components/MediaTrack.tsx index fc9bf72..bd04d6e 100644 --- a/packages/island/src/molecules/media-carousel/components/MediaTrack.tsx +++ b/packages/island/src/molecules/media-carousel/components/MediaTrack.tsx @@ -10,16 +10,17 @@ import { Element } from '../../../primitives/element'; import { cn } from '../../../tools/cn'; import type { MediaCarouselProps } from '../types'; import { mediaDotVariants } from '../variants'; +import { MediaExpandBadge } from './MediaExpandBadge'; import { MediaNavButton } from './MediaNavButton'; import { MediaSlide } from './MediaSlide'; const isRtl = (node: HTMLElement) => getComputedStyle(node).direction === 'rtl'; /** - * 2–4 images in a native swipe (scroll snap), with a «۱ / ۳» count and a dot per image. From 480px - * wide, ‹ › buttons on the image move it too, and ← → on a focused slide. Moving never opens the - * Lightbox: only a tap on an image does. The only client part of a post: it follows the scroll to - * light the current dot and count. + * 2–4 images in a native swipe (scroll snap) of 4:3 frames, with a «۱ / ۳» count, the expand badge + * and a dot per image. From 480px wide, ‹ › buttons on the image move it too, and ← → on a focused + * slide. Moving never opens the Lightbox: only a tap on an image does. The only client part of a + * post: it follows the scroll to light the current dot and count. */ export function MediaTrack({ items, @@ -130,6 +131,7 @@ export function MediaTrack({ {number(current + 1)} / {number(count)} + {items.map((item, index) => ( diff --git a/packages/island/src/molecules/media-carousel/types.ts b/packages/island/src/molecules/media-carousel/types.ts index 90d44aa..9d16e95 100644 --- a/packages/island/src/molecules/media-carousel/types.ts +++ b/packages/island/src/molecules/media-carousel/types.ts @@ -1,6 +1,6 @@ export type MediaItem = { src: string; - /** Natural size in px, so a single image reserves its box at its own ratio before it loads. */ + /** Natural size in px: the browser's ratio hint while it loads; the 4:3 frame sets the box. */ width: number; height: number; /** Describes the image; `''` only when it adds nothing to the caption. */ @@ -38,7 +38,7 @@ export type MediaCarouselProps = { export type MediaSlideProps = { item: MediaItem; index: number; - /** Alone at its own ratio (max 400px) rather than a 280px slide in the track. */ + /** Alone in its own rounded frame, with its own expand badge, rather than a slide in the track. */ single: boolean; /** The button's accessible name; see `slideLabels`. */ label?: string; diff --git a/packages/island/src/molecules/media-carousel/variants.ts b/packages/island/src/molecules/media-carousel/variants.ts index 13fba11..a495680 100644 --- a/packages/island/src/molecules/media-carousel/variants.ts +++ b/packages/island/src/molecules/media-carousel/variants.ts @@ -1,24 +1,34 @@ import { cva } from 'class-variance-authority'; -/** The image's box: letterboxed on `surface-sunken`, the track's ground when it swipes. */ -export const mediaSlideVariants = cva('relative', { - variants: { - single: { - true: 'w-full overflow-hidden rounded-md bg-surface-sunken', - false: 'h-70 max-h-100 w-full flex-none snap-center snap-always', +/** + * The image's frame (DS v6.1): 4:3 and at most 420px tall, whatever the image's own ratio, so a + * card's height never depends on its picture. Alone it is rounded on `surface-sunken`; in the + * track the track draws that ground and the corners. + */ +export const mediaSlideVariants = cva( + 'relative block aspect-4/3 max-h-105 w-full', + { + variants: { + single: { + true: 'overflow-hidden rounded-md bg-surface-sunken', + false: 'flex-none snap-center snap-always', + }, }, }, -}); +); -/** Contained, never cropped: the Lightbox shows the image whole anyway. */ -export const mediaImageVariants = cva('block object-contain', { - variants: { - single: { - true: 'h-auto max-h-100 w-full', - false: 'h-auto max-h-full w-auto max-w-full', - }, - }, -}); +/** The whole image, contained and centred in the frame, never cropped. */ +export const mediaImageVariants = cva( + 'absolute inset-0 block size-full object-contain', +); + +/** + * The 28px expand badge at the frame's bottom inline end: says a tap opens the image full size. + * Decorative and click-through; the image's own button or link carries the action. + */ +export const mediaExpandVariants = cva( + 'pointer-events-none absolute end-2 bottom-2 size-7 rounded-full bg-scrim-chip text-text-on-action', +); /** The current image's dot stretches into an 18px pill. */ export const mediaDotVariants = cva( diff --git a/packages/island/src/molecules/media-strip/MediaStrip.tsx b/packages/island/src/molecules/media-strip/MediaStrip.tsx new file mode 100644 index 0000000..dc39833 --- /dev/null +++ b/packages/island/src/molecules/media-strip/MediaStrip.tsx @@ -0,0 +1,125 @@ +import { FlexBox } from '../../atoms/flex-box'; +import { GridBox } from '../../atoms/grid-box'; +import { Icon } from '../../atoms/icon'; +import { Spinner } from '../../atoms/spinner'; +import { Typography } from '../../atoms/typography'; +import { Element } from '../../primitives/element'; +import { cn } from '../../tools/cn'; +import type { MediaStripItem, MediaStripProps } from './types'; +import { mediaStripAddVariants, mediaStripTileVariants } from './variants'; + +const IMAGE_CLASS = 'block size-full object-cover'; + +/** + * A form's picked images (DS MediaStrip), such as the post composer's: thumbnails in the order + * they were added, each with a 28px ✕; one uploading sits under a light veil with a spinner, a + * failed one has a danger frame and, with `onRetry`, sends again on tap. A dashed «افزودن» tile + * ends the strip until `max`. It wraps; 76px thumbnails, 96px at `lg`. + */ +export function MediaStrip({ + items, + label, + onRemove, + onRetry, + addLabel, + onAdd, + max = 4, + size = 'md', + disabled = false, + className, +}: MediaStripProps) { + const canAdd = + onAdd != null && addLabel != null && !disabled && items.length < max; + if (items.length === 0 && !canAdd) return null; + + const image = (item: MediaStripItem) => ( + + ); + + return ( + + {items.map((item) => { + const status = item.status ?? 'ready'; + const retry = + status === 'error' && onRetry && item.retryLabel ? onRetry : null; + return ( + + {retry ? ( + retry(item.key)} + disabled={disabled} + aria-label={item.retryLabel} + className="block size-full cursor-pointer focus-visible:focus-ring disabled:cursor-not-allowed" + > + {image(item)} + + ) : ( + image(item) + )} + {status === 'busy' && ( + + + + )} + onRemove(item.key)} + disabled={disabled} + aria-label={item.removeLabel} + justifyItems="justify-items-center" + alignItems="items-center" + className="absolute end-1 top-1 z-1 size-7 cursor-pointer rounded-full bg-scrim-chip text-text-inverse focus-visible:focus-ring disabled:frozen" + > + + + + ); + })} + {canAdd && ( + + + + + {addLabel} + + + + )} + + ); +} diff --git a/packages/island/src/molecules/media-strip/index.ts b/packages/island/src/molecules/media-strip/index.ts new file mode 100644 index 0000000..b69b501 --- /dev/null +++ b/packages/island/src/molecules/media-strip/index.ts @@ -0,0 +1,8 @@ +export { MediaStrip } from './MediaStrip'; +export type { + MediaStripItem, + MediaStripProps, + MediaStripSize, + MediaStripStatus, +} from './types'; +export { mediaStripAddVariants, mediaStripTileVariants } from './variants'; diff --git a/packages/island/src/molecules/media-strip/types.ts b/packages/island/src/molecules/media-strip/types.ts new file mode 100644 index 0000000..03e3339 --- /dev/null +++ b/packages/island/src/molecules/media-strip/types.ts @@ -0,0 +1,47 @@ +import type { VariantProps } from 'class-variance-authority'; + +import type { mediaStripTileVariants } from './variants'; + +/** ready: picked and stored. busy: uploading (a light veil and a spinner). error: failed. */ +export type MediaStripStatus = 'ready' | 'busy' | 'error'; + +export type MediaStripSize = NonNullable< + VariantProps['size'] +>; + +export type MediaStripItem = { + /** Stable while the item is in the strip. */ + key: string; + /** What the thumbnail shows: a local preview or the stored file's address. */ + src: string; + /** The image's accessible name, such as «تصویر ۲». */ + alt: string; + /** `ready` by default. */ + status?: MediaStripStatus; + /** The ✕'s accessible name, such as «حذف تصویر ۲». */ + removeLabel: string; + /** busy: what screen readers hear instead of `alt`, such as «در حال آپلود تصویر ۲: ۴۰٪». */ + busyLabel?: string; + /** error: with `onRetry`, the thumbnail sends it again on tap, named so: «آپلود دوباره تصویر ۲». */ + retryLabel?: string; +}; + +export type MediaStripProps = { + /** In the order they were added. */ + items: readonly MediaStripItem[]; + /** The list's accessible name, such as «تصاویر پست». */ + label: string; + onRemove: (key: string) => void; + /** A failed item with a `retryLabel` sends again on tap. */ + onRetry?: (key: string) => void; + /** The dashed add tile's text, «افزودن»; the tile shows with `onAdd`, below `max`. */ + addLabel?: string; + onAdd?: () => void; + /** At this many the add tile leaves the strip; 4 by default. */ + max?: number; + /** md: 76px thumbnails (mobile). lg: 96px (the desktop composer). */ + size?: MediaStripSize; + /** While the form is sending: the add tile leaves, and ✕ and retry do nothing. */ + disabled?: boolean; + className?: string; +}; diff --git a/packages/island/src/molecules/media-strip/variants.ts b/packages/island/src/molecules/media-strip/variants.ts new file mode 100644 index 0000000..c8f49b0 --- /dev/null +++ b/packages/island/src/molecules/media-strip/variants.ts @@ -0,0 +1,37 @@ +import { cva } from 'class-variance-authority'; + +/** + * One thumbnail (DS MediaStrip `lm-thumb`): a radius-md square on sunken surface with a hairline; + * a failed one has a 2px danger frame. + */ +export const mediaStripTileVariants = cva( + 'relative flex-none overflow-hidden rounded-md bg-surface-sunken', + { + variants: { + size: { + md: 'size-19', + lg: 'size-24', + }, + status: { + ready: 'border border-border-subtle', + busy: 'border border-border-subtle', + error: 'border-2 border-danger', + }, + }, + defaultVariants: { size: 'md', status: 'ready' }, + }, +); + +/** The add tile (DS `lm-thumb--add`): dashed, on surface, the plus over «افزودن» in 12/16/600. */ +export const mediaStripAddVariants = cva( + 'cursor-pointer rounded-md border-[1.5px] border-dashed border-border-default bg-surface text-text-secondary transition-colors duration-120 ease-standard hover:bg-surface-hover focus-visible:focus-ring', + { + variants: { + size: { + md: 'size-19', + lg: 'size-24', + }, + }, + defaultVariants: { size: 'md' }, + }, +); diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/SubscriberList.tsx b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/SubscriberList.tsx deleted file mode 100644 index 684c270..0000000 --- a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/SubscriberList.tsx +++ /dev/null @@ -1,140 +0,0 @@ -'use client'; - -import { Button } from '@lumina/island/atoms/button'; -import { Element } from '@lumina/island/primitives/element'; -import { FlexBox } from '@lumina/island/atoms/flex-box'; -import { Separator } from '@lumina/island/atoms/separator'; -import { Typography } from '@lumina/island/atoms/typography'; -import { Card } from '@lumina/island/molecules/card'; -import { EmptyState } from '@lumina/island/molecules/empty-state'; -import { ErrorState } from '@lumina/island/molecules/error-state'; -import { cn } from '@lumina/island/tools/cn'; -import { date, number } from '@lumina/tools/format'; -import { useId } from 'react'; -import { useTranslation } from 'react-i18next'; - -import { useSubscribersPart } from '../../../../../../../features/overview'; -import type { SubscriberListProps } from './types'; - -/** - * طرح‌های اشتراک › مشترکان (Creator Dashboard ۲.۱): the active count in the header, then each - * running subscription by @username only, with its plan, start and end; newest start first, 20 at - * a time. Rows aren't tappable, and there is no filter, search or action, until Epic 6. With none, - * one quiet line (۲.۴). - */ -export function SubscriberList({ layout }: SubscriberListProps) { - const { t } = useTranslation(['dashboard', 'common', 'errors']); - const model = useSubscribersPart(); - const headingId = useId(); - - return ( - - - - - {t('subscribers.title')} - - - {t('subscribers.active')}{' '} - - {number(model.activeCount)} - - - - {model.rows.length === 0 ? ( - - ) : ( - - {model.rows.map((row, index) => ( - 0 && 'border-t border-border-subtle', - )} - > - - - @{row.username ?? '—'} - - {row.billingPeriod && ( - - {t(`common:billing-periods.${row.billingPeriod}`)} - - )} - - - {row.startsAt && - t('subscribers.start', { - date: date(row.startsAt, { time: false }), - })} - {row.startsAt && row.endsAt && } - {row.endsAt && - t('subscribers.end', { - date: date(row.endsAt, { time: false }), - })} - - - ))} - - )} - {model.loadMoreError ? ( - - ) : ( - model.hasMore && ( - - ) - )} - - - ); -} diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/SubscriberListSkeleton.tsx b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/SubscriberListSkeleton.tsx deleted file mode 100644 index ada1779..0000000 --- a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/SubscriberListSkeleton.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { FlexBox } from '@lumina/island/atoms/flex-box'; -import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton'; -import { Card } from '@lumina/island/molecules/card'; - -import type { SubscriberListSkeletonProps } from './types'; - -/** مشترکان before it arrives: its header and three rows of two lines. */ -export function SubscriberListSkeleton({ - layout, - label, - delayed, -}: SubscriberListSkeletonProps) { - return ( - - - - - - - - {[0, 1, 2].map((row) => ( - - - - - - - - ))} - - - - ); -} diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/index.ts b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/index.ts deleted file mode 100644 index 918d76b..0000000 --- a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { SubscriberList } from './SubscriberList'; -export { SubscriberListSkeleton } from './SubscriberListSkeleton'; -export type { SubscriberListProps, SubscriberListSkeletonProps } from './types'; diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/types.ts b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/types.ts deleted file mode 100644 index f250916..0000000 --- a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscriber-list/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -export type SubscriberListProps = { - layout: 'mobile' | 'desktop'; -}; - -export type SubscriberListSkeletonProps = SubscriberListProps & { - /** Hidden status text: «در حال بارگذاری مشترکان…». */ - label: string; - /** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */ - delayed?: boolean; -}; diff --git a/platforms/market/src/features/overview/models/subscribers/index.ts b/platforms/market/src/features/overview/models/subscribers/index.ts deleted file mode 100644 index 6286818..0000000 --- a/platforms/market/src/features/overview/models/subscribers/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { useSubscribersPart } from './use-subscribers-part'; -export type { SubscribersPartModel } from './types'; diff --git a/platforms/market/src/features/overview/models/subscribers/types.ts b/platforms/market/src/features/overview/models/subscribers/types.ts deleted file mode 100644 index fb907c5..0000000 --- a/platforms/market/src/features/overview/models/subscribers/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { LoadMoreErrorKind } from '../../../../shared/utils'; -import type { SubscriberPayload } from '../../repositories/creator-subscribers'; - -export type SubscribersPartModel = { - activeCount: number; - rows: SubscriberPayload[]; - hasMore: boolean; - loadMore: () => void; - isLoadingMore: boolean; - loadMoreError: LoadMoreErrorKind | null; -}; diff --git a/platforms/market/src/features/overview/models/subscribers/use-subscribers-part.ts b/platforms/market/src/features/overview/models/subscribers/use-subscribers-part.ts deleted file mode 100644 index 539cdeb..0000000 --- a/platforms/market/src/features/overview/models/subscribers/use-subscribers-part.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { useSuspenseInfiniteQuery } from '@tanstack/react-query'; - -import { firstOfEach, loadMoreErrorKind } from '../../../../shared/utils'; -import { - creatorSubscribersRepository, - subscriberKeys, -} from '../../repositories/creator-subscribers'; -import type { SubscribersPartModel } from './types'; - -/** - * طرح‌های اشتراک › مشترکان (Creator Dashboard ۲.۱): the active count and the running - * subscriptions, newest start first, 20 at a time. No filters, search or actions until Epic 6. - */ -export function useSubscribersPart(): SubscribersPartModel { - const list = useSuspenseInfiniteQuery({ - queryKey: subscriberKeys.list(), - queryFn: ({ pageParam, signal }) => - creatorSubscribersRepository.list({ page: pageParam }, { signal }), - initialPageParam: 1, - getNextPageParam: (last) => (last.hasMore ? last.page + 1 : undefined), - }); - - return { - activeCount: list.data.pages[0].activeCount, - rows: firstOfEach( - list.data.pages.flatMap((page) => page.items), - (row) => row.id, - ), - hasMore: list.hasNextPage, - loadMore: () => { - if (!list.isFetching) void list.fetchNextPage(); - }, - isLoadingMore: list.isFetchingNextPage, - loadMoreError: list.isFetchNextPageError - ? loadMoreErrorKind(list.error) - : null, - }; -} diff --git a/platforms/market/src/features/overview/repositories/creator-subscribers/constants.ts b/platforms/market/src/features/overview/repositories/creator-subscribers/constants.ts deleted file mode 100644 index 66c4463..0000000 --- a/platforms/market/src/features/overview/repositories/creator-subscribers/constants.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const CREATOR_SUBSCRIBERS_ENDPOINT = '/subscriptions/me/subscribers'; - -export const subscriberKeys = { - all: ['overview', 'subscribers'] as const, - list: () => [...subscriberKeys.all, 'list'] as const, -}; diff --git a/platforms/market/src/features/overview/repositories/creator-subscribers/creator-subscribers.ts b/platforms/market/src/features/overview/repositories/creator-subscribers/creator-subscribers.ts deleted file mode 100644 index 7b358d3..0000000 --- a/platforms/market/src/features/overview/repositories/creator-subscribers/creator-subscribers.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { overviewHttp } from '../../http'; -import { CREATOR_SUBSCRIBERS_ENDPOINT } from './constants'; -import { toListSubscribersQueryDto, toSubscribersPagePayload } from './mappers'; -import type { - ListSubscribersArgs, - SubscribersPagePayload, - SubscribersPageResponseDto, -} from './types'; - -/** - * The signed-in creator's running subscriptions, newest start first, 20 a page (Creator Dashboard - * ۲.۱). Creator session only: an investor gets 403. - */ -export const creatorSubscribersRepository = { - async list( - args: ListSubscribersArgs = {}, - { signal }: { signal?: AbortSignal } = {}, - ): Promise { - const response = await overviewHttp.get( - CREATOR_SUBSCRIBERS_ENDPOINT, - { params: toListSubscribersQueryDto(args), signal }, - ); - return toSubscribersPagePayload(response); - }, -}; diff --git a/platforms/market/src/features/overview/repositories/creator-subscribers/index.ts b/platforms/market/src/features/overview/repositories/creator-subscribers/index.ts deleted file mode 100644 index 46409dd..0000000 --- a/platforms/market/src/features/overview/repositories/creator-subscribers/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export { subscriberKeys } from './constants'; -export { creatorSubscribersRepository } from './creator-subscribers'; -export type { - ListSubscribersArgs, - SubscriberPayload, - SubscribersPagePayload, -} from './types'; diff --git a/platforms/market/src/features/overview/repositories/creator-subscribers/mappers.ts b/platforms/market/src/features/overview/repositories/creator-subscribers/mappers.ts deleted file mode 100644 index 052216a..0000000 --- a/platforms/market/src/features/overview/repositories/creator-subscribers/mappers.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { - ListSubscribersArgs, - ListSubscribersQueryDto, - SubscribersPagePayload, - SubscribersPageResponseDto, -} from './types'; - -export function toListSubscribersQueryDto( - args: ListSubscribersArgs, -): ListSubscribersQueryDto { - return { page: args.page ?? 1 }; -} - -export function toSubscribersPagePayload( - dto: SubscribersPageResponseDto, -): SubscribersPagePayload { - return { - activeCount: dto.activeCount, - items: dto.items.map((item) => ({ - id: item.id, - username: item.username, - billingPeriod: item.billingPeriod, - startsAt: item.startsAt, - endsAt: item.endsAt, - })), - page: dto.page, - hasMore: dto.hasMore, - }; -} diff --git a/platforms/market/src/features/overview/repositories/creator-subscribers/types.ts b/platforms/market/src/features/overview/repositories/creator-subscribers/types.ts deleted file mode 100644 index da2482d..0000000 --- a/platforms/market/src/features/overview/repositories/creator-subscribers/types.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { BillingPeriod } from '../../../../shared/constants'; - -export type ListSubscribersArgs = { page?: number }; -export type ListSubscribersQueryDto = { page: number }; - -/** `SubscriptionService.listSubscribers`'s row. */ -export type SubscriberResponseDto = { - id: string; - username: string | null; - billingPeriod: BillingPeriod | null; - startsAt: string | null; - endsAt: string | null; -}; - -export type SubscribersPageResponseDto = { - activeCount: number; - items: SubscriberResponseDto[]; - page: number; - hasMore: boolean; -}; - -/** A running subscription to the creator: the investor by @username only, never a phone or name. */ -export type SubscriberPayload = { - id: string; - username: string | null; - billingPeriod: BillingPeriod | null; - /** The current period. */ - startsAt: string | null; - endsAt: string | null; -}; - -export type SubscribersPagePayload = { - /** مشترکان فعال: every running subscription, not this page's. */ - activeCount: number; - items: SubscriberPayload[]; - page: number; - hasMore: boolean; -};