Skip to content

Commit

Permalink
feat(mobile): add delete category (#249)
Browse files Browse the repository at this point in the history
Resolves #90
  • Loading branch information
bkdev98 authored Sep 1, 2024
1 parent 7b7d87f commit 0d0fa02
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 5 deletions.
56 changes: 53 additions & 3 deletions apps/mobile/app/(app)/category/[categoryId].tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,65 @@
import { CategoryForm } from '@/components/category/category-form'
import { toast } from '@/components/common/toast'
import { Button } from '@/components/ui/button'
import { Text } from '@/components/ui/text'
import { useCategory, useUpdateCategory } from '@/stores/category/hooks'
import { useLocalSearchParams, useRouter } from 'expo-router'
import { ScrollView, View } from 'react-native'
import {
useCategory,
useDeleteCategory,
useUpdateCategory,
} from '@/stores/category/hooks'
import { t } from '@lingui/macro'
import { useLingui } from '@lingui/react'
import { useLocalSearchParams, useNavigation, useRouter } from 'expo-router'
import { Trash2Icon } from 'lucide-react-native'
import { useEffect } from 'react'
import { Alert, ScrollView, View } from 'react-native'

export default function EditCategoryScreen() {
const router = useRouter()
const { categoryId } = useLocalSearchParams<{ categoryId: string }>()
const { category } = useCategory(categoryId!)
const navigation = useNavigation()
const { i18n } = useLingui()

const { mutateAsync: mutateUpdate } = useUpdateCategory()
const { mutateAsync: mutateDelete } = useDeleteCategory()

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
useEffect(() => {
navigation.setOptions({
headerRight: () => (
<Button
size="icon"
variant="ghost"
onPress={() =>
Alert.alert(
t(
i18n,
)`Are you sure you want to delete this category? This action cannot be undone.`,
'',
[
{
text: t(i18n)`Cancel`,
style: 'cancel',
},
{
text: t(i18n)`Delete`,
style: 'destructive',
onPress: () => {
mutateDelete(categoryId as string)
router.back()
toast.success(t(i18n)`Category deleted`)
},
},
],
)
}
>
<Trash2Icon className="size-6 text-primary" />
</Button>
),
})
}, [])

if (!category) {
return (
Expand Down
10 changes: 10 additions & 0 deletions apps/mobile/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ msgstr ""
msgid "Are you sure you want to delete this budget? This action cannot be undone."
msgstr ""

#: apps/mobile/app/(app)/category/[categoryId].tsx:36
msgid "Are you sure you want to delete this category? This action cannot be undone."
msgstr ""

#: apps/mobile/app/(app)/profile.tsx:115
msgid "Are you sure you want to delete your account? This action cannot be undone."
msgstr ""
Expand Down Expand Up @@ -159,6 +163,7 @@ msgstr ""

#: apps/mobile/app/(app)/(tabs)/settings.tsx:248
#: apps/mobile/app/(app)/budget/[budgetId]/edit.tsx:45
#: apps/mobile/app/(app)/category/[categoryId].tsx:42
#: apps/mobile/app/(app)/profile.tsx:120
#: apps/mobile/app/(app)/transaction/[transactionId].tsx:77
#: apps/mobile/app/(app)/wallet/[walletId].tsx:77
Expand All @@ -174,6 +179,10 @@ msgstr ""
msgid "Categories"
msgstr ""

#: apps/mobile/app/(app)/category/[categoryId].tsx:51
msgid "Category deleted"
msgstr ""

#: apps/mobile/components/category/category-form.tsx:67
msgid "Category name"
msgstr ""
Expand Down Expand Up @@ -232,6 +241,7 @@ msgid "Default currency"
msgstr ""

#: apps/mobile/app/(app)/budget/[budgetId]/edit.tsx:49
#: apps/mobile/app/(app)/category/[categoryId].tsx:46
#: apps/mobile/app/(app)/profile.tsx:124
#: apps/mobile/app/(app)/transaction/[transactionId].tsx:81
#: apps/mobile/app/(app)/wallet/[walletId].tsx:81
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/locales/en/messages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*eslint-disable*/ import type { Messages } from '@lingui/core'
export const messages = JSON.parse(
'{"J/hVSQ":[["0"]],"6MIiOI":[["0"]," left"],"FEZKSz":[["language"]],"4E30de":[["remainingDays"]," days left"],"GDr6hQ":"* you can always change this later.","VE5ikN":"<0><1>Manage your expense seamlessly</1><2>Let <3>6pm</3> a good time to spend</2></0>","ejSd6i":"<0>By continuing, you acknowledge that you understand and agree to our <1><2>Privacy Policy</2></1></0>","AYTmQ1":"<0>By continuing, you acknowledge that you understand and agree to the <1><2>Terms & Conditions</2></1> and <3><4>Privacy Policy</4></3></0>","LjsgKU":"0.00","y+OdTP":"Account deleted successfully","103Xyi":"Add your first transaction here","sxkWRg":"Advanced","Mxjwaz":"All accounts","pXc4dB":"All Accounts","HoJ+ka":"All entries","LcouyV":"All your data will be deleted","Vw8l6h":"An error occurred","bhrKSa":"An error occurred while deleting the transaction","rBd1BM":"An error occurred while updating the transaction","+FI+0t":"App is locked. Please authenticate to continue.","2Yw5Eq":"App settings","rg8lHb":"App theme","aAIQg2":"Appearance","rH4FJH":"Are you sure you want to delete this budget? This action cannot be undone.","TE1tui":"Are you sure you want to delete your account? This action cannot be undone.","apLLSU":"Are you sure you want to sign out?","6foA8n":"Are you sure?","X2pgJW":"Ask AI anything...","kfcRb0":"Avatar","fsBGk0":"Balance","IGsZpB":"Budgets","HjGOT5":"By day","kYFORZ":"By month","OTL6lf":"By week","HjYcC9":"Camera permissions are not granted","dEgA5A":"Cancel","dZYaqU":"Cannot extract transaction data","NUrY9o":"Categories","i+de8A":"Category name","h4wXn9":"Choose a preferred theme for the 6pm","AUYALh":"Coming soon","xGVfLh":"Continue","RvVi9c":"Continue with Email","eGKI3t":"Copied version to clipboard","PxMcud":"Current balance","AJToWu":"Current state","7cFjHo":"Daily reminder","Zz6Cxn":"Danger zone","pvnfJD":"Dark","o5ooMr":"Debt","ovBPCi":"Default","WRwm0h":"Default currency","cnGeoo":"Delete","chkudi":"Delete 6pm account","VbtMs5":"Delete wallet account will also delete all related transactions!","pfa8F0":"Display name","rrOW2A":"Edit account","j1Jl7s":"Edit category","O3oNi5":"Email","QOINDn":"empty","ak+zF8":"Enable Push Notifications","/AHxlh":"Enable spending alerts","lYGfRP":"English","EmV+r3":"Enter the code sent to your email","xRPn3U":"Enter your email address","/o/2Tm":"Expense","aSBbnl":"Expenses","AL8ocL":"Family budget","xRJSOj":"From date","Weq9zb":"General","h52e9T":"Get 6pm Pro","EVORi1":"Get started by setting your monthly budget.","M1w7jC":"Grant camera permissions","Uq/imr":"If you\'re not sure, start with how much you usually spend per month.","xxsw3W":"Income","Z2b5qm":"Incomes","13aTWr":"Investing","AhuqH6":"Keeping up with your spending and budgets.","vXIe7J":"Language","brkKQW":"Left per day","PRzhQh":"Left this month","1njn7W":"Light","UC3YIm":"Login using FaceID","lkAlEG":"Magic inbox","+8Nek/":"Monthly","iBONBd":"Monthly budget","6YtxFj":"Name","xYG/fs":"Negative","XejmNR":"Negative if your content balance is under zero","6WSYbN":["New ",["0"]],"Kcr9Fr":"New account","5OdwzH":"New budget","tl5vsv":"New category","ApQ2nt":"No budget selected","xc4rPs":"No transactions","8bNIKG":"No transactions found","NuKR0h":"Others","198luN":"per day","NtQvjo":"Period","66fYpz":"Period end date","QTWhG5":"Period start date","FHx6kz":"Positive","ScJ9fj":"Privacy policy","LcET2C":"Privacy Policy","Z8pOEI":"Processing transaction...","vERlcd":"Profile","kUlL8W":"Profile updated successfully","++8ZXz":"Proudly open source","SZJG6+":"Push notifications","r7QRqI":"Push notifications are disabled","LI1qx1":"Push notifications are enabled","3yhyIW":"Push notifications are not enabled","kCxe8K":"Quarterly","j75BA9":"Rate 6pm on App Store","GkHlI/":"Revenue this month","8lh/OF":"Revenue this week","tfDRzk":"Save","y3aU20":"Save changes","uF9ruK":"Saving","WDgJiV":"Scanner","P9vd26":"Search currency...","UA6v4Z":"Seed transactions","+O3PfQ":"Select account","HfaFKV":"Select balance state","PtoMco":"Select budget type","5dfUzo":"Select period type","RoafuO":"Send feedback","PPcets":"Set as default","wCqgpu":"Set Budget","oyi6Xa":"Set Monthly Budget","dY304N":"Set your monthly spending goal","Tz0i8g":"Settings","RDprz0":"Share with friends","5lWFkC":"Sign in","+EnZBU":"Sign in with Apple","dbWo0h":"Sign in with Google","fcWrnU":"Sign out","e+RpCP":"Sign up","TOm5Xo":"Specific dates","Q14cFX":"Spending","FlGoyI":"Spent this month","Ozoj7N":"Spent this week","w5QjWi":"Swift up to scan transaction","J8R0ve":"Swipe up to scan transaction","D+NlUC":"System","IL5Ibf":"Take a picture of your transaction","Yrrg+y":"Target","KWUgwY":"Terms & Conditions","Emv+V7":"Terms of use","OR1t9P":"This will delete the transaction. Are you sure you want to continue?","sH0pkc":"Time to enter your expenses!","w4eKlT":"To date","ecUA8p":"Today","BRMXj0":"Tomorrow","38Gho6":"Transaction created","6D8usS":"transaction note","+zy2Nq":"Type","b2vAoQ":"Uncategorized","Ef7StM":"Unknown","29VNqC":"Unknown error","VAOn4r":"Unlock","QQX2/q":"Unlocks full AI power and more!","wPTug2":"Upload new photo","KALubG":"ver.","AdWhjZ":"Verification code","fROFIL":"Vietnamese","q19YJ1":"Wallet account name","rUcnTU":"Wallet accounts","mdad9N":"Wallet Accounts","4XSc4l":"Weekly","I+fC9+":"Welcome to 6pm!","zkWmBh":"Yearly","y/0uwd":"Yesterday","kDrMSv":"Your display name"}',
'{"J/hVSQ":[["0"]],"6MIiOI":[["0"]," left"],"FEZKSz":[["language"]],"4E30de":[["remainingDays"]," days left"],"GDr6hQ":"* you can always change this later.","VE5ikN":"<0><1>Manage your expense seamlessly</1><2>Let <3>6pm</3> a good time to spend</2></0>","ejSd6i":"<0>By continuing, you acknowledge that you understand and agree to our <1><2>Privacy Policy</2></1></0>","AYTmQ1":"<0>By continuing, you acknowledge that you understand and agree to the <1><2>Terms & Conditions</2></1> and <3><4>Privacy Policy</4></3></0>","LjsgKU":"0.00","y+OdTP":"Account deleted successfully","103Xyi":"Add your first transaction here","sxkWRg":"Advanced","Mxjwaz":"All accounts","pXc4dB":"All Accounts","HoJ+ka":"All entries","LcouyV":"All your data will be deleted","Vw8l6h":"An error occurred","bhrKSa":"An error occurred while deleting the transaction","rBd1BM":"An error occurred while updating the transaction","+FI+0t":"App is locked. Please authenticate to continue.","2Yw5Eq":"App settings","rg8lHb":"App theme","aAIQg2":"Appearance","rH4FJH":"Are you sure you want to delete this budget? This action cannot be undone.","B5mOB7":"Are you sure you want to delete this category? This action cannot be undone.","TE1tui":"Are you sure you want to delete your account? This action cannot be undone.","apLLSU":"Are you sure you want to sign out?","6foA8n":"Are you sure?","X2pgJW":"Ask AI anything...","kfcRb0":"Avatar","fsBGk0":"Balance","IGsZpB":"Budgets","HjGOT5":"By day","kYFORZ":"By month","OTL6lf":"By week","HjYcC9":"Camera permissions are not granted","dEgA5A":"Cancel","dZYaqU":"Cannot extract transaction data","NUrY9o":"Categories","/zI1zq":"Category deleted","i+de8A":"Category name","h4wXn9":"Choose a preferred theme for the 6pm","AUYALh":"Coming soon","xGVfLh":"Continue","RvVi9c":"Continue with Email","eGKI3t":"Copied version to clipboard","PxMcud":"Current balance","AJToWu":"Current state","7cFjHo":"Daily reminder","Zz6Cxn":"Danger zone","pvnfJD":"Dark","o5ooMr":"Debt","ovBPCi":"Default","WRwm0h":"Default currency","cnGeoo":"Delete","chkudi":"Delete 6pm account","VbtMs5":"Delete wallet account will also delete all related transactions!","pfa8F0":"Display name","rrOW2A":"Edit account","j1Jl7s":"Edit category","O3oNi5":"Email","QOINDn":"empty","ak+zF8":"Enable Push Notifications","/AHxlh":"Enable spending alerts","lYGfRP":"English","EmV+r3":"Enter the code sent to your email","xRPn3U":"Enter your email address","/o/2Tm":"Expense","aSBbnl":"Expenses","AL8ocL":"Family budget","xRJSOj":"From date","Weq9zb":"General","h52e9T":"Get 6pm Pro","EVORi1":"Get started by setting your monthly budget.","M1w7jC":"Grant camera permissions","Uq/imr":"If you\'re not sure, start with how much you usually spend per month.","xxsw3W":"Income","Z2b5qm":"Incomes","13aTWr":"Investing","AhuqH6":"Keeping up with your spending and budgets.","vXIe7J":"Language","brkKQW":"Left per day","PRzhQh":"Left this month","1njn7W":"Light","UC3YIm":"Login using FaceID","lkAlEG":"Magic inbox","+8Nek/":"Monthly","iBONBd":"Monthly budget","6YtxFj":"Name","xYG/fs":"Negative","XejmNR":"Negative if your content balance is under zero","6WSYbN":["New ",["0"]],"Kcr9Fr":"New account","5OdwzH":"New budget","tl5vsv":"New category","ApQ2nt":"No budget selected","xc4rPs":"No transactions","8bNIKG":"No transactions found","NuKR0h":"Others","198luN":"per day","NtQvjo":"Period","66fYpz":"Period end date","QTWhG5":"Period start date","FHx6kz":"Positive","ScJ9fj":"Privacy policy","LcET2C":"Privacy Policy","Z8pOEI":"Processing transaction...","vERlcd":"Profile","kUlL8W":"Profile updated successfully","++8ZXz":"Proudly open source","SZJG6+":"Push notifications","r7QRqI":"Push notifications are disabled","LI1qx1":"Push notifications are enabled","3yhyIW":"Push notifications are not enabled","kCxe8K":"Quarterly","j75BA9":"Rate 6pm on App Store","GkHlI/":"Revenue this month","8lh/OF":"Revenue this week","tfDRzk":"Save","y3aU20":"Save changes","uF9ruK":"Saving","WDgJiV":"Scanner","P9vd26":"Search currency...","UA6v4Z":"Seed transactions","+O3PfQ":"Select account","HfaFKV":"Select balance state","PtoMco":"Select budget type","5dfUzo":"Select period type","RoafuO":"Send feedback","PPcets":"Set as default","wCqgpu":"Set Budget","oyi6Xa":"Set Monthly Budget","dY304N":"Set your monthly spending goal","Tz0i8g":"Settings","RDprz0":"Share with friends","5lWFkC":"Sign in","+EnZBU":"Sign in with Apple","dbWo0h":"Sign in with Google","fcWrnU":"Sign out","e+RpCP":"Sign up","TOm5Xo":"Specific dates","Q14cFX":"Spending","FlGoyI":"Spent this month","Ozoj7N":"Spent this week","w5QjWi":"Swift up to scan transaction","J8R0ve":"Swipe up to scan transaction","D+NlUC":"System","IL5Ibf":"Take a picture of your transaction","Yrrg+y":"Target","KWUgwY":"Terms & Conditions","Emv+V7":"Terms of use","OR1t9P":"This will delete the transaction. Are you sure you want to continue?","sH0pkc":"Time to enter your expenses!","w4eKlT":"To date","ecUA8p":"Today","BRMXj0":"Tomorrow","38Gho6":"Transaction created","6D8usS":"transaction note","+zy2Nq":"Type","b2vAoQ":"Uncategorized","Ef7StM":"Unknown","29VNqC":"Unknown error","VAOn4r":"Unlock","QQX2/q":"Unlocks full AI power and more!","wPTug2":"Upload new photo","KALubG":"ver.","AdWhjZ":"Verification code","fROFIL":"Vietnamese","q19YJ1":"Wallet account name","rUcnTU":"Wallet accounts","mdad9N":"Wallet Accounts","4XSc4l":"Weekly","I+fC9+":"Welcome to 6pm!","zkWmBh":"Yearly","y/0uwd":"Yesterday","kDrMSv":"Your display name"}',
) as Messages
10 changes: 10 additions & 0 deletions apps/mobile/locales/vi/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ msgstr "Giao diện"
msgid "Are you sure you want to delete this budget? This action cannot be undone."
msgstr "Bạn có chắc chắn muốn xóa ngân sách này? Hành động này không thể hoàn tác."

#: apps/mobile/app/(app)/category/[categoryId].tsx:36
msgid "Are you sure you want to delete this category? This action cannot be undone."
msgstr "Bạn có chắc chắn muốn xóa danh mục này? Hành động này không thể hoàn tác."

#: apps/mobile/app/(app)/profile.tsx:115
msgid "Are you sure you want to delete your account? This action cannot be undone."
msgstr "Bạn có chắc chắn muốn xóa tài khoản của bạn? Hành động này không thể hoàn tác."
Expand Down Expand Up @@ -159,6 +163,7 @@ msgstr "Quyền truy cập camera không được cấp"

#: apps/mobile/app/(app)/(tabs)/settings.tsx:248
#: apps/mobile/app/(app)/budget/[budgetId]/edit.tsx:45
#: apps/mobile/app/(app)/category/[categoryId].tsx:42
#: apps/mobile/app/(app)/profile.tsx:120
#: apps/mobile/app/(app)/transaction/[transactionId].tsx:77
#: apps/mobile/app/(app)/wallet/[walletId].tsx:77
Expand All @@ -174,6 +179,10 @@ msgstr "Không thể xử lý dữ liệu giao dịch"
msgid "Categories"
msgstr "Danh mục"

#: apps/mobile/app/(app)/category/[categoryId].tsx:51
msgid "Category deleted"
msgstr "Đã xóa danh mục"

#: apps/mobile/components/category/category-form.tsx:67
msgid "Category name"
msgstr "Tên danh mục"
Expand Down Expand Up @@ -232,6 +241,7 @@ msgid "Default currency"
msgstr "Đơn vị mặc định"

#: apps/mobile/app/(app)/budget/[budgetId]/edit.tsx:49
#: apps/mobile/app/(app)/category/[categoryId].tsx:46
#: apps/mobile/app/(app)/profile.tsx:124
#: apps/mobile/app/(app)/transaction/[transactionId].tsx:81
#: apps/mobile/app/(app)/wallet/[walletId].tsx:81
Expand Down
Loading

0 comments on commit 0d0fa02

Please sign in to comment.