Skip to content

Commit

Permalink
fix(mobile): unset default bugdet
Browse files Browse the repository at this point in the history
  • Loading branch information
duongdev committed Sep 19, 2024
1 parent 59c3ae0 commit fecf889
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/mobile/app/(app)/budget/[budgetId]/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function EditBudgetScreen() {
const { i18n } = useLingui()
const { budgetId } = useLocalSearchParams<{ budgetId: string }>()
const { budget } = useBudget(budgetId!)
const { mutateAsync } = useUpdateBudget()
const { mutateAsync: updateUpdate } = useUpdateBudget()
const { mutateAsync: mutateDelete } = useDeleteBudget()
const { setDefaultBudgetId, defaultBudgetId } = useUserMetadata()
const { sideOffset, ...rootProps } = useModalPortalRoot()
Expand Down Expand Up @@ -69,9 +69,12 @@ export default function EditBudgetScreen() {

const handleUpdate = async ({ isDefault, ...data }: BudgetFormValues) => {
if (isDefault) {
await setDefaultBudgetId(budget?.id)
setDefaultBudgetId(budget?.id)
} else if (defaultBudgetId === budget?.id) {
// unset default budget
setDefaultBudgetId(undefined)
}
mutateAsync({
updateUpdate({
data: data,
id: budget?.id!,
}).catch(() => {
Expand Down

0 comments on commit fecf889

Please sign in to comment.