-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mobile): [Transaction] add create transaction with success toast
- Loading branch information
Showing
6 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Toasts, toast as rntoast } from '@backpackapp-io/react-native-toast' | ||
|
||
export function ToastRoot() { | ||
return ( | ||
<Toasts | ||
defaultStyle={{ | ||
text: { | ||
fontFamily: 'Be Vietnam Pro', | ||
}, | ||
}} | ||
/> | ||
) | ||
} | ||
|
||
export const toast = rntoast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { getHonoClient } from '@/lib/client' | ||
import { type TransactionFormValues, TransactionSchema } from '@6pm/validation' | ||
import { z } from 'zod' | ||
|
||
export async function createTransaction(data: TransactionFormValues) { | ||
const hc = await getHonoClient() | ||
const result = await hc.v1.transactions.$post({ | ||
json: data, | ||
}) | ||
|
||
if (result.ok) { | ||
const transaction = await result.json() | ||
return TransactionSchema.merge( | ||
z.object({ | ||
// override Decimal type with number | ||
amount: z.number({ coerce: true }), | ||
}), | ||
).parse(transaction) | ||
} | ||
|
||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.