summaryrefslogtreecommitdiff
path: root/src/routes/team/index.svelte
blob: 3d27c0eb3492ec357e6b0c9d71313891c80e57bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<script>
  import DirectionCard from '../../components/DirectionCard.svelte';

  import { onMount } from 'svelte';
  import { supabase } from '$lib/supabase';

  const getPeople = async () => {
    const { data, error } = await supabase.from('people').select();
    if (!error) {
      return data;
    }
    return [];
  }

  const mapImages = (people) => {
    return people.map((x) => {
      const { publicURL, error } = supabase
        .storage
        .from('mistymountains')
        .getPublicUrl(x.image);
      if (!error) {
        return { ...x, image: publicURL };
      }
      return x;
    });
  }

  let people = [];
  onMount(async () => {
    people = await getPeople().then(mapImages);
  });
</script>

<main>
  <h1 class="text-center">Our Team</h1>
  {#if people.length}
    {#each people as person, i}
      <div class="row border-bottom">
        <DirectionCard imageSpec={{image: person.image, alt: person.name}} direction={i % 2 ? 'left' : 'right'}>
          <h2>{person.name}, {person.position}</h2>
          <p>{person.bio}</p>
          <a href="mailto:{person.email}"><p>{person.email}</p></a>
        </DirectionCard>
      </div>
    {/each}
  {/if}
</main>