Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
run: |
# A new role assignment can take a few minutes to apply.
for i in $(seq 1 20); do
infra/scripts/bootstrap-secrets.sh "${{ steps.base.outputs.kv }}" site_afterh site_hfriends site_datealittle && exit 0
infra/scripts/bootstrap-secrets.sh "${{ steps.base.outputs.kv }}" site_afterh site_hfriends site_datealittle site_swingandscore && exit 0
echo "waiting for Key Vault access…"; sleep 30
done
exit 1
Expand Down
13 changes: 8 additions & 5 deletions apps/api/scripts/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// First-time setup for a real (prod) environment. Safe to re-run and never deletes anything:
// - adds BOOTSTRAP_ADMIN_EMAIL as a Platform Admin (owner of the WhatBox sites) if not there yet
// - creates AfterH, HFriends and DateALittle with their default settings, real domains only and
// no members, unless a site with that id already exists (an existing site is left untouched)
// - creates AfterH, HFriends, DateALittle and SwingAndScore with their default settings, real domains only,
// no members and their starter pages, unless a site with that id already exists (an existing site is left untouched)
// The site's database already exists: the migrate job runs first and creates one for every built-in site.
// Runs as the `bootstrap` job, started by the deploy workflow when an admin email is given.
import { seedSites, type Site } from '@whatbox/core';
import { addStarterPages, seedSites, type Site } from '@whatbox/core';
import { closePools, pool } from '../src/db';
import { config } from '../src/config';
import { PgControlRepo } from '../src/pg-repo';
import { PgControlRepo, PgSiteRepo, siteDbName } from '../src/pg-repo';

