+
{
+type DailyView = Extract<
+ FeedViewType,
+ FeedViewType.Articles | FeedViewType.SocialMedia
+>
+enum DayOf {
+ Today,
+ Yesterday,
+}
+interface DailyItemProps {
+ view: DailyView
+ day: DayOf
+}
+
+const DailyItem = ({ view, day }: DailyItemProps) => {
const dateObj = new Date()
const nowHour = dateObj.getHours()
@@ -40,9 +46,10 @@ export const DailyItem = ({
dateObj.setDate(dateObj.getDate() - 1)
const dayBeforeYesterday8PM = dateObj.setHours(20, 0, 0, 0)
+ const isToday = day === DayOf.Today
// For index 0, get the last past 8 AM or 8 PM; for index 1, get the second last past 8 AM or 8 PM.
if (nowHour >= 20) {
- if (index === 0) {
+ if (isToday) {
endDate = today8PM - 1
startDate = today8AM
title = "Today"
@@ -52,7 +59,7 @@ export const DailyItem = ({
title = "Last Night"
}
} else if (nowHour >= 8) {
- if (index === 0) {
+ if (isToday) {
endDate = today8AM - 1
startDate = yesterday8PM
title = "Last Night"
@@ -62,7 +69,7 @@ export const DailyItem = ({
title = "Yesterday"
}
} else {
- if (index === 0) {
+ if (isToday) {
endDate = yesterday8PM - 1
startDate = yesterday8AM
title = "Yesterday"
@@ -73,6 +80,59 @@ export const DailyItem = ({
}
}
+ return (
+
+
+
+ {title}
+ 's Top News
+
+
+
+
+
+
+
+ -
+ Here is news selected by AI from your timeline
+ {" ("}
+ {new Date(startDate).toLocaleTimeString("en-US", {
+ weekday: "short",
+ hour: "numeric",
+ minute: "numeric",
+ })}
+ {" "}
+ -
+ {" "}
+ {new Date(endDate + 1).toLocaleTimeString("en-US", {
+ weekday: "short",
+ hour: "numeric",
+ minute: "numeric",
+ })}
+ {") "}
+ that may be important to you.
+
+ - Update daily at 8 AM and 8 PM.
+
+
+
+
+ )}
+ className="mx-auto w-full max-w-lg border-b pb-6 last:border-b-0"
+ >
+
+
+ )
+}
+
+const DailyReportContent: FC<{
+ view: DailyView
+ startDate: number
+ endDate: number
+}> = ({ endDate, startDate, view }) => {
const content = useAuthQuery(
defineQuery(["daily", view, startDate, endDate], async () => {
const res = await apiClient.ai.daily.$get({
@@ -84,72 +144,54 @@ export const DailyItem = ({
return res.data
}),
{
- enabled: value === `${index}`,
+ meta: {
+ persist: true,
+ },
},
)
+ const [markAllButtonRef, setMarkAllButtonRef] =
+ useState
(null)
+
return (
-
-
-
-
-
-
-
- {title}
- 's Top News
-
-
-
-
-
-
-
- -
- Here is news selected by AI from your timeline
- {" ("}
- {new Date(startDate).toLocaleTimeString("en-US", { weekday: "short", hour: "numeric", minute: "numeric" })}
- {" "}
- -
- {" "}
- {new Date(endDate + 1).toLocaleTimeString("en-US", { weekday: "short", hour: "numeric", minute: "numeric" })}
- {") "}
- that may be important to you.
-
- - Update daily at 8 AM and 8 PM.
-
-
-
-
-
-
-
- {content.isLoading ? (
-
- ) : (
- content.data && (
- {content.data}
- )
- )}
-
-
-
- Mark all as read
-
-
-
-
-
+
+
+
+ {content.isLoading ? (
+
+ ) : (
+ content.data && (
+
+ {content.data}
+
+ )
+ )}
+
+ {content.data && (
+
+ )}
+
+
)
}
@@ -157,17 +199,14 @@ export const Daily = ({
view,
className,
}: {
- view: 0 | 1
+ view: DailyView
className?: string
-}) => {
- const [value, setValue] = useState()
+}) => (
+
+
+
- return (
-
- )
-}
+
+
+
+)