feat: use uuid
This commit is contained in:
@@ -3,6 +3,7 @@ import { authClient } from '@/lib/auth-client';
|
|||||||
import { Button, Text } from 'react-native';
|
import { Button, Text } from 'react-native';
|
||||||
import { useQuery, useZero } from "@rocicorp/zero/react";
|
import { useQuery, useZero } from "@rocicorp/zero/react";
|
||||||
import { queries, type Mutators, type Schema } from '@money/shared';
|
import { queries, type Mutators, type Schema } from '@money/shared';
|
||||||
|
import { randomUUID } from "expo-crypto";
|
||||||
|
|
||||||
export default function HomeScreen() {
|
export default function HomeScreen() {
|
||||||
const { data: session } = authClient.useSession();
|
const { data: session } = authClient.useSession();
|
||||||
@@ -16,6 +17,7 @@ export default function HomeScreen() {
|
|||||||
|
|
||||||
const onNew = () => {
|
const onNew = () => {
|
||||||
z.mutate.transaction.create({
|
z.mutate.transaction.create({
|
||||||
|
id: randomUUID(),
|
||||||
name: "Uber",
|
name: "Uber",
|
||||||
amount: 100,
|
amount: 100,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
"drizzle-orm": "^0.44.6",
|
"drizzle-orm": "^0.44.6",
|
||||||
"expo": "~54.0.13",
|
"expo": "~54.0.13",
|
||||||
"expo-constants": "~18.0.9",
|
"expo-constants": "~18.0.9",
|
||||||
|
"expo-crypto": "~15.0.7",
|
||||||
"expo-font": "~14.0.9",
|
"expo-font": "~14.0.9",
|
||||||
"expo-haptics": "~15.0.7",
|
"expo-haptics": "~15.0.7",
|
||||||
"expo-image": "~3.0.9",
|
"expo-image": "~3.0.9",
|
||||||
|
|||||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -41,6 +41,9 @@ importers:
|
|||||||
expo-constants:
|
expo-constants:
|
||||||
specifier: ~18.0.9
|
specifier: ~18.0.9
|
||||||
version: 18.0.9(expo@54.0.13)(react-native@0.81.4(@babel/core@7.28.4)(@types/react@19.1.17)(react@19.1.0))
|
version: 18.0.9(expo@54.0.13)(react-native@0.81.4(@babel/core@7.28.4)(@types/react@19.1.17)(react@19.1.0))
|
||||||
|
expo-crypto:
|
||||||
|
specifier: ~15.0.7
|
||||||
|
version: 15.0.7(expo@54.0.13)
|
||||||
expo-font:
|
expo-font:
|
||||||
specifier: ~14.0.9
|
specifier: ~14.0.9
|
||||||
version: 14.0.9(expo@54.0.13)(react-native@0.81.4(@babel/core@7.28.4)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
version: 14.0.9(expo@54.0.13)(react-native@0.81.4(@babel/core@7.28.4)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { Transaction } from "@rocicorp/zero";
|
import type { Transaction } from "@rocicorp/zero";
|
||||||
import type { AuthData } from "./auth";
|
import type { AuthData } from "./auth";
|
||||||
import type { Schema } from "./schema";
|
import type { Schema } from ".";
|
||||||
import { isLoggedIn } from "./zql";
|
import { isLoggedIn } from "./zql";
|
||||||
|
|
||||||
type Tx = Transaction<Schema>;
|
type Tx = Transaction<Schema>;
|
||||||
@@ -8,10 +8,10 @@ type Tx = Transaction<Schema>;
|
|||||||
export function createMutators(authData: AuthData | null) {
|
export function createMutators(authData: AuthData | null) {
|
||||||
return {
|
return {
|
||||||
transaction: {
|
transaction: {
|
||||||
async create(tx: Tx, { name, amount }: { name: string, amount: number }) {
|
async create(tx: Tx, { id, name, amount }: { id: string, name: string, amount: number }) {
|
||||||
isLoggedIn(authData);
|
isLoggedIn(authData);
|
||||||
await tx.mutate.transaction.insert({
|
await tx.mutate.transaction.insert({
|
||||||
id: 'id-' + Math.random().toString(),
|
id,
|
||||||
user_id: authData.user.id,
|
user_id: authData.user.id,
|
||||||
name,
|
name,
|
||||||
amount,
|
amount,
|
||||||
|
|||||||
Reference in New Issue
Block a user