mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-10-31 18:19:43 +00:00
Completes the half-built dares feature: send a dare, respond, report done, confirm, and get a push notification on every transition. Backend (apps/api): - New `dares` domain with couple-shared premium entitlement, a free weekly send allowance, and server-enforced actor/state rules on every transition. - `submitted` status so the recipient reports completion and the sender confirms, rather than the sender guessing. - Notifications ride the existing operations outbox via a trigger on `sent_dares`. Push copy is generic; store compliance forbids dare text in a preview and a test asserts no payload leaks it. - Worker expiry sweep now covers `pending` as well as `active`/`submitted`; an invitation nobody opened previously stayed open forever. Fixes two latent defects: - Deleting any dare that had been sent aborted with a check violation, because `dare_id` is ON DELETE SET NULL while `sent_dares_dare_or_custom_check` required it. Dare text is now snapshotted at send time, which also keeps a couple's history stable across catalogue edits. - The free send allowance was raceable: concurrent requests all read the same count and every one succeeded. The count and insert are now serialized on the sender's profile row. Also ports `content_status` review metadata to the API catalogue, which had no store-safety gating at all, and mirrors the review decision already enforced on the legacy catalogue. Mobile: dares screen (active/send/history), send sheet with duration presets, home tile badging incoming dares, paywall on both proactive and 402 paths. Verified: lint, typecheck, 379 unit tests, build, 71 integration tests against local PostgreSQL. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
124 lines
3.3 KiB
TypeScript
124 lines
3.3 KiB
TypeScript
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native';
|
|
import { Ionicons } from '@expo/vector-icons';
|
|
import { router } from 'expo-router';
|
|
import * as Haptics from 'expo-haptics';
|
|
import Animated, { FadeInDown } from 'react-native-reanimated';
|
|
import { colors, spacing, radius, typography, shadows, tileColors } from '../../theme';
|
|
import { useAuthStore } from '../../store';
|
|
import { useIncomingDareCount } from '../../features/dares/hooks/useIncomingDareCount';
|
|
|
|
const HORIZONTAL_PADDING = spacing.lg;
|
|
const TILE_HEIGHT = 100;
|
|
|
|
interface DaresTileProps {
|
|
delay?: number;
|
|
}
|
|
|
|
export function DaresTile({ delay = 0 }: DaresTileProps) {
|
|
const { user } = useAuthStore();
|
|
const paired = Boolean(user?.couple_id);
|
|
const pending = useIncomingDareCount(paired);
|
|
|
|
if (!paired) return null;
|
|
|
|
const handlePress = () => {
|
|
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
|
router.push('/(app)/dares' as never);
|
|
};
|
|
|
|
return (
|
|
<Animated.View
|
|
entering={FadeInDown.delay(delay).duration(500).springify()}
|
|
style={styles.container}
|
|
>
|
|
<TouchableOpacity onPress={handlePress} activeOpacity={0.85} style={styles.tileWrapper}>
|
|
<View style={[styles.tile, shadows.md]}>
|
|
<View style={styles.iconContainer}>
|
|
<Ionicons name="flame" size={24} color="rgba(255, 255, 255, 0.9)" />
|
|
</View>
|
|
|
|
<View style={styles.content}>
|
|
<Text style={styles.title}>Dares</Text>
|
|
<Text style={styles.subtitle}>
|
|
{pending > 0
|
|
? `${pending} dare${pending === 1 ? '' : 's'} waiting for you`
|
|
: 'Challenge your partner to something playful'}
|
|
</Text>
|
|
</View>
|
|
|
|
{pending > 0 ? (
|
|
<View style={styles.badge}>
|
|
<Text style={styles.badgeText}>{pending}</Text>
|
|
</View>
|
|
) : (
|
|
<Ionicons name="chevron-forward" size={20} color="rgba(255, 255, 255, 0.6)" />
|
|
)}
|
|
|
|
<View style={styles.overlay} />
|
|
</View>
|
|
</TouchableOpacity>
|
|
</Animated.View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
marginBottom: spacing.lg,
|
|
},
|
|
tileWrapper: {
|
|
paddingHorizontal: HORIZONTAL_PADDING,
|
|
},
|
|
tile: {
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
backgroundColor: tileColors.amber,
|
|
borderRadius: radius.lg,
|
|
padding: spacing.md,
|
|
height: TILE_HEIGHT,
|
|
overflow: 'hidden',
|
|
position: 'relative',
|
|
},
|
|
iconContainer: {
|
|
width: 48,
|
|
height: 48,
|
|
borderRadius: 24,
|
|
backgroundColor: 'rgba(255, 255, 255, 0.2)',
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
marginRight: spacing.md,
|
|
},
|
|
content: {
|
|
flex: 1,
|
|
},
|
|
title: {
|
|
...typography.headline,
|
|
color: colors.text,
|
|
fontWeight: '700',
|
|
},
|
|
subtitle: {
|
|
...typography.caption1,
|
|
color: 'rgba(255, 255, 255, 0.8)',
|
|
marginTop: 2,
|
|
},
|
|
badge: {
|
|
minWidth: 24,
|
|
height: 24,
|
|
paddingHorizontal: 6,
|
|
borderRadius: radius.full,
|
|
backgroundColor: colors.background,
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
},
|
|
badgeText: {
|
|
...typography.caption1,
|
|
color: colors.text,
|
|
fontWeight: '700',
|
|
},
|
|
overlay: {
|
|
...StyleSheet.absoluteFillObject,
|
|
backgroundColor: 'rgba(0, 0, 0, 0.05)',
|
|
borderRadius: radius.lg,
|
|
pointerEvents: 'none',
|
|
},
|
|
});
|