Skip to content

Commit 432cfa4

Browse files
committed
Refactor event fetching logic by consolidating getAtprotoEvents function into a single utility import. Update ESLint configuration for compatibility and improve type annotations in Event component.
1 parent 2f9b6f9 commit 432cfa4

6 files changed

Lines changed: 29 additions & 50 deletions

File tree

devconnect-app/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const compat = new FlatCompat({
1010
});
1111

1212
const eslintConfig = [
13-
...compat.extends(['next/core-web-vitals']),
13+
...compat.extends('next/core-web-vitals'),
1414
];
1515

1616
export default eslintConfig;

devconnect-app/src/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import HomePageContent from './page-content';
2-
import { getAtprotoEvents } from './worlds-fair/page';
2+
import { getAtprotoEvents } from '@/utils/atproto-events';
33

44
export default async function HomePage() {
55
const atprotoEvents = await getAtprotoEvents();

devconnect-app/src/app/schedule/page.tsx

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
import ProgrammePageContent from './page-content';
2-
import { apiResultToCalendarFormat } from 'lib/components/event-schedule-new/atproto-to-calendar-format';
3-
4-
export async function getAtprotoEvents() {
5-
try {
6-
const atprotoEvents = await fetch(
7-
process.env.NODE_ENV === 'development' && !process.env.FORCE_PROD_ENV
8-
? 'http://localhost:4000/calendar-events'
9-
: 'https://at-slurper.onrender.com/calendar-events',
10-
{
11-
next: { revalidate: 300 }, // Cache for 5 minutes
12-
}
13-
);
14-
15-
const atprotoEventsData = await atprotoEvents.json();
16-
17-
const formattedAtprotoEvents = apiResultToCalendarFormat(atprotoEventsData);
18-
19-
return formattedAtprotoEvents;
20-
} catch (error) {
21-
console.error(error);
22-
return [];
23-
}
24-
}
2+
import { getAtprotoEvents } from '@/utils/atproto-events';
253

264
export default async function ProgrammePage() {
275
const atprotoEvents = await getAtprotoEvents();

devconnect-app/src/app/worlds-fair/page.tsx

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
import ProgrammePageContent from './page-content';
2-
import { apiResultToCalendarFormat } from 'lib/components/event-schedule-new/atproto-to-calendar-format';
3-
4-
export async function getAtprotoEvents() {
5-
try {
6-
const atprotoEvents = await fetch(
7-
process.env.NODE_ENV === 'development' && !process.env.FORCE_PROD_ENV
8-
? 'http://localhost:4000/calendar-events'
9-
: 'https://at-slurper.onrender.com/calendar-events',
10-
{
11-
next: { revalidate: 300 }, // Cache for 5 minutes
12-
}
13-
);
14-
15-
const atprotoEventsData = await atprotoEvents.json();
16-
17-
const formattedAtprotoEvents = apiResultToCalendarFormat(atprotoEventsData);
18-
19-
return formattedAtprotoEvents;
20-
} catch (error) {
21-
console.error(error);
22-
return [];
23-
}
24-
}
2+
import { getAtprotoEvents } from '@/utils/atproto-events';
253

264
export default async function ProgrammePage() {
275
const atprotoEvents = await getAtprotoEvents();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { apiResultToCalendarFormat } from 'lib/components/event-schedule-new/atproto-to-calendar-format';
2+
3+
export async function getAtprotoEvents() {
4+
try {
5+
const atprotoEvents = await fetch(
6+
process.env.NODE_ENV === 'development' && !process.env.FORCE_PROD_ENV
7+
? 'http://localhost:4000/calendar-events'
8+
: 'https://at-slurper.onrender.com/calendar-events',
9+
{
10+
next: { revalidate: 300 }, // Cache for 5 minutes
11+
}
12+
);
13+
14+
const atprotoEventsData = await atprotoEvents.json();
15+
16+
const formattedAtprotoEvents = apiResultToCalendarFormat(atprotoEventsData);
17+
18+
return formattedAtprotoEvents;
19+
} catch (error) {
20+
console.error(error);
21+
return [];
22+
}
23+
}

lib/components/event-schedule-new/event/event.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ const ExportEvent = ({
228228
);
229229
};
230230

231-
const Event: React.FC<EventProps> = ({
231+
function Event({
232232
compact,
233233
event,
234234
isDialog,
@@ -238,7 +238,7 @@ const Event: React.FC<EventProps> = ({
238238
setExports,
239239
toggleFavoriteEvent,
240240
favoriteEvents,
241-
}) => {
241+
}: EventProps): React.JSX.Element {
242242
const [showMobileProgramming, setShowMobileProgramming] = useState(false);
243243
const [imageLoaded, setImageLoaded] = useState(false);
244244
const imageRef = useRef<any>(null);

0 commit comments

Comments
 (0)