File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import CardList from '@/components/presentation/card-list' ;
2+ import EmptyInfo from '@/components/presentation/empty-info' ;
23import FullHeightScrollView from '@/components/presentation/full-height-scroll-view' ;
34import HistoryCalendarCard from '@/components/presentation/history-calendar-card' ;
5+ import LimitedHtml from '@/components/presentation/limited-html' ;
46import SessionSummary from '@/components/presentation/session-summary' ;
57import SessionSummaryTitle from '@/components/presentation/session-summary-title' ;
68import SplitCardControl from '@/components/presentation/split-card-control' ;
@@ -10,6 +12,7 @@ import {
1012 selectSessions ,
1113 selectSessionsInMonth ,
1214} from '@/store/stored-sessions' ;
15+ import { formatDate } from '@/utils/format-date' ;
1316import { YearMonth } from '@js-joda/core' ;
1417import { useTranslate } from '@tolgee/react' ;
1518import { Stack } from 'expo-router' ;
@@ -54,6 +57,15 @@ export default function History() {
5457 }
5558 />
5659 ) }
60+ emptyTemplate = {
61+ < EmptyInfo >
62+ < LimitedHtml
63+ value = { t ( 'NoSessionsInMonth{Month}' , {
64+ 0 : formatDate ( currentYearMonth . atDay ( 1 ) , { month : 'long' } ) ,
65+ } ) }
66+ />
67+ </ EmptyInfo >
68+ }
5769 />
5870 </ FullHeightScrollView >
5971 </ >
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ interface CardListProps<T> extends ViewProps {
1212 cardStyle ?: CardProps [ 'style' ] ;
1313 cardType : 'elevated' | 'outlined' | 'contained' ;
1414 keySelector ?: ( item : T ) => Key ;
15+ emptyTemplate ?: ReactNode ;
1516}
1617
1718export default function CardList < T > ( props : CardListProps < T > ) {
@@ -24,6 +25,7 @@ export default function CardList<T>(props: CardListProps<T>) {
2425 cardStyle,
2526 cardType,
2627 keySelector,
28+ emptyTemplate,
2729 ...rest
2830 } = props ;
2931 return (
@@ -33,10 +35,12 @@ export default function CardList<T>(props: CardListProps<T>) {
3335 {
3436 gap : spacing [ 2 ] ,
3537 padding : spacing [ 2 ] ,
38+ flex : 1 ,
3639 } ,
3740 rest [ 'style' ] ,
3841 ] }
3942 >
43+ { ! ! items . length || emptyTemplate }
4044 { items . map ( ( item , i ) => (
4145 < Card
4246 key = { keySelector ?.( item ) ?? i }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { SurfaceText } from '@/components/presentation/surface-text';
22import { spacing , useAppTheme } from '@/hooks/useAppTheme' ;
33import { Session } from '@/models/session-models' ;
44import { useAppSelector } from '@/store' ;
5+ import { formatDate } from '@/utils/format-date' ;
56import { LocalDate , Year , YearMonth } from '@js-joda/core' ;
67import Enumerable from 'linq' ;
78import { View } from 'react-native' ;
@@ -250,14 +251,6 @@ function HistoryCalendarDay(props: {
250251 ) ;
251252}
252253
253- function formatDate ( date : LocalDate , opts : Intl . DateTimeFormatOptions ) {
254- return new Date (
255- date . year ( ) ,
256- date . month ( ) . ordinal ( ) ,
257- date . dayOfMonth ( ) ,
258- ) . toLocaleString ( 'default' , opts ) ;
259- }
260-
261254function getDateOnDay ( dayOfWeek : number ) {
262255 // Super gross and hacky, but then we get i18n formatting for free
263256 const constantSundayDay = LocalDate . of ( 2025 , 5 , 4 ) ;
Original file line number Diff line number Diff line change 1+ import { LocalDate } from '@js-joda/core' ;
2+
3+ export function formatDate ( date : LocalDate , opts : Intl . DateTimeFormatOptions ) {
4+ return new Date (
5+ date . year ( ) ,
6+ date . month ( ) . ordinal ( ) ,
7+ date . dayOfMonth ( ) ,
8+ ) . toLocaleString ( 'default' , opts ) ;
9+ }
You can’t perform that action at this time.
0 commit comments