Phase 1 foundation: backend, web profile, and mobile app
Greenfield implementation of CardClaws Phase 1 across three surfaces. Backend (Rust/Axum workspace, 67 tests): - cardclaws-types/config/db/auth/api/wallet crates - Auth: register, login + lockout, magic link, refresh rotation, Apple verify - Cards: CRUD, tier-limited publish, duplicate, public handle lookup - Assets: R2 presigned uploads; vCard export - Apple Wallet .pkpass pipeline (PKCS#7 signer behind apple-signing feature) - Analytics ingest + summary with daily-salted IP hashing - Migrations 0001 (incl. cardclaws_sessions) + 0002 analytics Web profile (Astro SSR): cardclaws.com/[handle] hero + flip, contact actions, client-built vCard, visit attribution. Verified end-to-end. Mobile (Expo SDK 51): auth, card list/create, builder v1 (bg/text/logo, palette, undo/redo), Skia/Reanimated viewer (flip + ambient). 22 logic tests. CI: policy/backend/profile/mobile jobs; LOC + no-placeholder lint. Review fixes baked in: `back` (not `cardclaws`) key; strip image is a bundled manifest file (not a URL); sessions table added; NFC reframed; test doubles allowed for external services. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
|
||||
import { useEffect } from "react";
|
||||
import { ActivityIndicator, Alert, Pressable, StyleSheet, Text, View } from "react-native";
|
||||
import { getCard, publishCard, saveCard } from "../../src/api/cards";
|
||||
import { BuilderCanvas } from "../../src/components/builder/BuilderCanvas";
|
||||
import { useCardStore } from "../../src/stores/cardStore";
|
||||
|
||||
export default function BuilderScreen() {
|
||||
const { cardId } = useLocalSearchParams<{ cardId: string }>();
|
||||
const router = useRouter();
|
||||
const queryClient = useQueryClient();
|
||||
const load = useCardStore((s) => s.load);
|
||||
const storeCard = useCardStore((s) => s.card);
|
||||
|
||||
const { data, isLoading } = useQuery({
|
||||
queryKey: ["card", cardId],
|
||||
queryFn: () => getCard(cardId),
|
||||
enabled: !!cardId,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) load(data.definition);
|
||||
}, [data, load]);
|
||||
|
||||
const save = useMutation({
|
||||
mutationFn: () => {
|
||||
const def = useCardStore.getState().card;
|
||||
if (!def) throw new Error("no card loaded");
|
||||
return saveCard(cardId, def);
|
||||
},
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["cards"] }),
|
||||
});
|
||||
|
||||
const publish = useMutation({
|
||||
mutationFn: async () => {
|
||||
const def = useCardStore.getState().card;
|
||||
if (def) await saveCard(cardId, def);
|
||||
return publishCard(cardId);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["cards"] });
|
||||
router.replace(`/card/${cardId}/view`);
|
||||
},
|
||||
onError: () => Alert.alert("Couldn't publish", "Check your plan's active-card limit."),
|
||||
});
|
||||
|
||||
if (isLoading || !storeCard) {
|
||||
return (
|
||||
<View style={styles.center}>
|
||||
<ActivityIndicator color="#ff3b30" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: "Builder",
|
||||
headerRight: () => (
|
||||
<View style={styles.headerActions}>
|
||||
<Pressable onPress={() => save.mutate()} disabled={save.isPending}>
|
||||
<Text style={styles.headerBtn}>Save</Text>
|
||||
</Pressable>
|
||||
<Pressable onPress={() => publish.mutate()} disabled={publish.isPending}>
|
||||
<Text style={[styles.headerBtn, styles.publish]}>Publish</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<BuilderCanvas side="face" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
center: { flex: 1, alignItems: "center", justifyContent: "center", backgroundColor: "#0a0a0c" },
|
||||
headerActions: { flexDirection: "row", gap: 16 },
|
||||
headerBtn: { color: "#f5f5f7", fontWeight: "600", fontSize: 16 },
|
||||
publish: { color: "#ff3b30" },
|
||||
});
|
||||
Reference in New Issue
Block a user