Skip to content

Commit b7c6b33

Browse files
authored
fix(Calendar): migrate events data to firefly api (#11935)
* fix: mf-6490 missing luma icon * fix(Calendar): migrate events data to firefly api * fix: remove luma * fixup! fix(Calendar): migrate events data to firefly api * fix: eslint --------- Co-authored-by: swkatmask <[email protected]>
1 parent 7ff417f commit b7c6b33

File tree

33 files changed

+297
-626
lines changed

33 files changed

+297
-626
lines changed
Lines changed: 11 additions & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Loading

packages/icons/icon-generated-as-jsx.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/icons/icon-generated-as-url.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/plugins/Calendar/src/SiteAdaptor/CalendarContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ export function CalendarContent(props: Props) {
6767
allowedDates={allowedDates}
6868
/>
6969
<TabPanel value={tabs.news} className={classes.tabPanel}>
70-
<NewsList date={date} />
70+
<NewsList date={date} onDatesUpdate={setAllowedDates} />
7171
</TabPanel>
7272
<TabPanel value={tabs.events} className={classes.tabPanel}>
7373
<EventList date={date} onDatesUpdate={setAllowedDates} />
7474
</TabPanel>
75-
<Footer provider={currentTab} />
75+
<Footer tab={currentTab} />
7676
</TabContext>
7777
</div>
7878
)

packages/plugins/Calendar/src/SiteAdaptor/components/EventList.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,18 @@ interface EventListProps {
100100
onDatesUpdate(/** locale date string list */ dates: string[]): void
101101
}
102102

103-
export const formatDate = (date: string) => {
104-
return format(new Date(date), 'MMM dd, yyyy HH:mm')
105-
}
106-
107103
export function EventList({ date, onDatesUpdate }: EventListProps) {
108104
const { classes, cx } = useStyles()
109105
const { isLoading, isFetching, data, hasNextPage, fetchNextPage } = useLumaEvents()
110106

111107
const comingEvents = useMemo(() => {
112108
if (!data) return EMPTY_LIST
113-
return data.filter((x) => new Date(x.start_at) >= date || new Date(x.event.end_at) >= date)
109+
return data.filter((x) => new Date(x.event_date) >= date)
114110
}, [data, date])
115111

116112
useEffect(() => {
117113
if (!data) return onDatesUpdate(EMPTY_LIST)
118-
onDatesUpdate(uniq(data.map((x) => new Date(x.start_at).toLocaleDateString())))
114+
onDatesUpdate(uniq(data.map((x) => new Date(x.event_date).toLocaleDateString())))
119115
}, [onDatesUpdate, data])
120116

121117
if (isLoading) {
@@ -148,29 +144,31 @@ export function EventList({ date, onDatesUpdate }: EventListProps) {
148144
<div className={classes.paddingWrap}>
149145
{comingEvents.map((entry) => {
150146
return (
151-
<div key={entry.api_id}>
147+
<div key={entry.event_id}>
152148
<Typography className={classes.dateDiv}>
153-
{format(new Date(entry.start_at), 'MMM dd,yyy')}
149+
{format(new Date(entry.event_date), 'MMM dd,yyy')}
154150
</Typography>
155151
<Link
156152
className={classes.eventCard}
157-
href={entry.event.url}
153+
href={entry.event_url}
158154
rel="noopener noreferrer"
159155
target="_blank">
160156
<div className={classes.eventHeader}>
161157
<div className={classes.projectWrap}>
162158
<Image
163-
src={resolveIPFS_URL(entry.event.cover_url)}
159+
src={resolveIPFS_URL(entry.poster_url)}
164160
classes={{ container: classes.logo }}
165161
size={24}
166-
alt={entry.event.name}
162+
alt={entry.event_title}
167163
/>
168-
<Typography className={classes.projectName}>{entry.event.name}</Typography>
164+
<Typography className={classes.projectName}>{entry.event_title}</Typography>
169165
</div>
170166
</div>
171-
<Typography className={classes.eventTitle}>{entry.event.name}</Typography>
172-
<Typography className={classes.time}>{formatDate(entry.start_at)}</Typography>
173-
<ImageLoader src={entry.event.cover_url} />
167+
<Typography className={classes.eventTitle}>{entry.event_title}</Typography>
168+
<Typography className={classes.time}>
169+
{format(new Date(date), 'MMM dd, yyyy HH:mm')}
170+
</Typography>
171+
<ImageLoader src={entry.poster_url} />
174172
</Link>
175173
</div>
176174
)

packages/plugins/Calendar/src/SiteAdaptor/components/Footer.tsx

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { ApplicationSettingTabs, useOpenApplicationSettings } from '@masknet/sha
33
import { PluginID } from '@masknet/shared-base'
44
import { makeStyles } from '@masknet/theme'
55
import { IconButton, Typography } from '@mui/material'
6-
import { type ReactNode } from 'react'
76
import { Trans } from '@lingui/macro'
87

98
const useStyles = makeStyles()((theme) => ({
@@ -60,32 +59,25 @@ const useStyles = makeStyles()((theme) => ({
6059
}))
6160

6261
export interface FooterProps {
63-
provider: string
64-
disableSetting?: boolean
62+
tab: 'news' | 'events'
6563
}
6664

67-
export function Footer({ provider, disableSetting }: FooterProps) {
65+
export function Footer({ tab }: FooterProps) {
6866
const { classes } = useStyles()
69-
const providerMap: Record<string, ReactNode> = {
67+
const providerMap = {
7068
news: (
7169
<>
7270
<Typography className={classes.providerName}>CoinCarp</Typography>
7371
<Icons.CoinCarp size={24} />
7472
</>
7573
),
76-
event: (
74+
events: (
7775
<>
78-
<Typography className={classes.providerName}>LINK3</Typography>
79-
<Icons.Link3 size={24} />
76+
<Typography className={classes.providerName}></Typography>
77+
<Icons.Luma size={24} />
8078
</>
8179
),
82-
nfts: (
83-
<>
84-
<Typography className={classes.providerName}>NFTGO</Typography>
85-
<Icons.NFTGo size={24} />
86-
</>
87-
),
88-
}
80+
} as const
8981
const openApplicationBoardDialog = useOpenApplicationSettings()
9082
return (
9183
<div className={classes.container}>
@@ -98,17 +90,15 @@ export function Footer({ provider, disableSetting }: FooterProps) {
9890
</div>
9991
<div className={classes.poweredByWrap}>
10092
<Typography className={classes.poweredBy} component="div">
101-
<Trans>Powered By {providerMap[provider]}</Trans>
93+
<Trans>Powered By {providerMap[tab]}</Trans>
10294
</Typography>
103-
{disableSetting ? null : (
104-
<IconButton
105-
sx={{ width: '16px', height: '16px' }}
106-
onClick={() =>
107-
openApplicationBoardDialog(ApplicationSettingTabs.pluginSwitch, PluginID.Calendar)
108-
}>
109-
<Icons.Gear size={16} />
110-
</IconButton>
111-
)}
95+
<IconButton
96+
sx={{ width: '16px', height: '16px' }}
97+
onClick={() =>
98+
openApplicationBoardDialog(ApplicationSettingTabs.pluginSwitch, PluginID.Calendar)
99+
}>
100+
<Icons.Gear size={16} />
101+
</IconButton>
112102
</div>
113103
</div>
114104
</div>

0 commit comments

Comments
 (0)