Skip to content

Commit f725404

Browse files
Update volunteer page to reflect new db structure
1 parent 6096bd8 commit f725404

File tree

1 file changed

+22
-31
lines changed

1 file changed

+22
-31
lines changed

src/pages/volunteer.astro

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import BackOnTrackLayout from "../layouts/BackOnTrackLayout.astro";
33
import PocketBase from "pocketbase";
44
55
const pb = new PocketBase("https://pb.backontrackus.org");
6+
pb.autoCancellation(false);
67
7-
const records = await pb.collection("locations").getFullList({
8+
const locations = await pb.collection("locations").getFullList({
89
filter: "inactive = false",
910
sort: "+name",
1011
});
@@ -26,42 +27,32 @@ const records = await pb.collection("locations").getFullList({
2627
</h2>
2728
<hr class="my-5 w-2/3 border-t border-white" />
2829
<div
29-
class="m-5 grid w-1/2 grid-cols-1 place-items-center gap-5 md:grid-cols-2"
30+
class="mb-10 grid w-1/2 grid-cols-1 place-items-center gap-5 md:grid-cols-2"
3031
>
3132
{
32-
records.map((record) => {
33-
if (record.remind || record.groupme || record.whatsapp) {
33+
locations.map(async (location) => {
34+
const links = await pb.collection("links").getFullList({
35+
filter: `location.id = "${location.id}"`,
36+
});
37+
console.log(links);
38+
if (links.length > 0) {
3439
return (
3540
<div class="flex flex-col items-center justify-center gap-3">
3641
<p class="text-center text-3xl font-bold text-white md:text-4xl">
37-
{record.name}
42+
{location.name}
3843
</p>
39-
<div class="flex items-center justify-center gap-2">
40-
{record.remind && (
41-
<a
42-
href={record.remind}
43-
class="block rounded border-b-4 border-blue-700 bg-blue-500 px-4 py-2 font-bold text-white hover:border-blue-500 hover:bg-blue-400"
44-
>
45-
Remind
46-
</a>
47-
)}
48-
{record.groupme && (
49-
<a
50-
href={record.groupme}
51-
class="block rounded border-b-4 border-blue-700 bg-blue-500 px-4 py-2 font-bold text-white hover:border-blue-500 hover:bg-blue-400"
52-
>
53-
GroupMe
54-
</a>
55-
)}
56-
{record.whatsapp && (
57-
<a
58-
href={record.whatsapp}
59-
class="block rounded border-b-4 border-blue-700 bg-blue-500 px-4 py-2 font-bold text-white hover:border-blue-500 hover:bg-blue-400"
60-
>
61-
WhatsApp
62-
</a>
63-
)}
64-
</div>
44+
{links.map((link) => {
45+
return (
46+
<div class="flex items-center justify-center gap-2">
47+
<a
48+
href={link.url}
49+
class="block rounded border-b-4 border-blue-700 bg-blue-500 px-4 py-2 font-bold text-white hover:border-blue-500 hover:bg-blue-400"
50+
>
51+
{link.name}
52+
</a>
53+
</div>
54+
);
55+
})}
6556
</div>
6657
);
6758
}

0 commit comments

Comments
 (0)