feat(mobile): Empfehlungsprogramm in der App

- Bildschirm "Freunde einladen" (/invite, aus den Einstellungen erreichbar):
  eigener Code mit nativem Teilen-Dialog, Rangleiter mit Fortschritt,
  eingeladene Tiere, nachträgliche Code-Eingabe im Einlösefenster
- Onboarding-Schritt "Wie hast du von PawFeed erfahren?" mit Code-Eingabe,
  einmal pro Owner (referrals.onboardingState)
- Rang-Abzeichen in PetIdentityBadges (Feed und Profil), Profilring in
  Rangfarbe, "Eingeladen von …" im Tierprofil
- Benachrichtigungen REFERRAL_JOINED / REFERRAL_RANK_UP
- Keine neuen nativen Module (React Native Share) — per OTA auslieferbar

Typecheck grün; nicht auf einem Gerät getestet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-01 06:30:11 +02:00
1 parent 4d0aa7ab9e
commit 78e16c9210
17 files changed
+725 -13

No files matched your search

@@ -20,6 +20,7 @@ const ACTOR_MESSAGE_KEYS: Partial<Record<NotificationItem["type"], string>> = {
MENTION: "notifications.mention",
PAW_BACK: "notifications.pawBack",
PET_SUGGESTION: "notifications.petSuggestion",
REFERRAL_JOINED: "notifications.referralJoined",
};
// BIRTHDAY/ADOPTION_DAY are self-referential ("your pet's day today") — the
@@ -28,6 +29,7 @@ const ACTOR_MESSAGE_KEYS: Partial<Record<NotificationItem["type"], string>> = {
const SELF_MESSAGE_KEYS: Partial<Record<NotificationItem["type"], string>> = {
BIRTHDAY: "notifications.birthday",
ADOPTION_DAY: "notifications.adoptionDay",
REFERRAL_RANK_UP: "notifications.referralRankUp",
};
// Suffix only — the actor's name is rendered separately as its own tappable
@@ -56,7 +58,10 @@ function getNotificationRoute(item: NotificationItem): string | null {
switch (item.type) {
case "FOLLOW":
case "PET_SUGGESTION":
case "REFERRAL_JOINED":
return item.actorPet ? `/pets/${item.actorPet.id}` : null;
case "REFERRAL_RANK_UP":
return "/invite";
case "BIRTHDAY":
case "ADOPTION_DAY":
return item.recipientPetId ? `/pets/${item.recipientPetId}/health` : null;
+1
View File
@@ -50,6 +50,7 @@ export default function AppLayout() {
<Stack.Screen name="messages/[conversationId]" options={{ ...headerOptions, title: t("screens.conversation") }} />
<Stack.Screen name="search" options={{ ...headerOptions, title: t("screens.search") }} />
<Stack.Screen name="settings" options={{ ...headerOptions, title: t("screens.settings") }} />
<Stack.Screen name="invite" options={{ ...headerOptions, title: t("screens.invite") }} />
<Stack.Screen name="delete-account" options={{ ...headerOptions, title: t("screens.deleteAccount") }} />
<Stack.Screen
name="post-new"
+127
View File
@@ -0,0 +1,127 @@
import { useMemo } from "react";
import { ActivityIndicator, Pressable, ScrollView, Share, StyleSheet, Text, View } from "react-native";
import { useRouter } from "expo-router";
import { useTranslation } from "react-i18next";
import { useQuery } from "@tanstack/react-query";
import { Share2 } from "lucide-react-native";
import { useTRPC } from "../../src/api/trpc";
import { useTheme } from "../../src/context/ThemeContext";
import { useBottomSafePadding } from "../../src/hooks/useBottomSafePadding";
import { useReferralRanks } from "../../src/hooks/useReferralRanks";
import { env } from "../../src/lib/env";
import { PetAvatar } from "../../src/components/PetAvatar";
import { RankLadder } from "../../src/components/referrals/RankLadder";
import { RedeemCodeForm } from "../../src/components/referrals/RedeemCodeForm";
import { radii, getTypography, type ColorTokens } from "../../src/theme/tokens";
const STATUS_KEYS = {
counted: "referrals.statusCounted",
waiting: "referrals.statusWaiting",
"in-review": "referrals.statusInReview",
revoked: "referrals.statusRevoked",
} as const;
/**
* Port of web's /einladen — eigener Link mit nativem Teilen-Dialog (React
* Natives eingebautes Share, kein zusätzliches natives Modul → per OTA
* auslieferbar), Rangfortschritt, eingeladene Tiere, nachträgliche Code-Eingabe.
*/
export default function InviteScreen() {
const { t } = useTranslation();
const router = useRouter();
const trpc = useTRPC();
const { colors } = useTheme();
const styles = useMemo(() => makeStyles(colors), [colors]);
const bottomPadding = useBottomSafePadding();
const { ranks } = useReferralRanks();
const { data, isLoading } = useQuery(trpc.referrals.me.queryOptions());
if (isLoading || !data) {
return (
<View style={styles.center}>
<ActivityIndicator color={colors.marigoldOrange} />
</View>
);
}
const link = `${env.apiUrl}/r/${data.code}`;
const achieved = new Set(data.achievedRankIds);
function handleShare() {
void Share.share({ message: `${t("referrals.shareText", { code: data!.code })} ${link}` });
}
return (
<ScrollView contentContainerStyle={[styles.content, bottomPadding]}>
<Text style={styles.subtitle}>{t("referrals.subtitle")}</Text>
{!data.programActive && <Text style={styles.notice}>{t("referrals.programPaused")}</Text>}
<View style={styles.card}>
<Text style={styles.heading}>{t("referrals.shareHeading")}</Text>
<Text style={styles.muted}>{t("referrals.shareSubtitle")}</Text>
<View style={styles.codeBox}>
<Text style={styles.codeLabel}>{t("referrals.yourCode")}</Text>
<Text style={styles.code} selectable>{data.code}</Text>
</View>
<Pressable style={styles.shareButton} onPress={handleShare} accessibilityRole="button">
<Share2 size={18} color="#ffffff" />
<Text style={styles.shareText}>{t("referrals.share")}</Text>
</Pressable>
</View>
<RankLadder ranks={ranks} achievedRankIds={achieved} qualifiedCount={data.qualifiedCount} nextRankId={data.nextRankId} />
<View style={styles.card}>
<Text style={styles.heading}>{t("referrals.inviteesHeading")}</Text>
{data.invitees.length === 0 ? (
<Text style={styles.muted}>{t("referrals.inviteesEmpty")}</Text>
) : (
data.invitees.map((invitee, index) => (
<Pressable
key={invitee.pet?.id ?? `invitee-${index}`}
style={styles.inviteeRow}
disabled={!invitee.pet}
onPress={() => invitee.pet && router.push(`/pets/${invitee.pet.id}`)}
>
{invitee.pet && <PetAvatar name={invitee.pet.name} avatarKey={invitee.pet.avatarKey} size="sm" />}
<Text style={styles.inviteeName} numberOfLines={1}>{invitee.pet?.name ?? t("referrals.inviteeNoPet")}</Text>
<Text style={styles.muted}>{t(STATUS_KEYS[invitee.status])}</Text>
</Pressable>
))
)}
</View>
{data.canRedeem && (
<View style={styles.card}>
<Text style={styles.heading}>{t("referrals.redeemHeading")}</Text>
<Text style={styles.muted}>{t("referrals.redeemSubtitle")}</Text>
<RedeemCodeForm />
</View>
)}
<Text style={styles.footnote}>{t("referrals.rulesNote")}</Text>
</ScrollView>
);
}
function makeStyles(colors: ColorTokens) {
const typography = getTypography(colors);
return StyleSheet.create({
center: { flex: 1, alignItems: "center", justifyContent: "center", backgroundColor: colors.porchWhite },
content: { padding: 16, gap: 16, flexGrow: 1, backgroundColor: colors.porchWhite },
subtitle: { ...typography.body, color: colors.quietGray },
notice: { ...typography.body, fontSize: 13, padding: 12, borderRadius: radii.xl, backgroundColor: colors.marigoldTint, color: colors.ink },
card: { gap: 10, padding: 16, borderRadius: radii["2xl"], borderWidth: 1, borderColor: colors.hairlineGray, backgroundColor: colors.pureWhite },
heading: { ...typography.title, fontSize: 16 },
muted: { ...typography.body, fontSize: 13, color: colors.quietGray },
codeBox: { alignItems: "center", paddingVertical: 12, borderRadius: radii.xl, backgroundColor: colors.whisperGray },
codeLabel: { ...typography.body, fontSize: 11, letterSpacing: 1, textTransform: "uppercase", color: colors.quietGray },
code: { ...typography.title, fontSize: 24, letterSpacing: 2 },
shareButton: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 8, height: 48, borderRadius: radii.lg, backgroundColor: colors.marigoldOrange },
shareText: { ...typography.body, fontWeight: "600", color: "#ffffff" },
inviteeRow: { flexDirection: "row", alignItems: "center", gap: 10, paddingVertical: 6 },
inviteeName: { ...typography.body, flex: 1, fontWeight: "600" },
footnote: { ...typography.body, fontSize: 12, color: colors.quietGray },
});
}
+14 -1
View File
@@ -8,6 +8,7 @@ import { useTRPC } from "../../../../src/api/trpc";
import { useActivePet } from "../../../../src/context/ActivePetContext";
import { useTheme } from "../../../../src/context/ThemeContext";
import { PetAvatar } from "../../../../src/components/PetAvatar";
import { ReferralAvatarRing } from "../../../../src/components/referrals/ReferralAvatarRing";
import { PetIdentityBadges } from "../../../../src/components/PetIdentityBadges";
import { PostCard } from "../../../../src/components/PostCard";
import { Button } from "../../../../src/components/Button";
@@ -126,6 +127,7 @@ export default function PetProfileScreen() {
)}
ListHeaderComponent={
<View style={styles.header}>
<ReferralAvatarRing owner={pet.owner}>
{pet.avatarKey ? (
<Pressable
onPress={() =>
@@ -140,11 +142,20 @@ export default function PetProfileScreen() {
) : (
<PetAvatar name={pet.name} avatarKey={pet.avatarKey} size="lg" />
)}
</ReferralAvatarRing>
<View style={styles.nameRow}>
<Text style={styles.name}>{formatPetName(pet)}</Text>
<PetIdentityBadges isVerified={pet.isVerified} sponsor={pet.owner} />
<PetIdentityBadges isVerified={pet.isVerified} sponsor={pet.owner} referral={pet.owner} />
</View>
<Text style={styles.species}>{pet.species.name}</Text>
{pet.invitedByPet && (
<Text style={styles.invitedBy}>
{t("referrals.invitedBy")}{" "}
<Text style={styles.invitedByName} onPress={() => router.push(`/pets/${pet.invitedByPet?.id}`)}>
{pet.invitedByPet.name}
</Text>
</Text>
)}
<View style={styles.statsRow}>
<Pressable style={styles.stat} onPress={() => router.push(`/pets/${petId}/followers`)}>
@@ -216,6 +227,8 @@ function makeStyles(colors: ColorTokens) {
nameRow: { flexDirection: "row", alignItems: "center", marginTop: 8 },
name: { ...typography.title },
species: { ...typography.body, color: colors.quietGray },
invitedBy: { ...typography.body, fontSize: 12, color: colors.quietGray },
invitedByName: { color: colors.ink, fontWeight: "600" },
statsRow: { flexDirection: "row", gap: 32, marginVertical: 12 },
stat: { alignItems: "center" },
statCount: { ...typography.title, fontSize: 18 },
+2
View File
@@ -4,6 +4,7 @@ import { useTheme } from "../../src/context/ThemeContext";
import { AppearanceSection } from "../../src/components/settings/AppearanceSection";
import { LanguageSection } from "../../src/components/settings/LanguageSection";
import { PetSuggestionsSection } from "../../src/components/settings/PetSuggestionsSection";
import { InviteFriendsSection } from "../../src/components/settings/InviteFriendsSection";
import { LegalSection } from "../../src/components/settings/LegalSection";
import { LogoutSection } from "../../src/components/settings/LogoutSection";
import { DeleteAccountSection } from "../../src/components/settings/DeleteAccountSection";
@@ -41,6 +42,7 @@ export default function SettingsScreen() {
return (
<FooterErrorBoundary>
<ScrollView contentContainerStyle={[styles.content, bottomPadding]}>
<InviteFriendsSection />
<AppearanceSection />
<LanguageSection />
<PetSuggestionsSection />
+25 -4
View File
@@ -1,5 +1,5 @@
import { useState } from "react";
import { FlatList } from "react-native";
import { ActivityIndicator, FlatList, View } from "react-native";
import { useRouter } from "expo-router";
import { useActivePet } from "../../src/context/ActivePetContext";
import { OnboardingGuidelines } from "../../src/components/onboarding/OnboardingGuidelines";
@@ -7,12 +7,16 @@ import { UploadConsent } from "../../src/components/onboarding/UploadConsent";
import { ArachnophobiaOptIn } from "../../src/components/onboarding/ArachnophobiaOptIn";
import { PetCreateForm } from "../../src/components/onboarding/PetCreateForm";
import { AvatarStep } from "../../src/components/onboarding/AvatarStep";
import { AcquisitionStep } from "../../src/components/onboarding/AcquisitionStep";
import { useQuery } from "@tanstack/react-query";
import { useTRPC } from "../../src/api/trpc";
import { useTheme } from "../../src/context/ThemeContext";
/**
* Port of web's src/app/onboarding/pet/page.tsx — same five-step flow and
* step order: community guidelines -> upload-rights/data-processing consent
* -> Arachnophobie-Helfer opt-in -> pet profile -> avatar photo. Lives as
* Port of web's src/app/onboarding/pet/page.tsx — same step order:
* community guidelines -> upload-rights/data-processing consent ->
* Arachnophobie-Helfer opt-in -> pet profile -> "Wie hast du von PawFeed
* erfahren?" + referral code (once per owner) -> avatar photo. Lives as
* its own top-level route (not under (auth) or (app)) so app/_layout.tsx's
* "zero pets -> redirect here" check (see OnboardingRedirect) doesn't loop.
*/
@@ -24,6 +28,15 @@ export default function OnboardingPetScreen() {
const [uploadConsentGiven, setUploadConsentGiven] = useState(false);
const [arachnophobiaStepDone, setArachnophobiaStepDone] = useState(false);
const [createdPet, setCreatedPet] = useState<{ id: string; name: string } | null>(null);
const [acquisitionStepDone, setAcquisitionStepDone] = useState(false);
const trpc = useTRPC();
// Erst nach dem Anlegen des Tiers abfragen — vorher existiert die Owner-Zeile ggf. noch nicht.
const { data: referralState } = useQuery({
...trpc.referrals.onboardingState.queryOptions(),
enabled: !!createdPet,
});
const isReferralStateLoading = !!createdPet && !acquisitionStepDone && referralState === undefined;
const showAcquisitionStep = !!createdPet && !acquisitionStepDone && !!referralState?.showStep;
const finish = () => router.replace("/(app)");
@@ -34,6 +47,14 @@ export default function OnboardingPetScreen() {
content = <UploadConsent onContinue={() => setUploadConsentGiven(true)} />;
} else if (!arachnophobiaStepDone) {
content = <ArachnophobiaOptIn onContinue={() => setArachnophobiaStepDone(true)} />;
} else if (isReferralStateLoading) {
content = (
<View style={{ padding: 48, alignItems: "center" }}>
<ActivityIndicator color={colors.marigoldOrange} />
</View>
);
} else if (showAcquisitionStep) {
content = <AcquisitionStep canRedeem={referralState?.canRedeem ?? false} onDone={() => setAcquisitionStepDone(true)} />;
} else if (createdPet) {
content = <AvatarStep petId={createdPet.id} petName={createdPet.name} onDone={finish} />;
} else {