Skip to content

Commit

Permalink
chore: reorder code
Browse files Browse the repository at this point in the history
  • Loading branch information
PaiJi committed Nov 4, 2023
1 parent d0a9ea6 commit c638c74
Showing 1 changed file with 40 additions and 36 deletions.
76 changes: 40 additions & 36 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import { EventScale, EventStatus } from "@/types/event";
import { Switch } from "@headlessui/react";
import { sendTrack } from "@/utils/track";

enum DurationType {
Passed = "passed", //already done.
Now = "now", // in the duration of event.
Soon = "soon", // in the same month of event start date.
Next = "next", // not start yet but plan in this year.
NextYear = "nextYear", // in the next year
}

export default function Home(props: { events: Event[] }) {
const [selectedFilter, setFilter] = useState({
onlyAvailable: false,
Expand Down Expand Up @@ -138,42 +146,6 @@ export default function Home(props: { events: Event[] }) {
);
}

export async function getStaticProps() {
const xata = new XataClient();
const events = await xata.db.event
.filter({
startDate: { $ge: new Date(new Date().getFullYear(), 0, 1) },
})
.select([
"name",
"address",
"city",
"coverUrl",
"logoUrl",
"startDate",
"endDate",
"slug",
"status",
"scale",
"organization.name",
"organization.logoUrl",
"organization.slug",
])
.getAll();
return {
props: {
events,
},
};
}

enum DurationType {
Passed = "passed", //already done.
Now = "now", // in the duration of event.
Soon = "soon", // in the same month of event start date.
Next = "next", // not start yet but plan in this year.
NextYear = "nextYear", // in the next year
}
function DurationSection({
durationType,
events,
Expand Down Expand Up @@ -306,3 +278,35 @@ function Filter({
</div>
);
}

export async function getStaticProps() {
const xata = new XataClient();
const events = await xata.db.event
.filter({
startDate: { $ge: new Date(new Date().getFullYear(), 0, 1) },
$not: {
status: EventStatus.EventCancelled
}
})
.select([
"name",
"address",
"city",
"coverUrl",
"logoUrl",
"startDate",
"endDate",
"slug",
"status",
"scale",
"organization.name",
"organization.logoUrl",
"organization.slug",
])
.getAll();
return {
props: {
events,
},
};
}

0 comments on commit c638c74

Please sign in to comment.