(async () => {
const email = (process.env.BOOTSTRAP_ADMIN_EMAIL ?? '').trim().toLowerCase();
Expand All @@ -33,7 +34,9 @@ import { PgControlRepo } from '../src/pg-repo';
createdAt: now.toISOString(),
};
await control.saveSite(site);
console.log(`${site.slug}: created (${site.domains.join(', ')})`);
const pages = await addStarterPages(site, new PgSiteRepo(pool(siteDbName(site.slug))), now);
await control.saveSite(site); // remembers which starter pages were added
console.log(`${site.slug}: created (${site.domains.join(', ')}), ${pages.length} pages`);
}
await closePools();
})().catch((e) => { console.error(e); process.exit(1); });
2 changes: 1 addition & 1 deletion apps/api/scripts/smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const base = process.env.API_URL ?? 'http://localhost:4000';
const st = await admin.start(DEMO_OWNER_EMAIL);
admin.setToken((await admin.verify(st.challengeId, st.devCode!)).token);
const adm = await admin.me();
assert.equal(adm.sites.length, 3);
assert.equal(adm.sites.length, 4);
const queue = await admin.moderation('site_afterh', 'pending');
assert.ok(queue.some((q) => q.kind === 'message' && q.messageBody?.includes('gift card')));
const site2 = await admin.updateSite('site_afterh', { settings: { membership: { paywallEnabled: true } } });
Expand Down
6 changes: 3 additions & 3 deletions apps/member/src/app/(app)/activity.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Activity: "Liked you" is built for busy inboxes. Priority likes come first, then people who fit
// what you asked for, then serious profiles. Quick filters and one-tap like back or pass.
import type { ActivityList, ActivityPerson, Tier } from '@whatbox/core';
import { agesLabel, type ActivityList, type ActivityPerson, type Tier } from '@whatbox/core';
import { TONES } from '@whatbox/core';
import { router } from 'expo-router';
import { useCallback, useEffect, useMemo, useState } from 'react';
Expand Down Expand Up @@ -114,7 +114,7 @@ export default function Activity() {
<Grid min={190} gap={14}>
{shown.map((p) => (
<View key={p.id} style={{ backgroundColor: t.surface, borderWidth: p.vip ? 2 : 1, borderColor: p.vip ? '#D9A43A' : t.line, borderRadius: 16, overflow: 'hidden', opacity: done[p.id] === 'passed' ? 0.45 : 1 }}>
<Pressable onPress={() => router.push(`/member/${p.id}`)} accessibilityLabel={`${p.displayName}, ${p.age}. Open profile`}>
<Pressable onPress={() => router.push(`/member/${p.id}`)} accessibilityLabel={`${p.displayName}, ${agesLabel(p)}. Open profile`}>
<PhotoTile photo={p.mainPhoto} radius={0} style={{ height: 180 }}>
<View style={{ position: 'absolute', top: 8, left: 8, gap: 4, alignItems: 'flex-start' }}>
{p.vip ? <Badge label="★ VIP" tone="alert" /> : null}
Expand All @@ -124,7 +124,7 @@ export default function Activity() {
</PhotoTile>
</Pressable>
<View style={{ padding: 10, gap: 2 }}>
<Txt bold>{p.displayName}, {p.age}</Txt>
<Txt bold>{p.displayName}, {agesLabel(p)}</Txt>
<Txt sub size={13}>{p.city} · {relTime(p.at)}</Txt>
<View style={{ flexDirection: 'row', gap: 6, flexWrap: 'wrap', marginTop: 2 }}>
{p.fitsMe ? <Txt size={12} color={t.accent} bold>Fits you</Txt> : null}
Expand Down
10 changes: 7 additions & 3 deletions apps/member/src/app/(app)/browse.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GENDERS, tierFor, type MemberCard, type SearchFilters, type SearchResult } from '@whatbox/core';
import { agesLabel, COUPLE_MIXES, coupleLabel, GENDERS, tierFor, type MemberCard, type SearchFilters, type SearchResult } from '@whatbox/core';
import { router } from 'expo-router';
import { useCallback, useEffect, useState } from 'react';
import { Platform, Pressable, ScrollView, useWindowDimensions, View } from 'react-native';
Expand Down Expand Up @@ -58,7 +58,10 @@ export default function Browse() {
};
const filterable = site.fields.filter((f) => f.filterable && (f.type === 'select' || f.type === 'multiselect'));
const moreCount = filterable.filter((f) => draft.fields?.[f.key]?.length).length;
const seekingLabel = (me!.member.seeking ?? []).map((v) => GENDERS.find((g) => g.value === v)?.plural ?? v).join(', ') || 'Everyone';
const seekingLabel = [
...(site.couples ? (me!.member.seekingCouples ?? []).map((c) => COUPLE_MIXES.find((x) => x.value === c)?.label ?? c) : []),
...(me!.member.seeking ?? []).map((v) => { const pl = GENDERS.find((g) => g.value === v)?.plural ?? v; return site.couples ? `Single ${pl.replace(/^(Women|Men)$/, (x) => x.toLowerCase())}` : pl; }),
].join(', ') || 'Everyone';
const digits = (v: string) => v.replace(/\D/g, '').slice(0, 2);

const panel = (
Expand Down Expand Up @@ -179,14 +182,15 @@ function PersonCard({ p, width, onLiked }: { p: MemberCard; width: any; onLiked:
{p.vip ? <Badge label="★ VIP" tone="alert" /> : null}
{p.online ? <Badge label="Online" tone="online" /> : null}
{p.isNew ? <Badge label="New" /> : null}
{p.couple ? <Badge label={coupleLabel(p)} tone="dark" /> : null}
</View>
<View style={{ position: 'absolute', top: 12, right: 12 }}><Badge label={`${p.photoCount} photo${p.photoCount === 1 ? '' : 's'}`} tone="dark" /></View>
</PhotoTile>
</Pressable>
<View style={{ padding: 14, paddingTop: 12, gap: 2 }}>
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 8 }}>
<Pressable onPress={() => router.push(`/member/${p.id}`)} style={{ flex: 1 }}>
<Txt bold size={18}>{p.displayName}, {p.age}</Txt>
<Txt bold size={18}>{p.displayName}, {agesLabel(p)}</Txt>
</Pressable>
<Pressable
role="button" accessibilityLabel={p.likedByMe ? `Unlike ${p.displayName}` : `Like ${p.displayName}`}
Expand Down
4 changes: 2 additions & 2 deletions apps/member/src/app/(app)/discover.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Discover: one blended stack (active, new and good-fit people together), reviewed one at a time.
// Phones swipe; the web uses the X and heart buttons or the arrow keys.
import type { DiscoverCard } from '@whatbox/core';
import { agesLabel, type DiscoverCard } from '@whatbox/core';
import { router } from 'expo-router';
import { useCallback, useEffect, useRef, useState } from 'react';
import { Animated, PanResponder, Platform, Pressable, ScrollView, View } from 'react-native';
Expand Down Expand Up @@ -146,7 +146,7 @@ export default function Discover() {
</Pressable>
<Pressable onPress={() => router.push(`/member/${top.id}`)} accessibilityLabel={`Open ${top.displayName}'s full profile`} style={{ padding: 16, gap: 6, backgroundColor: t.surface }}>
<View style={{ flexDirection: 'row', alignItems: 'baseline', gap: 8, flexWrap: 'wrap' }}>
<Txt bold size={22}>{top.displayName}, {top.age}</Txt>
<Txt bold size={22}>{top.displayName}, {agesLabel(top)}</Txt>
<Txt sub size={14}>{top.city}{top.miles !== null ? ` · ${awayLabel(top.miles, me!.member.unitsResolved)}` : ''}</Txt>
</View>
{top.facts.length ? <Txt size={14} color={t.accent} bold numberOfLines={1}>{top.facts.join(' · ')}</Txt> : null}
Expand Down
22 changes: 15 additions & 7 deletions apps/member/src/app/(app)/me.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ApiError, DEFAULT_NOTIFY, DEFAULT_STRICT, GENDERS, type NotifyPrefs, type AccessRow, type Gender, type Member, type HiddenPrefs, type StrictPrefs } from '@whatbox/core';
import { agesLabel, ApiError, type CoupleMix, DEFAULT_NOTIFY, DEFAULT_STRICT, GENDERS, type NotifyPrefs, type AccessRow, type Gender, type Member, type HiddenPrefs, type StrictPrefs } from '@whatbox/core';
import { router, useLocalSearchParams } from 'expo-router';
import { useCallback, useEffect, useState } from 'react';
import { Pressable, ScrollView, View } from 'react-native';
import { useBilling } from '../../lib/billing';
import { useSession } from '../../lib/session';
import { FieldsEditor } from '../../ui/FieldsEditor';
import { CoupleBasics, CoupleFields, partnerDraft, partnerPatch, SeekingBoth, type PartnerDraft } from '../../ui/CoupleEditor';
import { Avatar, Badge, Btn, Card, ChipPicker, ErrorText, Field, H, Notice, relTime, Segmented, Toggle, Txt, useTheme } from '../../ui/kit';
import { LocationPicker, type PickedLocation } from '../../ui/LocationPicker';
import { DISTANCE_STEPS, distanceLabel } from '../../lib/distance';
Expand Down Expand Up @@ -59,18 +60,24 @@ function ProfileTab() {
const units = m.unitsResolved;
const plural = (v: Gender) => GENDERS.find((g) => g.value === v)!.plural;
const [fields, setFields] = useState<Member['fields']>(m.fields);
const [kind, setKind] = useState<'single' | 'couple'>(m.kind ?? 'single');
const [partner, setPartner] = useState<PartnerDraft>(partnerDraft(m.partner));
const [seekingCouples, setSeekingCouples] = useState<CoupleMix[]>(m.seekingCouples ?? []);
const [busy, setBusy] = useState(false);
const [msg, setMsg] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);
return (
<Card style={{ gap: 20 }}>
<Field label="Display name" value={name} onChangeText={setName} maxLength={24} />
<Field label="About me" value={about} onChangeText={setAbout} multiline style={{ minHeight: 120, textAlignVertical: 'top' }} hint="Contact details here are flagged for review." />
{site.couples ? <CoupleBasics kind={kind} onKind={setKind} partner={partner} onPartner={setPartner} /> : null}
<Field label={site.couples && kind === 'couple' ? 'About us' : 'About me'} value={about} onChangeText={setAbout} multiline style={{ minHeight: 120, textAlignVertical: 'top' }} hint="Contact details here are flagged for review." />
<LocationPicker current={{ city: m.city, region: m.region, country: m.country, postal: m.postal }} onChange={setLoc} />
<H size={18} level={2}>Who you want to meet</H>
<Txt sub size={14} style={{ marginTop: -12 }}>Discover and Browse start from these. A hard limit is never crossed. A preferred one widens when you run out of people, and those people are labelled.</Txt>
<ChipPicker label="Looking for" multi options={GENDERS.map((g) => g.plural)} value={seeking.map(plural)}
onChange={(ls: string[]) => ls.length && setSeeking(ls.map((l) => GENDERS.find((g) => g.plural === l)!.value))} />
{site.couples ? <SeekingBoth seeking={seeking} onSeeking={setSeeking} couples={seekingCouples} onCouples={setSeekingCouples} /> : (
<ChipPicker label="Looking for" multi options={GENDERS.map((g) => g.plural)} value={seeking.map(plural)}
onChange={(ls: string[]) => ls.length && setSeeking(ls.map((l) => GENDERS.find((g) => g.plural === l)!.value))} />
)}
<Toggle label="Hard limit" value={strict.seeking} onChange={(v) => setStrict({ ...strict, seeking: v })} />
<Toggle label="Keep private" hint="Hide who you're looking for on your profile. It still decides who we suggest." value={!!hidden.seeking} onChange={(v) => setHidden({ ...hidden, seeking: v })} />
<View style={{ flexDirection: 'row', gap: 12 }}>
Expand All @@ -84,14 +91,15 @@ function ProfileTab() {
<Toggle label="Hard limit" value={strict.distance} onChange={(v) => setStrict({ ...strict, distance: v })} />
<Toggle label="Show events I'm going to on my profile" hint="Off by default. When on, other members see the site events you're going to or went to, and you're listed on those events." value={showEvents} onChange={setShowEvents} />
<H size={18} level={2}>About you on {site.name}</H>
<FieldsEditor fields={site.fields} value={fields} onChange={setFields} />
{site.couples ? <CoupleFields fields={site.fields} value={fields} onChange={setFields} kind={kind} partner={partner} onPartner={setPartner} /> : <FieldsEditor fields={site.fields} value={fields} onChange={setFields} />}
{msg ? <Notice tone="success" icon="check">{msg}</Notice> : null}
<ErrorText error={error} />
<View style={{ flexDirection: 'row', gap: 10, flexWrap: 'wrap' }}>
<Btn label="Save changes" busy={busy} onPress={async () => {
setBusy(true); setError(null); setMsg(null);
try {
setMe(await api.updateMe({ displayName: name, about, ...(loc ? { location: loc.input } : {}), seeking, ageMin: Number(ageMin) || m.ageMin, ageMax: Number(ageMax) || m.ageMax, maxMiles: miles, strict, hiddenPrefs: hidden, showEvents, fields }));
setMe(await api.updateMe({ displayName: name, about, ...(loc ? { location: loc.input } : {}), seeking, ageMin: Number(ageMin) || m.ageMin, ageMax: Number(ageMax) || m.ageMax, maxMiles: miles, strict, hiddenPrefs: hidden, showEvents, fields,
...(site.couples ? { kind, seekingCouples, ...(kind === 'couple' ? { partner: partnerPatch(partner) } : {}) } : {}) }));
setMsg('Saved.');
} catch (e) { setError(e instanceof ApiError ? e.message : 'Could not save.'); } finally { setBusy(false); }
}} />
Expand All @@ -116,7 +124,7 @@ function AccessTab() {
<Pressable onPress={() => router.push(`/member/${r.member.id}`)} style={{ flexDirection: 'row', alignItems: 'center', gap: 12, flex: 1, minWidth: 180 }}>
<Avatar photo={r.member.mainPhoto} size={48} />
<View>
<Txt bold>{r.member.displayName}, {r.member.age}</Txt>
<Txt bold>{r.member.displayName}, {agesLabel(r.member)}</Txt>
<Txt sub size={13}>{status} · {relTime(r.updatedAt)}</Txt>
</View>
</Pressable>
Expand Down
19 changes: 16 additions & 3 deletions apps/member/src/app/(app)/member/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiError, GENDERS, type MemberProfile, type PhotoView } from '@whatbox/core';
import { agesLabel, ApiError, COUPLE_MIXES, coupleLabel, GENDERS, type MemberProfile, type PhotoView } from '@whatbox/core';
import { router, useLocalSearchParams } from 'expo-router';
import { useCallback, useEffect, useState } from 'react';
import { Pressable, ScrollView, View } from 'react-native';
Expand Down Expand Up @@ -40,7 +40,8 @@ export default function ProfileScreen() {
}[p.privateAccess];
const preview = !!p.preview;
const lookingFor = [
p.seeking ? p.seeking.map((s) => GENDERS.find((g) => g.value === s)?.plural ?? s).join(', ') : '',
...(p.seekingCouples ?? []).map((c) => COUPLE_MIXES.find((x) => x.value === c)?.short.replace('couple', 'couples') ?? c),
p.seeking ? p.seeking.map((s) => (p.seekingCouples ? 'single ' : '') + (GENDERS.find((g) => g.value === s)?.plural ?? s).replace(/^(Women|Men)$/, (x) => (p.seekingCouples ? x.toLowerCase() : x))).join(', ') : '',
p.ageMin !== undefined ? `${p.ageMin} to ${p.ageMax}` : '',
].filter(Boolean).join(', ');
const all = [p.mainPhoto, ...p.publicPhotos].filter(Boolean) as PhotoView[];
Expand Down Expand Up @@ -116,7 +117,7 @@ export default function ProfileScreen() {
<View style={{ flex: 1, width: '100%', gap: 18 }}>
<View>
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10, flexWrap: 'wrap' }}>
<H size={40}>{p.displayName}, {p.age}</H>
<H size={40}>{p.displayName}, {agesLabel(p)}</H>
{p.tier === 'vip' ? <Badge label="★ VIP" tone="alert" /> : null}
{p.verified ? (
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 5, backgroundColor: t.accentSoft, borderRadius: 999, paddingHorizontal: 10, paddingVertical: 4 }}>
Expand All @@ -125,6 +126,7 @@ export default function ProfileScreen() {
</View>
) : null}
</View>
{p.couple ? <Txt bold style={{ marginTop: 6 }}>{coupleLabel(p)}</Txt> : null}
<Txt sub style={{ marginTop: 6 }}>{[p.city, p.region].filter(Boolean).join(', ')}{p.miles !== null ? ` · ${awayLabel(p.miles, me!.member.unitsResolved, true)}` : ''}{p.online ? ' · Online now' : ''}</Txt>
</View>

Expand Down Expand Up @@ -191,6 +193,17 @@ export default function ProfileScreen() {
</Card>
) : null}

{p.people?.map((who, i) => (
<Card key={i}>
<H size={18} level={2} style={{ marginBottom: 14 }}>{who.name || (i === 0 ? 'Partner one' : 'Partner two')}</H>
<View style={{ flexDirection: 'row', flexWrap: 'wrap', rowGap: 14 }}>
<Detail label="Age" value={String(who.age)} />
<Detail label="Gender" value={GENDERS.find((g) => g.value === who.gender)?.label ?? who.gender} />
{who.details.map((d) => <Detail key={d.key} label={d.label} value={d.value} />)}
</View>
</Card>
))}

{p.events?.length ? (
<Card>
<H size={18} level={2} style={{ marginBottom: 12 }}>Events</H>
Expand Down
4 changes: 2 additions & 2 deletions apps/member/src/app/(app)/messages/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiError, type ConversationView } from '@whatbox/core';
import { agesLabel, ApiError, type ConversationView } from '@whatbox/core';
import { router, useLocalSearchParams } from 'expo-router';
import { useCallback, useEffect, useRef, useState } from 'react';
import { KeyboardAvoidingView, Platform, Pressable, ScrollView, TextInput, View } from 'react-native';
Expand Down Expand Up @@ -48,7 +48,7 @@ export default function Conversation() {
<Pressable onPress={() => router.push(`/member/${other.id}`)} style={{ flexDirection: 'row', alignItems: 'center', gap: 10, flex: 1 }}>
<Avatar photo={other.mainPhoto} size={42} />
<View>
<Txt bold size={17}>{other.displayName}, {other.age}</Txt>
<Txt bold size={17}>{other.displayName}, {agesLabel(other)}</Txt>
<Txt size={13} color={other.online ? '#2F7A52' : t.sub}>{other.online ? 'Online now' : other.city}</Txt>
</View>
</Pressable>
Expand Down
4 changes: 2 additions & 2 deletions apps/member/src/app/(app)/messages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ConversationSummary } from '@whatbox/core';
import { agesLabel, type ConversationSummary } from '@whatbox/core';
import { router } from 'expo-router';
import { useEffect, useState } from 'react';
import { Pressable, ScrollView, View } from 'react-native';
Expand Down Expand Up @@ -33,7 +33,7 @@ export default function Messages() {
<View style={{ flex: 1, minWidth: 0 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', gap: 8 }}>
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 6, flexShrink: 1 }}>
<Txt bold size={17}>{c.other.displayName}, {c.other.age}</Txt>
<Txt bold size={17}>{c.other.displayName}, {agesLabel(c.other)}</Txt>
{c.fromVip ? <Badge label="★ VIP" tone="alert" /> : null}
</View>
<Txt sub size={13}>{relTime(c.last.at)}</Txt>
Expand Down
Loading
Loading