Skip to content

Commit 700549b

Browse files
committed
refactor: fix forwardRef, add type and improve props
1 parent 15aa724 commit 700549b

File tree

18 files changed

+649
-290
lines changed

18 files changed

+649
-290
lines changed

apps/app/app/(admin)/categories/view.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { CategoryDialog } from '@/components/dialog/CategoryDialog'
2727
import { SubcategoryDialog } from '@/components/dialog/SubcategoryDialog'
2828
import { useCategory } from '@/hooks/useCategory'
2929
import { CategoryItem } from '@/components/item/CategoryItem'
30+
import Divider from '@/components/other/Divider'
3031

3132
export default function CategoryView() {
3233
const t = useTranslations()
@@ -167,7 +168,7 @@ export default function CategoryView() {
167168
</a>
168169
{localCategoryList.length > 0 && (
169170
<>
170-
<hr />
171+
<Divider></Divider>
171172
<a
172173
className='flex items-center space-x-2 w-full'
173174
onClick={() => openNew('subcategory')}

apps/app/app/(admin)/transactions/view.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { IFilterOptions, ITransaction } from '@poveroh/types'
3030

3131
import { isEmpty } from 'lodash'
3232
import { Popover, PopoverContent, PopoverTrigger } from '@poveroh/ui/components/popover'
33+
import Divider from '@/components/other/Divider'
3334

3435
export default function TransactionsView() {
3536
const t = useTranslations()
@@ -151,7 +152,7 @@ export default function TransactionsView() {
151152
<Upload />
152153
<p>{t('buttons.add.import')}</p>
153154
</a>
154-
<hr />
155+
<Divider />
155156
<a
156157
className='flex items-center space-x-2 w-full'
157158
onClick={() => {
@@ -228,7 +229,7 @@ export default function TransactionsView() {
228229
</div>
229230
{(bankAccountCacheList.length == 0 || categoryCacheList.length == 0) && (
230231
<>
231-
<hr className='w-full' />
232+
<Divider />
232233
<div className='flex flex-col items-center space-y-8 justify-center'>
233234
<div className='flex flex-col items-center space-y-2 justify-center'>
234235
<p className='warning'>{t('messages.noCategoriesAndAccountTitle')}</p>

apps/app/components/filter/FilterButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
88
import { ListFilter } from 'lucide-react'
99
import { useTranslations } from 'next-intl'
1010
import { FilterField } from '@poveroh/types'
11+
import Divider from '../other/Divider'
1112

1213
type FilterButtonProps<T extends Record<string, any>> = {
1314
fields: FilterField[]
@@ -68,7 +69,7 @@ export function FilterButton<T extends Record<string, any>>({ fields, filters, o
6869
/>
6970
)}
7071

71-
{fields.length - 1 !== index && <hr />}
72+
{fields.length - 1 !== index && <Divider />}
7273
</div>
7374
))}
7475
</div>

apps/app/components/form/BankAccountForm.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { z } from 'zod'
66
import { zodResolver } from '@hookform/resolvers/zod'
77
import { useTranslations } from 'next-intl'
88

9-
import { BankAccountType, IBankAccount, IItem } from '@poveroh/types'
9+
import { BankAccountType, FormRef, IBankAccount, IItem } from '@poveroh/types'
1010

1111
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@poveroh/ui/components/form'
1212
import { Input } from '@poveroh/ui/components/input'
@@ -26,9 +26,11 @@ type FormProps = {
2626
closeDialog: () => void
2727
}
2828

29-
export const BankAccountForm = forwardRef(({ initialData, inEditingMode, dataCallback }: FormProps, ref) => {
29+
export const BankAccountForm = forwardRef<FormRef, FormProps>((props: FormProps, ref) => {
3030
const t = useTranslations()
3131

32+
const { initialData, inEditingMode, dataCallback } = props
33+
3234
const { getTypeList } = useBankAccount()
3335
const { handleError } = useError()
3436

apps/app/components/form/CategoryForm.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { z } from 'zod'
66
import { zodResolver } from '@hookform/resolvers/zod'
77
import { useTranslations } from 'next-intl'
88

9-
import { ICategory, IItem } from '@poveroh/types'
9+
import { FormRef, ICategory, IItem } from '@poveroh/types'
1010

1111
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@poveroh/ui/components/form'
1212
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@poveroh/ui/components/select'
@@ -26,8 +26,11 @@ type FormProps = {
2626
closeDialog: () => void
2727
}
2828

29-
export const CategoryForm = forwardRef(({ initialData, inEditingMode, dataCallback }: FormProps, ref) => {
29+
export const CategoryForm = forwardRef<FormRef, FormProps>((props: FormProps, ref) => {
3030
const t = useTranslations()
31+
32+
const { initialData, inEditingMode, dataCallback } = props
33+
3134
const { handleError } = useError()
3235
const { getActionList } = useTransaction()
3336

apps/app/components/form/SubcategoryForm.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { z } from 'zod'
66
import { zodResolver } from '@hookform/resolvers/zod'
77
import { useTranslations } from 'next-intl'
88

9-
import { ICategory, ISubcategory, TransactionAction } from '@poveroh/types'
9+
import { FormRef, ICategory, ISubcategory, TransactionAction } from '@poveroh/types'
1010

1111
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@poveroh/ui/components/form'
1212
import {
@@ -33,8 +33,11 @@ type FormProps = {
3333
closeDialog: () => void
3434
}
3535

36-
export const SubcategoryForm = forwardRef(({ initialData, inEditingMode, dataCallback }: FormProps, ref) => {
36+
export const SubcategoryForm = forwardRef<FormRef, FormProps>((props: FormProps, ref) => {
3737
const t = useTranslations()
38+
39+
const { initialData, inEditingMode, dataCallback } = props
40+
3841
const { handleError } = useError()
3942

4043
const { categoryCacheList } = useCategory()

0 commit comments

Comments
 (0)