Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deactivates the pupil signup for selected chapters #98

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib/ChapterList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

export let chapters: Chapter[]

const openChapters = chapters.filter((ch) => ch.acceptsSignups)
const openChapters = chapters.filter((ch) => ch.status == `active`)
const startingChapters = chapters.filter((ch) => ch.status == `starting`)
const partnerChapters = chapters.filter((ch) => ch.status == `partner`)
</script>
Expand All @@ -19,7 +19,7 @@
<li><a href={slug}>{title}</a></li>
{/each}
</ol>
{#if startingChapters.length > 2}
{#if startingChapters.length > 0}
<h1>
<Icon icon="ic:round-construction" inline />
{$microcopy?.chapterList?.inSetup}
Expand All @@ -30,7 +30,7 @@
{/each}
</ol>
{/if}
{#if partnerChapters.length > 2}
{#if partnerChapters.length > 0}
<h1>
<Icon icon="ic:place" inline />
{$microcopy?.chapterList?.partner}
Expand Down
1 change: 1 addition & 0 deletions src/lib/ChapterMap.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { microcopy } from './stores'
import type { Chapter } from './types'

// why do we fetch chapters here? They were already passed to the function
export const load: Load = () => {
return { props: { chapters: fetch_chapters() } }
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ const chapters_query = `{
}
baseId
acceptsSignups
deactivatePupils
status
signup
token
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export type Chapter = {
}
baseId: string
acceptsSignups: boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is maybe not the most future-proof interface for managing signup state of chapters.

How about we use acceptsSignups: Record<'students' | 'pupils', boolean> = {students: true, pupils: false} ?

deactivatePupils: boolean
status: 'active' | 'starting' | 'partner' | null
signup: 'everyone' | 'onlyStudents' | 'nobody' | null
token: string
}

Expand Down
4 changes: 2 additions & 2 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const load = async () => {

// create { title, url } array containing all chapters
const chapterLinks = chapters.map((chapter: Chapter) => {
const { title, slug, acceptsSignups } = chapter
return { title, url: slug, lightFont: !acceptsSignups }
const { title, slug, status } = chapter
return { title, url: slug, lightFont: status == `starting` }
})

// prepend chapter links into chapter subnav
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<section style="white-space: nowrap;">
<div style="background: var(--light-blue);">
<span>{data.chapters.filter((ch) => ch.acceptsSignups).length}</span>
<span>{data.chapters.filter((ch) => ch.status == `active`).length}</span>
<strong>
<Icon inline icon="ic:place" {style} />
{$microcopy?.indexPage?.boxes?.locationsName}</strong
Expand Down
2 changes: 1 addition & 1 deletion src/routes/signup-pupil/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import raw_form from '../../signup-form/de/pupil.yml'

export const load = async () => {
let chapters = await fetch_chapters()
chapters = chapters.filter((chap) => chap.acceptsSignups)
chapters = chapters.filter((chap) => chap.signup == `everyone`)

const form = parse_form_data({ ...raw_form, ...messages })

Expand Down
4 changes: 3 additions & 1 deletion src/routes/signup-student/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import raw_form from '../../signup-form/de/student.yml'

export const load = async () => {
let chapters = await fetch_chapters()
chapters = chapters.filter((chap) => chap.acceptsSignups)
chapters = chapters.filter(
(chap) => chap.signup == `everyone` || chap.signup == `onlyStudents`
)

const form = parse_form_data({ ...raw_form, ...messages })

Expand Down
4 changes: 1 addition & 3 deletions src/routes/standorte/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@
<ChapterMap {chapters} />
<ChapterList {chapters} />

<BasePage {page}>
<h2 slot="title">🤗 Wir brauchen dich! 🤗</h2>
</BasePage>
<BasePage {page} />
7 changes: 6 additions & 1 deletion src/routes/standorte/[slug]/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { fetch_page } from '$lib/fetch'
import { error } from '@sveltejs/kit'
import { fetch_chapters } from '$lib/fetch'

export const load = async ({ params }) => {
const { slug } = params

const page = await fetch_page(`standorte/${slug}`)

const chapters = await fetch_chapters()

const selectedChapter = chapters.find((ch) => ch.slug == `/standorte/${slug}`)

if (!page) throw error(404)

return { page, slug }
return { page, slug, selectedChapter }
}
57 changes: 52 additions & 5 deletions src/routes/standorte/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import Icon from '@iconify/svelte'

export let data
$: ({ page, slug } = data)

$: ({ page, slug, selectedChapter } = data)
const style = `margin-right: 3pt;`
</script>

<BasePage {page}>
<!-- Buttons at the end of the chapter pages to contact the different chapter manager by mail
showSignupButtons should be set false when chapter is still in setup -->
{#if page?.yaml?.showSignupButtons !== false}
when selectedChapter is not defined show all buttons as default -->
{#if !selectedChapter?.signup || selectedChapter?.signup == `everyone`}
<h2 style="text-align: center; margin-top: 2em;">{$microcopy?.location?.register}</h2>
<section>
<span>
Expand Down Expand Up @@ -57,10 +56,58 @@
>
</span>
</section>
{:else if selectedChapter?.signup == `onlyStudents`}
<h2 style="text-align: center; margin-top: 2em;">{$microcopy?.location?.register}</h2>
<section>
<span>
{$microcopy?.location?.joinStudent}
<a href="/signup-student?chapter={page.title}" class="btn blue">
<Icon inline icon="fa-solid:graduation-cap" {style} />{$microcopy?.location
?.registerStudent}
</a>
<a href={$microcopy?.location?.linkStudentInfo} class="btn blue stroke">
<Icon
inline
icon="bi:info-circle-fill"
style={style + `margin-right: 6pt;`}
/>{$microcopy?.location?.infoStudentButton}
</a>
</span>
<span>
{$microcopy?.location?.joinPupil}
<a class="btn green">
<Icon inline icon="fa-solid:child" {style} />{$microcopy?.location
?.declinePupil}
</a>
<a href={$microcopy?.location?.linkPupilInfo} class="btn green stroke">
<Icon
inline
icon="bi:info-circle-fill"
style={style + `margin-right: 6pt;`}
/>{$microcopy?.location?.infoPupilButton}</a
>
</span>
<span>
{$microcopy?.location?.locationManagement}
<a
href="mailto:info.{slug}{$microcopy?.location?.mailTo} {page.title}"
class="btn orange"
>
<Icon inline icon="ic:email" {style} />{$microcopy?.location?.writeMailButton}
</a>
<a href={$microcopy?.location?.linkLeadingInfo} class="btn orange stroke">
<Icon
inline
icon="bi:info-circle-fill"
style={style + `margin-right: 6pt;`}
/>{$microcopy?.location?.infoLeadingButton}</a
>
</span>
</section>
{/if}

<svelte:fragment slot="afterBody">
{#if page?.yaml?.showSignupButtons !== false}
{#if selectedChapter?.signup !== `nobody`}
<h2 id="kontakt">{$microcopy?.location?.contact}</h2>
<p>{$microcopy?.location?.questions}</p>
<ul class="contact">
Expand Down
93 changes: 93 additions & 0 deletions src/signup-form/at/smallTexts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
comment: This yaml is both on github and on contentful for versioning and checking of correctness. Only the version on contentful is actually used!

country: at

indexPage:
title: Studenten bilden Schüler
theme: Kostenlose Nachhilfe von ehrenamtlichen Studierenden für finanziell benachteiligte Kinder
chooseLocation: 'Wähle deinen <a sveltekit:prefetch href="/standorte"><strong>Standort</strong></a> auf der Karte!'

register:
'Oder melde dich direkt <a sveltekit:prefetch href="/signup-student">
<strong>bei uns an.</strong>
</a>'
boxes:
locationsName: Standorte
studentsName: Studierende
studentsNumber: 3
pupilsName: Schüler:innen
pupilsNumber: 5
scholarshipName: Gründung
scholarshipNumber: 2023
organizationMemberName: Vereinsmitglieder
organizationMemberNumber: 10

footer:
name: 'Studenten bilden Schüler e.V.'
siteInfos: 'Diese Seite ist
<a href="https://github.com/sbsev/svelte-site">
<OpenSource
height="2.5ex"
style="vertical-align: bottom; padding-right: 3pt;"
/>open source
</a>
und verwendet keine
<a href="https://de.wikipedia.org/wiki/HTTP-Cookie">
use
<Cookie height="2.2ex" style="vertical-align: middle;" />
cookies.
</a>'
site: 'Diese Seite ist'
uses: 'und verwendet keine'

map:
location:
lng: 13.55
lat: 47.71
zoom: 6.00
minZoom: 4
maxZoom: 10
text:
active: 'aktiver Standort'
inSetup: 'in Gründung'
partner: 'Partner'

chapterList:
locations: 'Unsere Standorte'
inSetup: 'Standorte in Gründung'
partner: 'Partner Standorte'

location:
register: 'Anmeldungen'
joinStudent: 'Willst du bei uns mitmachen?'
registerStudent: 'Als Student:in anmelden'
linkStudentInfo: '/mitmachen/nachhilfelehrer'
infoStudentButton: 'Infos für Studierende'
joinPupil: 'Suchst du Nachhilfe?'
registerPupil: 'Als Schüler:in anmelden'
linkPupilInfo: '/mitmachen/schueler'
infoPupilButton: 'Infos für Schüler:innen'
locationManagement: 'Interesse an Standortleitung?'
mailTo: 'mailto:info.{slug}@studenten-bilden-schueler.de?subject=Interesse an Standortleitung in {page.title}'
writeMailButton: 'Schreib uns'
linkLeadingInfo: '/mitmachen/standortleiter'
infoLeadingButton: 'Infos für Standortleitende'
contact: 'Kontakt'
questions: 'Noch Fragen? Schreib uns eine Mail!'
url: 'studenten-bilden-schueler.de'
student: 'studenten'
forStudents: 'für Studierende'
pupil: 'schueler'
info: 'info'
forPartner: 'für Soziale Einrichtungen und Nachhilfeanfragen'
generalRequests: 'für Allgemeine Anfragen'

basepage:
last: 'Zuletzt bearbeitet:'
feedback: 'Feedback zu dieser Seite?'
email: 'it@studenten-bilden-schueler.de?subject=Feedback zu Seite:'

meta:
name: 'Studenten bilden Schüler e.V.'
description: 'Ehrenamtliche Nachhilfe von Studierenden für Schüler:innen in deutschlandweit über 50 Unistädten.'
url: studenten-bilden-schueler.de
Loading