Skip to content

Commit e9999cd

Browse files
committed
members: ask signup referral source
1 parent eecf42e commit e9999cd

8 files changed

Lines changed: 434 additions & 201 deletions

File tree

modules/admin/member.templ

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type member struct {
2222
Confirmed bool
2323
Created engine.LocalTime
2424
AdminNotes string
25+
HeardAbout string
2526
Leadership bool
2627
NonBillable bool
2728
FobID *int64
@@ -48,11 +49,11 @@ type memberEvent struct {
4849
func querySingleMember(ctx context.Context, db *sql.DB, id string) (*member, []*memberEvent, error) {
4950
mem := member{}
5051
err := db.QueryRowContext(ctx, `
51-
SELECT m.id, m.access_status, m.name, m.name_override, m.email, m.confirmed, m.created, COALESCE(m.fob_id, 0), m.admin_notes, m.leadership, m.non_billable, m.stripe_customer_id, m.stripe_subscription_id, m.stripe_subscription_state, m.paypal_subscription_id, m.paypal_price, m.discount_type, m.discount_status, COALESCE(rfm.email, ''), m.bill_annually, m.fob_last_seen, COALESCE(m.discord_user_id, ''), COALESCE(m.discord_username, '')
52+
SELECT m.id, m.access_status, m.name, m.name_override, m.email, m.confirmed, m.created, COALESCE(m.fob_id, 0), m.admin_notes, COALESCE(m.heard_about, ''), m.leadership, m.non_billable, m.stripe_customer_id, m.stripe_subscription_id, m.stripe_subscription_state, m.paypal_subscription_id, m.paypal_price, m.discount_type, m.discount_status, COALESCE(rfm.email, ''), m.bill_annually, m.fob_last_seen, COALESCE(m.discord_user_id, ''), COALESCE(m.discord_username, '')
5253
FROM members m
5354
LEFT JOIN members rfm ON m.root_family_member = rfm.id
5455
WHERE m.id = $1`, id).
55-
Scan(&mem.ID, &mem.AccessStatus, &mem.Name, &mem.NameOverride, &mem.Email, &mem.Confirmed, &mem.Created, &mem.FobID, &mem.AdminNotes, &mem.Leadership, &mem.NonBillable, &mem.StripeCustomerID, &mem.StripeSubID, &mem.StripeStatus, &mem.PaypalSubID, &mem.PaypalPrice, &mem.DiscountType, &mem.DiscountStatus, &mem.RootFamilyEmail, &mem.BillAnnually, &mem.FobLastSeen, &mem.DiscordUserID, &mem.DiscordUsername)
56+
Scan(&mem.ID, &mem.AccessStatus, &mem.Name, &mem.NameOverride, &mem.Email, &mem.Confirmed, &mem.Created, &mem.FobID, &mem.AdminNotes, &mem.HeardAbout, &mem.Leadership, &mem.NonBillable, &mem.StripeCustomerID, &mem.StripeSubID, &mem.StripeStatus, &mem.PaypalSubID, &mem.PaypalPrice, &mem.DiscountType, &mem.DiscountStatus, &mem.RootFamilyEmail, &mem.BillAnnually, &mem.FobLastSeen, &mem.DiscordUserID, &mem.DiscordUsername)
5657
if err != nil {
5758
return nil, nil, err
5859
}
@@ -103,8 +104,8 @@ func queryMemberEvents(ctx context.Context, db *sql.DB, memberID int64, limit, o
103104
var _ = handlePostForm(formHandler{
104105
Path: "/admin/members/{id}/updates/basics",
105106
Handler: &engine.FormHandler{
106-
Fields: []string{"name", "email", "confirmed", "fob_id", "admin_notes", "bill_annually", "discord_user_id"},
107-
Query: `UPDATE members SET name_override = (CASE WHEN :name = name OR :name = '' THEN NULL ELSE :name END), email = :email, admin_notes = :admin_notes,
107+
Fields: []string{"name", "email", "confirmed", "fob_id", "admin_notes", "heard_about", "bill_annually", "discord_user_id"},
108+
Query: `UPDATE members SET name_override = (CASE WHEN :name = name OR :name = '' THEN NULL ELSE :name END), email = :email, admin_notes = :admin_notes, heard_about = :heard_about,
108109
discord_user_id = (CASE WHEN :discord_user_id != '' THEN :discord_user_id ELSE NULL END),
109110
confirmed = (CASE WHEN :confirmed = 'on' THEN 1 ELSE 0 END),
110111
bill_annually = (CASE WHEN :bill_annually = 'on' THEN 1 ELSE 0 END),
@@ -212,6 +213,10 @@ templ renderSingleMember(tabs []*navbarTab, member *member, events []*memberEven
212213
<input type="checkbox" class="form-check-input" id="bill_annually" name="bill_annually" checked?={ member.BillAnnually }/>
213214
<label class="form-check-label" for="bill_annually" style="margin-left: 5px;">Bill Annually</label>
214215
</div>
216+
<div class="form-floating mb-2">
217+
<input type="text" class="form-control" id="heard_about" name="heard_about" value={ member.HeardAbout } placeholder="How they heard about us"/>
218+
<label for="heard_about">Heard About Makerspace</label>
219+
</div>
215220
<div class="form-floating mb-2">
216221
<textarea class="form-control" id="admin_notes" name="admin_notes" style="height: 100px">{ member.AdminNotes }</textarea>
217222
<label for="admin_notes" class="form-label">Admin Notes</label>

modules/admin/member_templ.go

Lines changed: 164 additions & 150 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/auth/login.templ

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,36 @@ templ renderLoginSentPage(email string) {
130130
}
131131
}
132132

133-
templ renderSignupConfirmPage(email string, confirmToken string, callbackURI string) {
133+
templ renderSignupConfirmPage(email string, confirmToken string, callbackURI string, referralSources []string, selectedReferralSource string, errorMessage string) {
134134
@bootstrap.View() {
135135
<div class="d-flex align-items-center justify-content-center vh-100 p-3">
136136
<div class="card p-4" style="max-width: 450px;">
137-
<div class="text-center">
138-
<h1 class="h5 mb-3">Create a New Account?</h1>
137+
<div>
138+
<h1 class="h5 mb-3 text-center">Create a New Account?</h1>
139139
<p class="text-muted mb-3">
140140
We don't have an account for <strong>{ email }</strong>.
141141
</p>
142142
<p class="text-muted mb-4">
143143
If you already have an account, you may have signed up with a different email address. Would you like to create a new account with this email?
144144
</p>
145+
if errorMessage != "" {
146+
<div class="alert alert-danger" role="alert">{ errorMessage }</div>
147+
}
145148
<form action="/login/confirm-signup" method="post">
146149
<input type="hidden" name="confirm_token" value={ confirmToken }/>
147150
<input type="hidden" name="callback_uri" value={ callbackURI }/>
151+
if len(referralSources) > 0 {
152+
<div class="mb-4">
153+
<label for="heard_about" class="form-label">How did you hear about the Makerspace?</label>
154+
<select class="form-select" id="heard_about" name="heard_about" required aria-describedby="heard_about_help">
155+
<option value="" selected?={ selectedReferralSource == "" }>Choose one...</option>
156+
for _, source := range referralSources {
157+
<option value={ source } selected?={ selectedReferralSource == source }>{ source }</option>
158+
}
159+
</select>
160+
<div id="heard_about_help" class="form-text">This helps us understand which outreach is working.</div>
161+
</div>
162+
}
148163
<button type="submit" class="btn btn-primary w-100 mb-2">Yes, Create Account</button>
149164
</form>
150165
<a href="/login" class="btn btn-outline-secondary w-100">Go Back</a>

0 commit comments

Comments
 (0)