diff --git a/messages/de.json b/messages/de.json index 19494a2..649e678 100644 --- a/messages/de.json +++ b/messages/de.json @@ -488,7 +488,9 @@ "typeStoryComment": "hat deine Story kommentiert.", "typeStoryReaction": "hat deiner Story eine Pfote gegeben.", "typeUnknown": "hat eine neue Mitteilung für dich.", - "typePetDeceased": "ist über die Regenbogenbrücke gegangen. In liebevoller Erinnerung 🤍" + "typePetDeceased": "ist über die Regenbogenbrücke gegangen. In liebevoller Erinnerung 🤍", + "typePetLost": "wird vermisst. Vielleicht kannst du helfen – tippe für alle Infos.", + "typePetFound": "ist wieder sicher zu Hause. Danke fürs Mithelfen! 🎉" }, "PhotoPostForm": { "captionPlaceholder": "Bildunterschrift schreiben…", @@ -879,5 +881,60 @@ "saved": "Das Profil wird nun als Erinnerung bewahrt.", "removed": "Gedenkmodus beendet.", "saveFailed": "Das hat leider nicht geklappt. Bitte versuch es noch einmal." + }, + "LostPublic": { + "badge": "Vermisst", + "heading": "Hast du {name} gesehen?", + "metaTitle": "Vermisst: {name} – hast du dieses Tier gesehen?", + "metaDescription": "Zuletzt gesehen: {place}. Jeder Hinweis hilft – bitte teilen.", + "lastSeenPlace": "Zuletzt gesehen", + "lastSeenAt": "Wann", + "details": "Erkennungsmerkmale & Hinweise", + "contactHeading": "Bitte melde dich, wenn du {name} siehst", + "messageInPawFeed": "Nachricht über PawFeed schreiben", + "mailSubject": "Hinweis zu {name}", + "approachHint": "Bitte das Tier nicht verfolgen oder einfangen wollen – verängstigte Tiere laufen sonst oft weiter weg. Ruhig beobachten, Ort und Zeit merken und Bescheid geben.", + "photosHeading": "Weitere Fotos", + "photoAlt": "Foto von {name}", + "share": "Seite teilen – jede Weitergabe hilft", + "copied": "Link kopiert", + "foundTitle": "{name} ist wieder sicher zu Hause 🎉", + "foundText": "Danke an alle, die geteilt und mitgesucht haben!", + "openInPawFeed": "{name} auf PawFeed besuchen", + "rateLimited": "Zu viele Anfragen – bitte versuch es in einer Minute erneut." + }, + "LostReport": { + "badge": "Wird vermisst", + "teaser": "Ist {name} entlaufen? Hier kannst du sofort eine Vermisst-Meldung starten.", + "open": "Vermisst melden", + "formHeading": "{name} als vermisst melden", + "formHint": "Wir drücken dir fest die Daumen. Alle, die {name} folgen oder denen {name} folgt, bekommen sofort eine Push-Mitteilung, und du erhältst eine Seite zum Teilen – auch für Menschen ohne PawFeed.", + "activeHeading": "{name} wird vermisst", + "activeHint": "Teile den Link, so oft du kannst – zum Beispiel in WhatsApp-Gruppen aus deiner Nachbarschaft. Du kannst die Angaben jederzeit ergänzen.", + "lastSeenAt": "Zuletzt gesehen am", + "lastSeenPlace": "Wo zuletzt gesehen?", + "lastSeenPlacePlaceholder": "z. B. Stadtpark Nord, Nähe Spielplatz", + "description": "Erkennungsmerkmale & Hinweise", + "descriptionPlaceholder": "z. B. rotes Halsband, gechippt, eher scheu – bitte nicht rufen", + "contactHint": "Kontaktdaten sind freiwillig und erscheinen nur auf der Teilen-Seite dieser Meldung. Eine Nachricht über PawFeed ist immer möglich.", + "contactPhone": "Telefonnummer (optional)", + "contactEmail": "E-Mail (optional)", + "allowIndexing": "Seite darf über Suchmaschinen gefunden werden", + "allowIndexingHint": "Mehr Reichweite, aber auch Fremde finden die Seite. Ohne Haken ist sie nur über den Link erreichbar.", + "submit": "Vermisst-Meldung starten", + "cancel": "Abbrechen", + "saveChanges": "Änderungen speichern", + "notifyFound": "Allen Bescheid geben, dass {name} wieder da ist", + "markFound": "{name} ist wieder da!", + "share": "Link teilen", + "shareTitle": "Vermisst: {name}", + "copied": "Link kopiert", + "created": "Die Meldung ist raus. Wir drücken die Daumen, dass {name} schnell nach Hause findet.", + "updated": "Angaben gespeichert.", + "foundToast": "Wie schön – willkommen zurück, {name}! 🎉", + "saveFailed": "Das hat leider nicht geklappt. Bitte versuch es noch einmal.", + "bannerTitle": "{name} wird vermisst", + "bannerText": "Zuletzt gesehen: {place} · {date}", + "bannerLink": "Alle Infos & Seite teilen" } } diff --git a/messages/en.json b/messages/en.json index 3e6ebf4..5bc44b4 100644 --- a/messages/en.json +++ b/messages/en.json @@ -488,7 +488,9 @@ "typeStoryComment": "commented on your story.", "typeStoryReaction": "gave your story a paw.", "typeUnknown": "has a new notification for you.", - "typePetDeceased": "has crossed the rainbow bridge. In loving memory 🤍" + "typePetDeceased": "has crossed the rainbow bridge. In loving memory 🤍", + "typePetLost": "is missing. Maybe you can help – tap for all details.", + "typePetFound": "is safely back home. Thanks for helping! 🎉" }, "PhotoPostForm": { "captionPlaceholder": "Write a caption…", @@ -879,5 +881,60 @@ "saved": "The profile is now kept as a memorial.", "removed": "Memorial mode ended.", "saveFailed": "That didn't work, sorry. Please try again." + }, + "LostPublic": { + "badge": "Missing", + "heading": "Have you seen {name}?", + "metaTitle": "Missing: {name} – have you seen this pet?", + "metaDescription": "Last seen: {place}. Every tip helps – please share.", + "lastSeenPlace": "Last seen", + "lastSeenAt": "When", + "details": "Distinguishing features & notes", + "contactHeading": "Please get in touch if you see {name}", + "messageInPawFeed": "Send a message on PawFeed", + "mailSubject": "A tip about {name}", + "approachHint": "Please don't chase or try to catch the pet – frightened animals often run further away. Watch calmly, note the place and time and let us know.", + "photosHeading": "More photos", + "photoAlt": "Photo of {name}", + "share": "Share this page – every share helps", + "copied": "Link copied", + "foundTitle": "{name} is safely back home 🎉", + "foundText": "Thank you to everyone who shared and helped search!", + "openInPawFeed": "Visit {name} on PawFeed", + "rateLimited": "Too many requests – please try again in a minute." + }, + "LostReport": { + "badge": "Missing", + "teaser": "Has {name} run away? Start a missing report right here.", + "open": "Report missing", + "formHeading": "Report {name} as missing", + "formHint": "We're keeping our fingers crossed. Everyone who follows {name} or whom {name} follows gets a push notification right away, and you get a page to share – even with people who aren't on PawFeed.", + "activeHeading": "{name} is missing", + "activeHint": "Share the link as often as you can – for example in neighbourhood WhatsApp groups. You can add details at any time.", + "lastSeenAt": "Last seen on", + "lastSeenPlace": "Where last seen?", + "lastSeenPlacePlaceholder": "e.g. North City Park, near the playground", + "description": "Distinguishing features & notes", + "descriptionPlaceholder": "e.g. red collar, microchipped, rather shy – please don't call out", + "contactHint": "Contact details are optional and only appear on this report's share page. A message via PawFeed is always possible.", + "contactPhone": "Phone number (optional)", + "contactEmail": "Email (optional)", + "allowIndexing": "Allow search engines to find this page", + "allowIndexingHint": "More reach, but strangers can find it too. Unchecked, the page is only reachable via the link.", + "submit": "Start missing report", + "cancel": "Cancel", + "saveChanges": "Save changes", + "notifyFound": "Let everyone know {name} is back", + "markFound": "{name} is back!", + "share": "Share link", + "shareTitle": "Missing: {name}", + "copied": "Link copied", + "created": "Your report is out. We're keeping our fingers crossed that {name} finds the way home soon.", + "updated": "Details saved.", + "foundToast": "How wonderful – welcome back, {name}! 🎉", + "saveFailed": "That didn't work, sorry. Please try again.", + "bannerTitle": "{name} is missing", + "bannerText": "Last seen: {place} · {date}", + "bannerLink": "All details & share page" } } diff --git a/mobile/app/(app)/(tabs)/notifications.tsx b/mobile/app/(app)/(tabs)/notifications.tsx index c67070f..40a159a 100644 --- a/mobile/app/(app)/(tabs)/notifications.tsx +++ b/mobile/app/(app)/(tabs)/notifications.tsx @@ -27,6 +27,8 @@ const ACTOR_MESSAGE_KEYS: Partial> = { STORY_COMMENT: "notifications.storyComment", STORY_REACTION: "notifications.storyReaction", PET_DECEASED: "notifications.petDeceased", + PET_LOST: "notifications.petLost", + PET_FOUND: "notifications.petFound", }; // BIRTHDAY/ADOPTION_DAY are self-referential ("your pet's day today") — the diff --git a/mobile/app/(app)/(tabs)/pets.tsx b/mobile/app/(app)/(tabs)/pets.tsx index 9a07bfa..0f15286 100644 --- a/mobile/app/(app)/(tabs)/pets.tsx +++ b/mobile/app/(app)/(tabs)/pets.tsx @@ -84,7 +84,7 @@ function PetRow({ {formatPetName(pet)} - + {pet.breed?.name ?? pet.species.name} diff --git a/mobile/app/(app)/pets/[petId]/edit.tsx b/mobile/app/(app)/pets/[petId]/edit.tsx index 1909b98..e44e11d 100644 --- a/mobile/app/(app)/pets/[petId]/edit.tsx +++ b/mobile/app/(app)/pets/[petId]/edit.tsx @@ -13,6 +13,7 @@ import { Button } from "../../../../src/components/Button"; import { BreedPicker } from "../../../../src/components/pet/BreedPicker"; import { PrivacySettings } from "../../../../src/components/pet/PrivacySettings"; import { MemorialSettings } from "../../../../src/components/pet/MemorialSettings"; +import { LostReportSettings } from "../../../../src/components/lost/LostReportSettings"; import { radii, getTypography, type ColorTokens, type Typography } from "../../../../src/theme/tokens"; import { displayDateToIso, isoToDisplayDate } from "../../../../src/lib/date-format"; import { useBottomSafePadding } from "../../../../src/hooks/useBottomSafePadding"; @@ -133,6 +134,9 @@ export default function EditPetScreen() { keyboardShouldPersistTaps="handled" ListHeaderComponent={ <> + {/* Vermisst-Meldung ganz oben: im Ernstfall sofort auffindbar */} + + {t("editPet.nameLabel")} diff --git a/mobile/app/(app)/pets/[petId]/index.tsx b/mobile/app/(app)/pets/[petId]/index.tsx index dc9a623..bcc043a 100644 --- a/mobile/app/(app)/pets/[petId]/index.tsx +++ b/mobile/app/(app)/pets/[petId]/index.tsx @@ -1,9 +1,9 @@ import { useMemo, useState } from "react"; -import { View, Text, FlatList, Pressable, ActivityIndicator, Alert, StyleSheet } from "react-native"; +import { View, Text, FlatList, Pressable, ActivityIndicator, Alert, Linking, StyleSheet } from "react-native"; import { Stack, useLocalSearchParams, useRouter } from "expo-router"; import { useTranslation } from "react-i18next"; import { useQuery, useMutation } from "@tanstack/react-query"; -import { HeartPulse, Trophy, MessageCircle, MoreHorizontal, Ribbon } from "lucide-react-native"; +import { HeartPulse, Trophy, MessageCircle, MoreHorizontal, Ribbon, Siren } from "lucide-react-native"; import { useTRPC } from "../../../../src/api/trpc"; import { useActivePet } from "../../../../src/context/ActivePetContext"; import { useTheme } from "../../../../src/context/ThemeContext"; @@ -18,6 +18,7 @@ import { useBlockPet } from "../../../../src/hooks/useBlockPet"; import { useVisiblePostIds } from "../../../../src/hooks/useVisiblePostIds"; import { formatPetName } from "../../../../src/lib/format"; import { isoToDisplayDate } from "../../../../src/lib/date-format"; +import { env } from "../../../../src/lib/env"; import { getAvatarUrl } from "../../../../src/lib/media-url"; import { getTypography, type ColorTokens, type Typography } from "../../../../src/theme/tokens"; import { useBottomSafePadding } from "../../../../src/hooks/useBottomSafePadding"; @@ -146,8 +147,27 @@ export default function PetProfileScreen() { {formatPetName(pet)} - + + {pet.lostReport && ( + void Linking.openURL(`${env.apiUrl}/vermisst/${pet.lostReport?.code}`)} + > + + + {t("lostReport.bannerTitle", { name: pet.name })} + + + {t("lostReport.bannerText", { + place: pet.lostReport.lastSeenPlace, + date: isoToDisplayDate(new Date(pet.lostReport.lastSeenAt).toISOString().slice(0, 10)), + })} + + {t("lostReport.bannerLink")} + + )} {pet.deceasedAt && ( @@ -254,6 +274,20 @@ function makeStyles(colors: ColorTokens) { backgroundColor: colors.whisperGray, }, memorialText: { ...typography.body, fontSize: 12, color: colors.quietGray }, + lostBanner: { + alignSelf: "stretch", + alignItems: "center", + gap: 2, + padding: 12, + borderRadius: 12, + borderWidth: 1, + borderColor: colors.alertRedTint, + backgroundColor: colors.alertRedTint, + }, + lostTitleRow: { flexDirection: "row", alignItems: "center", gap: 6 }, + lostTitle: { ...typography.body, fontFamily: typography.title.fontFamily, color: "#b91c1c" }, + lostText: { ...typography.body, fontSize: 13, color: colors.ink, textAlign: "center" }, + lostLink: { ...typography.body, fontSize: 12, textDecorationLine: "underline", color: colors.ink }, invitedByName: { color: colors.ink, fontWeight: "600" }, statsRow: { flexDirection: "row", gap: 32, marginVertical: 12 }, stat: { alignItems: "center" }, diff --git a/mobile/src/components/PetIdentityBadges.tsx b/mobile/src/components/PetIdentityBadges.tsx index 010970d..7c9fe39 100644 --- a/mobile/src/components/PetIdentityBadges.tsx +++ b/mobile/src/components/PetIdentityBadges.tsx @@ -1,5 +1,5 @@ import { View, StyleSheet } from "react-native"; -import { BadgeCheck, Ribbon, Sparkles, Sprout } from "lucide-react-native"; +import { BadgeCheck, Ribbon, Siren, Sparkles, Sprout } from "lucide-react-native"; import { useTranslation } from "react-i18next"; import { isActiveSponsor } from "../lib/sponsor"; import { colors } from "../theme/tokens"; @@ -13,6 +13,8 @@ type Props = { isFoundingMember?: boolean; /** Gedenkmodus „In Erinnerung“ (Pet.deceasedAt gesetzt). */ isDeceased?: boolean; + /** Aktive Vermisst-Meldung (Pet.lostSince gesetzt). */ + isLost?: boolean; sponsor?: { sponsorSince?: Date | string | null; sponsorPeriodEnd?: Date | string | null } | null; /** Owner-Felder referralRankId/referralPerks — Rang-Abzeichen des Empfehlungsprogramms. */ referral?: ReferralOwnerFields | null; @@ -21,15 +23,16 @@ type Props = { /** Port of web's src/components/ui/pet-identity-badges.tsx. */ const FOUNDING_COLOR = "#059669"; // emerald-600, wie im Web -export function PetIdentityBadges({ isVerified, isFoundingMember, isDeceased, sponsor, referral }: Props) { +export function PetIdentityBadges({ isVerified, isFoundingMember, isDeceased, isLost, sponsor, referral }: Props) { const { t } = useTranslation(); const { colors: theme } = useTheme(); const showSponsor = sponsor ? isActiveSponsor(sponsor) : false; const rank = useOwnerRankWithPerk(referral, "NAME_BADGE"); - if (!isDeceased && !isVerified && !isFoundingMember && !showSponsor && !rank) return null; + if (!isDeceased && !isLost && !isVerified && !isFoundingMember && !showSponsor && !rank) return null; return ( + {isLost && } {isDeceased && } {isVerified && } {showSponsor && } diff --git a/mobile/src/components/PostCard.tsx b/mobile/src/components/PostCard.tsx index dfc1464..bad2776 100644 --- a/mobile/src/components/PostCard.tsx +++ b/mobile/src/components/PostCard.tsx @@ -61,6 +61,7 @@ export type PostCardPost = { avatarKey?: string | null; isVerified?: boolean; deceasedAt?: Date | string | null; + lostSince?: Date | string | null; isFoundingMember?: boolean; // Sponsor fields only come with petCardSelect (feed/explore); a plain pet // identity's owner (posts.byPetId, comments) carries just the referral rank. @@ -153,7 +154,7 @@ export function PostCard({ post, actingPetId, isTrending, isVisible = true }: Pr {formatPetName(post.pet)} - + {isTrending && ( diff --git a/mobile/src/components/lost/LostReportSettings.tsx b/mobile/src/components/lost/LostReportSettings.tsx new file mode 100644 index 0000000..8e34db1 --- /dev/null +++ b/mobile/src/components/lost/LostReportSettings.tsx @@ -0,0 +1,292 @@ +import { useMemo, useState } from "react"; +import { View, Text, Pressable, Switch, Share, Linking, Alert, StyleSheet } from "react-native"; +import { useTranslation } from "react-i18next"; +import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import { Siren } from "lucide-react-native"; +import { useTRPC } from "../../api/trpc"; +import { useTheme } from "../../context/ThemeContext"; +import { TextField } from "../TextField"; +import { DateField } from "../DateField"; +import { Button } from "../Button"; +import { env } from "../../lib/env"; +import { displayDateToIso, isoToDisplayDate, todayAsDisplayDate } from "../../lib/date-format"; +import { radii, getTypography, type ColorTokens, type Typography } from "../../theme/tokens"; + +type Props = { petId: string; petName: string; isDeceased: boolean }; + +type Form = { + date: string; // DD.MM.YYYY + time: string; // HH:MM + lastSeenPlace: string; + description: string; + contactPhone: string; + contactEmail: string; + allowIndexing: boolean; +}; + +const TIME_PATTERN = /^([01]?\d|2[0-3]):[0-5]\d$/; +const RED = "#dc2626"; + +function pad(n: number): string { + return String(n).padStart(2, "0"); +} + +function formFromDate(date: Date): Pick { + const iso = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`; + return { date: isoToDisplayDate(iso), time: `${pad(date.getHours())}:${pad(date.getMinutes())}` }; +} + +/** Datum + Uhrzeit (Ortszeit) → ISO-Zeitpunkt, oder null bei ungültiger Eingabe. */ +function toIsoTimestamp(form: Form): string | null { + const iso = displayDateToIso(form.date); + if (!iso || !TIME_PATTERN.test(form.time)) return null; + const [h, m] = form.time.split(":"); + const date = new Date(`${iso}T${pad(Number(h))}:${m}:00`); + return Number.isNaN(date.getTime()) ? null : date.toISOString(); +} + +/** + * Vermisst-Meldung in „Profil bearbeiten“ — Port von web + * src/components/lost/LostReportSettings.tsx. Melden (Push an Follower und + * gefolgte Tiere), Angaben ergänzen, Link teilen, „Wieder da!“. + */ +export function LostReportSettings({ petId, petName, isDeceased }: Props) { + const { t } = useTranslation(); + const trpc = useTRPC(); + const queryClient = useQueryClient(); + const { colors } = useTheme(); + const styles = useMemo(() => makeStyles(colors), [colors]); + const { data: report, isPending } = useQuery(trpc.lostReports.mine.queryOptions({ petId })); + const [isOpen, setIsOpen] = useState(false); + const [notifyFound, setNotifyFound] = useState(true); + const [form, setForm] = useState
(null); + const [error, setError] = useState(null); + + const done = (message: string) => { + setForm(null); + setError(null); + void queryClient.invalidateQueries(); + Alert.alert(message); + }; + const onError = (err: { message: string }) => Alert.alert(err.message || t("lostReport.saveFailed")); + const create = useMutation( + trpc.lostReports.create.mutationOptions({ + onSuccess: () => { + setIsOpen(false); + done(t("lostReport.created", { name: petName })); + }, + onError, + }) + ); + const update = useMutation(trpc.lostReports.update.mutationOptions({ onSuccess: () => done(t("lostReport.updated")), onError })); + const markFound = useMutation( + trpc.lostReports.markFound.mutationOptions({ onSuccess: () => done(t("lostReport.foundToast", { name: petName })), onError }) + ); + + if (isDeceased || isPending) return null; + + const current: Form = + form ?? + (report + ? { + ...formFromDate(new Date(report.lastSeenAt)), + lastSeenPlace: report.lastSeenPlace, + description: report.description ?? "", + contactPhone: report.contactPhone ?? "", + contactEmail: report.contactEmail ?? "", + allowIndexing: report.allowIndexing, + } + : { + date: todayAsDisplayDate(), + time: "", + lastSeenPlace: "", + description: "", + contactPhone: "", + contactEmail: "", + allowIndexing: false, + }); + const set = (patch: Partial) => setForm({ ...current, ...patch }); + const publicUrl = report ? `${env.apiUrl}/vermisst/${report.code}` : ""; + + function payload() { + const lastSeenAt = toIsoTimestamp(current); + if (!lastSeenAt || !current.lastSeenPlace.trim()) { + setError(t("lostReport.invalidForm")); + return null; + } + setError(null); + return { + petId, + lastSeenAt, + lastSeenPlace: current.lastSeenPlace, + description: current.description, + contactPhone: current.contactPhone, + contactEmail: current.contactEmail, + allowIndexing: current.allowIndexing, + }; + } + + if (!report && !isOpen) { + return ( + + {t("lostReport.teaser", { name: petName })} + setIsOpen(true)} accessibilityRole="button"> + + {t("lostReport.open")} + + + ); + } + + return ( + + + + + {report ? t("lostReport.activeHeading", { name: petName }) : t("lostReport.formHeading", { name: petName })} + + + {report ? t("lostReport.activeHint") : t("lostReport.formHint", { name: petName })} + + {report && ( + <> + void Linking.openURL(publicUrl)}> + {publicUrl} + +