From 7eb121aee747d0639463425401b7d7f054ba1b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qu=E1=BB=91c=20Kh=C3=A1nh?= Date: Sun, 1 Sep 2024 19:56:56 +0700 Subject: [PATCH] feat(mobile): add delete category --- .../app/(app)/category/[categoryId].tsx | 56 ++++++++++++++++++- apps/mobile/locales/en/messages.po | 10 ++++ apps/mobile/locales/en/messages.ts | 2 +- apps/mobile/locales/vi/messages.po | 10 ++++ apps/mobile/locales/vi/messages.ts | 2 +- apps/mobile/stores/category/hooks.tsx | 24 ++++++++ apps/mobile/stores/category/store.ts | 7 +++ 7 files changed, 106 insertions(+), 5 deletions(-) diff --git a/apps/mobile/app/(app)/category/[categoryId].tsx b/apps/mobile/app/(app)/category/[categoryId].tsx index febc799e..2febc0be 100644 --- a/apps/mobile/app/(app)/category/[categoryId].tsx +++ b/apps/mobile/app/(app)/category/[categoryId].tsx @@ -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: + useEffect(() => { + navigation.setOptions({ + headerRight: () => ( + + ), + }) + }, []) if (!category) { return ( diff --git a/apps/mobile/locales/en/messages.po b/apps/mobile/locales/en/messages.po index 8ec82b74..0bd6a36a 100644 --- a/apps/mobile/locales/en/messages.po +++ b/apps/mobile/locales/en/messages.po @@ -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 "" @@ -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 @@ -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 "" @@ -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 diff --git a/apps/mobile/locales/en/messages.ts b/apps/mobile/locales/en/messages.ts index ac72f7ca..0d3248e4 100644 --- a/apps/mobile/locales/en/messages.ts +++ b/apps/mobile/locales/en/messages.ts @@ -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<2>Let <3>6pm a good time to spend","ejSd6i":"<0>By continuing, you acknowledge that you understand and agree to our <1><2>Privacy Policy","AYTmQ1":"<0>By continuing, you acknowledge that you understand and agree to the <1><2>Terms & Conditions and <3><4>Privacy Policy","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<2>Let <3>6pm a good time to spend","ejSd6i":"<0>By continuing, you acknowledge that you understand and agree to our <1><2>Privacy Policy","AYTmQ1":"<0>By continuing, you acknowledge that you understand and agree to the <1><2>Terms & Conditions and <3><4>Privacy Policy","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 diff --git a/apps/mobile/locales/vi/messages.po b/apps/mobile/locales/vi/messages.po index 85d22505..53b85908 100644 --- a/apps/mobile/locales/vi/messages.po +++ b/apps/mobile/locales/vi/messages.po @@ -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." @@ -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 @@ -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" @@ -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 diff --git a/apps/mobile/locales/vi/messages.ts b/apps/mobile/locales/vi/messages.ts index d4be0e78..392cb2c7 100644 --- a/apps/mobile/locales/vi/messages.ts +++ b/apps/mobile/locales/vi/messages.ts @@ -1,4 +1,4 @@ /*eslint-disable*/ import type { Messages } from '@lingui/core' export const messages = JSON.parse( - '{"J/hVSQ":[["0"]],"6MIiOI":[["0"]," còn lại"],"FEZKSz":[["language"]],"4E30de":["còn ",["remainingDays"]," ngày"],"GDr6hQ":"* bạn có thể cập nhật lại sau.","VE5ikN":"<0><1>Quản lý chi tiêu hiệu quả<2>Không lo cháy túi mỗi <3>6pm","ejSd6i":"<0>Bằng cách tiếp tục, bạn đã hiểu và đồng ý với <1><2>Chính sách bảo mật của 6pm.","AYTmQ1":"<0>Bằng cách tiếp tục, bạn đã hiểu và đồng ý với <1><2>Điều khoản sử dụng và <3><4>Chính sách bảo mật của 6pm.","LjsgKU":"0.00","y+OdTP":"Xóa tài khoản thành công","103Xyi":"Thêm giao dịch đầu tiên ở đây","sxkWRg":"Nâng cao","Mxjwaz":"Tất cả tài khoản","pXc4dB":"Tất cả tài khoản","HoJ+ka":"Xem tất cả","LcouyV":"Tất cả dữ liệu của bạn sẽ bị xóa","Vw8l6h":"Có lỗi xảy ra","bhrKSa":"Có lỗi xảy ra khi xóa giao dịch","rBd1BM":"Có lỗi xảy ra khi cập nhật giao dịch","+FI+0t":"Ứng dụng đã khóa. Vui lòng xác thực để tiếp tục.","2Yw5Eq":"Cài đặt ứng dụng","rg8lHb":"Chủ đề ứng dụng","aAIQg2":"Giao diện","rH4FJH":"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.","TE1tui":"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.","apLLSU":"Bạn có chắc chắn muốn đăng xuất?","6foA8n":"Bạn chắc chưa?","X2pgJW":"Hỏi AI bất kỳ gì...","kfcRb0":"Ảnh đại diện","fsBGk0":"Số dư","IGsZpB":"Ngân sách","HjGOT5":"Theo ngày","kYFORZ":"Theo tháng","OTL6lf":"Theo tuần","HjYcC9":"Quyền truy cập camera không được cấp","dEgA5A":"Huỷ","dZYaqU":"Không thể xử lý dữ liệu giao dịch","NUrY9o":"Danh mục","i+de8A":"Tên danh mục","h4wXn9":"Chọn chủ đề giao diện cho 6pm","AUYALh":"Sắp xong","xGVfLh":"Tiếp tục","RvVi9c":"Tiếp tục với Email","eGKI3t":"Đã sao chép số phiên bản","PxMcud":"Số dư hiện tại","AJToWu":"Trạng thái","7cFjHo":"Nhắc nhở hàng ngày","Zz6Cxn":"Vùng nguy hiểm","pvnfJD":"Tối","o5ooMr":"Nợ","ovBPCi":"Mặc định","WRwm0h":"Đơn vị mặc định","cnGeoo":"Xóa","chkudi":"Xóa tài khoản 6pm","VbtMs5":"Xóa tài khoản ví sẽ cũng xóa tất cả các giao dịch liên quan!","pfa8F0":"Tên hiển thị","rrOW2A":"Chỉnh sửa tài khoản","j1Jl7s":"Chỉnh sửa danh mục","O3oNi5":"Email","QOINDn":"trống","ak+zF8":"Bật Thông Báo Đẩy","/AHxlh":"Nhận thông báo chi tiêu","lYGfRP":"Tiếng Anh","EmV+r3":"Nhập mã xác nhận gửi đến email của bạn","xRPn3U":"Nhập địa chỉ email của bạn","/o/2Tm":"Chi tiêu","aSBbnl":"Chi tiêu","AL8ocL":"Ngân sách gia đình","xRJSOj":"Từ ngày","Weq9zb":"Chung","h52e9T":"Nâng Cấp 6pm Pro","EVORi1":"Bắt đầu bằng cách đặt ngân sách hàng tháng của bạn.","M1w7jC":"Cấp quyền truy cập camera","Uq/imr":"Nếu không chắc chắn, hãy nhập số tiền bạn thường chi tiêu hàng tháng.","xxsw3W":"Thu nhập","Z2b5qm":"Thu nhập","13aTWr":"Đầu tư","AhuqH6":"Theo dõi kịp tình hình chi tiêu và ngân sách.","vXIe7J":"Ngôn ngữ","brkKQW":"Còn lại mỗi ngày","PRzhQh":"Còn lại tháng này","1njn7W":"Sáng","UC3YIm":"Đăng nhập bằng FaceID","lkAlEG":"Hộp thư ma thuật","+8Nek/":"Hàng tháng","iBONBd":"Ngân sách tháng","6YtxFj":"Tên","xYG/fs":"Âm","XejmNR":"Âm nếu số dư tài khoản dưới 0","6WSYbN":["Tạo mới ",["0"]],"Kcr9Fr":"Tạo tài khoản mới","5OdwzH":"Tạo ngân sách","tl5vsv":"Tạo danh mục mới","ApQ2nt":"Chọn ngân sách","xc4rPs":"Không có giao dịch","8bNIKG":"Không tìm thấy giao dịch","NuKR0h":"Khác","198luN":"mỗi ngày","NtQvjo":"Period","66fYpz":"Ngày kết thúc","QTWhG5":"Ngày bắt đầu","FHx6kz":"Dương","ScJ9fj":"Chính sách bảo mật","LcET2C":"Chính sách bảo mật","Z8pOEI":"Đang xử lý giao dịch...","vERlcd":"Hồ sơ","kUlL8W":"Cập nhật hồ sơ thành công","++8ZXz":"Mã nguồn mở","SZJG6+":"Thông báo đẩy","r7QRqI":"Thông báo đẩy bị vô hiệu hóa","LI1qx1":"Thông báo đẩy đã được bật","3yhyIW":"Thông báo đẩy chưa được bật","kCxe8K":"Hàng quý","j75BA9":"Đánh giá 6pm trên App Store","GkHlI/":"Doanh thu tháng này","8lh/OF":"Doanh thu tuần này","tfDRzk":"Lưu","y3aU20":"Lưu thay đổi","uF9ruK":"Đang lưu","WDgJiV":"Quét hoá đơn","P9vd26":"Tìm kiếm đơn vị...","UA6v4Z":"Tạo giao dịch mẫu","+O3PfQ":"Chọn tài khoản","HfaFKV":"Chọn trạng thái số dư","PtoMco":"Chọn loại ngân sách","5dfUzo":"Chọn loại chu kỳ","RoafuO":"Gửi phản hồi","PPcets":"Đặt làm mặc định","wCqgpu":"Lưu Ngân Sách","oyi6Xa":"Đặt Ngân Sách Tháng","dY304N":"Đặt mục tiêu chi tiêu hàng tháng","Tz0i8g":"Cài đặt","RDprz0":"Chia sẻ với bạn bè","5lWFkC":"Đăng nhập","+EnZBU":"Tiếp tục với Apple","dbWo0h":"Tiếp tục với Google","fcWrnU":"Đăng xuất","e+RpCP":"Đăng ký","TOm5Xo":"Ngày cụ thể","Q14cFX":"Chi tiêu","FlGoyI":"Chi tiêu tháng này","Ozoj7N":"Chi tiêu tuần này","w5QjWi":"Vuốt lên để quét giao dịch","J8R0ve":"Vuốt lên để quét giao dịch","D+NlUC":"Hệ thống","IL5Ibf":"Chụp ảnh giao dịch của bạn","Yrrg+y":"Mục tiêu","KWUgwY":"Điều khoản sử dụng","Emv+V7":"Điều khoản sử dụng","OR1t9P":"Hành động này sẽ xóa giao dịch. Bạn có chắc chắn muốn tiếp tục không?","sH0pkc":"Đến giờ nhập chi tiêu hôm nay!","w4eKlT":"Đến ngày","ecUA8p":"Hôm nay","BRMXj0":"Ngày mai","38Gho6":"Giao dịch đã được tạo","6D8usS":"ghi chú giao dịch","+zy2Nq":"Loại","b2vAoQ":"Chưa phân loại","Ef7StM":"Không xác định","29VNqC":"Lỗi không xác định","VAOn4r":"Mở khóa","QQX2/q":"Mở khóa sức mạnh AI và các tính năng khác!","wPTug2":"Tải lên ảnh mới","KALubG":"ver.","AdWhjZ":"Mã xác nhận","fROFIL":"Tiếng Việt","q19YJ1":"Tên tài khoản ví","rUcnTU":"Quản lý tài khoản ví","mdad9N":"Các tài khoản","4XSc4l":"Hàng tuần","I+fC9+":"Chào mừng đến 6pm!","zkWmBh":"Hàng năm","y/0uwd":"Hôm qua","kDrMSv":"Tên hiển thị của bạn"}', + '{"J/hVSQ":[["0"]],"6MIiOI":[["0"]," còn lại"],"FEZKSz":[["language"]],"4E30de":["còn ",["remainingDays"]," ngày"],"GDr6hQ":"* bạn có thể cập nhật lại sau.","VE5ikN":"<0><1>Quản lý chi tiêu hiệu quả<2>Không lo cháy túi mỗi <3>6pm","ejSd6i":"<0>Bằng cách tiếp tục, bạn đã hiểu và đồng ý với <1><2>Chính sách bảo mật của 6pm.","AYTmQ1":"<0>Bằng cách tiếp tục, bạn đã hiểu và đồng ý với <1><2>Điều khoản sử dụng và <3><4>Chính sách bảo mật của 6pm.","LjsgKU":"0.00","y+OdTP":"Xóa tài khoản thành công","103Xyi":"Thêm giao dịch đầu tiên ở đây","sxkWRg":"Nâng cao","Mxjwaz":"Tất cả tài khoản","pXc4dB":"Tất cả tài khoản","HoJ+ka":"Xem tất cả","LcouyV":"Tất cả dữ liệu của bạn sẽ bị xóa","Vw8l6h":"Có lỗi xảy ra","bhrKSa":"Có lỗi xảy ra khi xóa giao dịch","rBd1BM":"Có lỗi xảy ra khi cập nhật giao dịch","+FI+0t":"Ứng dụng đã khóa. Vui lòng xác thực để tiếp tục.","2Yw5Eq":"Cài đặt ứng dụng","rg8lHb":"Chủ đề ứng dụng","aAIQg2":"Giao diện","rH4FJH":"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.","B5mOB7":"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.","TE1tui":"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.","apLLSU":"Bạn có chắc chắn muốn đăng xuất?","6foA8n":"Bạn chắc chưa?","X2pgJW":"Hỏi AI bất kỳ gì...","kfcRb0":"Ảnh đại diện","fsBGk0":"Số dư","IGsZpB":"Ngân sách","HjGOT5":"Theo ngày","kYFORZ":"Theo tháng","OTL6lf":"Theo tuần","HjYcC9":"Quyền truy cập camera không được cấp","dEgA5A":"Huỷ","dZYaqU":"Không thể xử lý dữ liệu giao dịch","NUrY9o":"Danh mục","/zI1zq":"Đã xóa danh mục","i+de8A":"Tên danh mục","h4wXn9":"Chọn chủ đề giao diện cho 6pm","AUYALh":"Sắp xong","xGVfLh":"Tiếp tục","RvVi9c":"Tiếp tục với Email","eGKI3t":"Đã sao chép số phiên bản","PxMcud":"Số dư hiện tại","AJToWu":"Trạng thái","7cFjHo":"Nhắc nhở hàng ngày","Zz6Cxn":"Vùng nguy hiểm","pvnfJD":"Tối","o5ooMr":"Nợ","ovBPCi":"Mặc định","WRwm0h":"Đơn vị mặc định","cnGeoo":"Xóa","chkudi":"Xóa tài khoản 6pm","VbtMs5":"Xóa tài khoản ví sẽ cũng xóa tất cả các giao dịch liên quan!","pfa8F0":"Tên hiển thị","rrOW2A":"Chỉnh sửa tài khoản","j1Jl7s":"Chỉnh sửa danh mục","O3oNi5":"Email","QOINDn":"trống","ak+zF8":"Bật Thông Báo Đẩy","/AHxlh":"Nhận thông báo chi tiêu","lYGfRP":"Tiếng Anh","EmV+r3":"Nhập mã xác nhận gửi đến email của bạn","xRPn3U":"Nhập địa chỉ email của bạn","/o/2Tm":"Chi tiêu","aSBbnl":"Chi tiêu","AL8ocL":"Ngân sách gia đình","xRJSOj":"Từ ngày","Weq9zb":"Chung","h52e9T":"Nâng Cấp 6pm Pro","EVORi1":"Bắt đầu bằng cách đặt ngân sách hàng tháng của bạn.","M1w7jC":"Cấp quyền truy cập camera","Uq/imr":"Nếu không chắc chắn, hãy nhập số tiền bạn thường chi tiêu hàng tháng.","xxsw3W":"Thu nhập","Z2b5qm":"Thu nhập","13aTWr":"Đầu tư","AhuqH6":"Theo dõi kịp tình hình chi tiêu và ngân sách.","vXIe7J":"Ngôn ngữ","brkKQW":"Còn lại mỗi ngày","PRzhQh":"Còn lại tháng này","1njn7W":"Sáng","UC3YIm":"Đăng nhập bằng FaceID","lkAlEG":"Hộp thư ma thuật","+8Nek/":"Hàng tháng","iBONBd":"Ngân sách tháng","6YtxFj":"Tên","xYG/fs":"Âm","XejmNR":"Âm nếu số dư tài khoản dưới 0","6WSYbN":["Tạo mới ",["0"]],"Kcr9Fr":"Tạo tài khoản mới","5OdwzH":"Tạo ngân sách","tl5vsv":"Tạo danh mục mới","ApQ2nt":"Chọn ngân sách","xc4rPs":"Không có giao dịch","8bNIKG":"Không tìm thấy giao dịch","NuKR0h":"Khác","198luN":"mỗi ngày","NtQvjo":"Period","66fYpz":"Ngày kết thúc","QTWhG5":"Ngày bắt đầu","FHx6kz":"Dương","ScJ9fj":"Chính sách bảo mật","LcET2C":"Chính sách bảo mật","Z8pOEI":"Đang xử lý giao dịch...","vERlcd":"Hồ sơ","kUlL8W":"Cập nhật hồ sơ thành công","++8ZXz":"Mã nguồn mở","SZJG6+":"Thông báo đẩy","r7QRqI":"Thông báo đẩy bị vô hiệu hóa","LI1qx1":"Thông báo đẩy đã được bật","3yhyIW":"Thông báo đẩy chưa được bật","kCxe8K":"Hàng quý","j75BA9":"Đánh giá 6pm trên App Store","GkHlI/":"Doanh thu tháng này","8lh/OF":"Doanh thu tuần này","tfDRzk":"Lưu","y3aU20":"Lưu thay đổi","uF9ruK":"Đang lưu","WDgJiV":"Quét hoá đơn","P9vd26":"Tìm kiếm đơn vị...","UA6v4Z":"Tạo giao dịch mẫu","+O3PfQ":"Chọn tài khoản","HfaFKV":"Chọn trạng thái số dư","PtoMco":"Chọn loại ngân sách","5dfUzo":"Chọn loại chu kỳ","RoafuO":"Gửi phản hồi","PPcets":"Đặt làm mặc định","wCqgpu":"Lưu Ngân Sách","oyi6Xa":"Đặt Ngân Sách Tháng","dY304N":"Đặt mục tiêu chi tiêu hàng tháng","Tz0i8g":"Cài đặt","RDprz0":"Chia sẻ với bạn bè","5lWFkC":"Đăng nhập","+EnZBU":"Tiếp tục với Apple","dbWo0h":"Tiếp tục với Google","fcWrnU":"Đăng xuất","e+RpCP":"Đăng ký","TOm5Xo":"Ngày cụ thể","Q14cFX":"Chi tiêu","FlGoyI":"Chi tiêu tháng này","Ozoj7N":"Chi tiêu tuần này","w5QjWi":"Vuốt lên để quét giao dịch","J8R0ve":"Vuốt lên để quét giao dịch","D+NlUC":"Hệ thống","IL5Ibf":"Chụp ảnh giao dịch của bạn","Yrrg+y":"Mục tiêu","KWUgwY":"Điều khoản sử dụng","Emv+V7":"Điều khoản sử dụng","OR1t9P":"Hành động này sẽ xóa giao dịch. Bạn có chắc chắn muốn tiếp tục không?","sH0pkc":"Đến giờ nhập chi tiêu hôm nay!","w4eKlT":"Đến ngày","ecUA8p":"Hôm nay","BRMXj0":"Ngày mai","38Gho6":"Giao dịch đã được tạo","6D8usS":"ghi chú giao dịch","+zy2Nq":"Loại","b2vAoQ":"Chưa phân loại","Ef7StM":"Không xác định","29VNqC":"Lỗi không xác định","VAOn4r":"Mở khóa","QQX2/q":"Mở khóa sức mạnh AI và các tính năng khác!","wPTug2":"Tải lên ảnh mới","KALubG":"ver.","AdWhjZ":"Mã xác nhận","fROFIL":"Tiếng Việt","q19YJ1":"Tên tài khoản ví","rUcnTU":"Quản lý tài khoản ví","mdad9N":"Các tài khoản","4XSc4l":"Hàng tuần","I+fC9+":"Chào mừng đến 6pm!","zkWmBh":"Hàng năm","y/0uwd":"Hôm qua","kDrMSv":"Tên hiển thị của bạn"}', ) as Messages diff --git a/apps/mobile/stores/category/hooks.tsx b/apps/mobile/stores/category/hooks.tsx index 6fccf557..d621f048 100644 --- a/apps/mobile/stores/category/hooks.tsx +++ b/apps/mobile/stores/category/hooks.tsx @@ -1,3 +1,4 @@ +import { toast } from '@/components/common/toast' import { getHonoClient } from '@/lib/client' import { useMeQuery } from '@/queries/auth' import { @@ -160,3 +161,26 @@ export const useCreateCategory = () => { return mutation } + +export function useDeleteCategory() { + const deleteCategoryInStore = useCategoryStore( + (state) => state.deleteCategory, + ) + + const mutation = useMutation({ + mutationFn: async (categoryId: string) => { + const hc = await getHonoClient() + await hc.v1.categories[':categoryId'].$delete({ + param: { categoryId }, + }) + }, + onMutate(categoryId) { + deleteCategoryInStore(categoryId) + }, + onError(error) { + toast.error(error.message) + }, + throwOnError: true, + }) + return mutation +} diff --git a/apps/mobile/stores/category/store.ts b/apps/mobile/stores/category/store.ts index 785b960a..1e8210dc 100644 --- a/apps/mobile/stores/category/store.ts +++ b/apps/mobile/stores/category/store.ts @@ -9,6 +9,7 @@ interface CategoryStore { _reset: () => void setCategories: (categories: Category[]) => void updateCategory: (category: Category) => void + deleteCategory: (categoryId: string) => void } function normalizeCategories(categories: Category[]) { @@ -35,6 +36,12 @@ export const useCategoryStore = create()( state.categories[index] = category return { categories: normalizeCategories(state.categories) } }), + deleteCategory: (categoryId) => + set((state) => { + return { + categories: state.categories.filter((c) => c.id !== categoryId), + } + }), }), { name: 'category-storage',