diff --git a/package.json b/package.json index 9e140cedf..1394b8f5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iSunFA", - "version": "0.8.2+39", + "version": "0.8.2+40", "private": false, "scripts": { "dev": "next dev", diff --git a/src/components/voucher/asset_section.tsx b/src/components/voucher/asset_section.tsx index 0d58ea807..c524ffb33 100644 --- a/src/components/voucher/asset_section.tsx +++ b/src/components/voucher/asset_section.tsx @@ -1,10 +1,12 @@ import React, { useState } from 'react'; import Image from 'next/image'; +import { useTranslation } from 'next-i18next'; import { FiEdit, FiPlus, FiTrash2 } from 'react-icons/fi'; import { Button } from '@/components/button/button'; import { IAssetItem, mockAssetItem } from '@/interfaces/asset'; const AssetSection: React.FC = () => { + const { t } = useTranslation('common'); const [assets, setAssets] = useState([]); // ToDo: (20241009 - Julian) Replace with real function to add asset @@ -63,8 +65,8 @@ const AssetSection: React.FC = () => { }) ) : (
-

Empty

-

Please add at least 1 asset!

+

{t('common:COMMON.EMPTY')}

+

{t('journal:ASSET_SECTION.EMPTY_HINT')}

); @@ -75,7 +77,7 @@ const AssetSection: React.FC = () => {
asset_icon -

Asset

+

{t('journal:ASSET_SECTION.TITLE')}


@@ -84,7 +86,7 @@ const AssetSection: React.FC = () => { {displayedAssetList} diff --git a/src/components/voucher/new_voucher_form.tsx b/src/components/voucher/new_voucher_form.tsx index 668afd198..40c493dea 100644 --- a/src/components/voucher/new_voucher_form.tsx +++ b/src/components/voucher/new_voucher_form.tsx @@ -279,11 +279,15 @@ const NewVoucherForm: React.FC = () => { setRecurringMenuOpen(!isRecurringMenuOpen); }; - // ToDo: (20240926 - Julian) type 字串轉換 + // Info: (20240926 - Julian) type 字串轉換 const translateType = (voucherType: string) => { return t(`journal:ADD_NEW_VOUCHER.TYPE_${voucherType.toUpperCase()}`); }; + const translateUnit = (unit: RecurringUnit) => { + return t(`common:COMMON.${unit.toUpperCase()}`); + }; + // Info: (20241004 - Julian) 清空表單 const clearAllHandler = () => { setDate(default30DayPeriodInSec); @@ -573,7 +577,7 @@ const NewVoucherForm: React.FC = () => { className="py-8px hover:bg-dropdown-surface-menu-background-secondary" onClick={recurringUnitClickHandler} > - {t(`common:COMMON.${unit.toUpperCase()}`)} + {translateUnit(unit)} ); })} @@ -742,7 +746,7 @@ const NewVoucherForm: React.FC = () => { onClick={recurringUnitToggleHandler} className="relative flex flex-1 items-center justify-between px-12px py-10px text-input-text-input-filled hover:cursor-pointer" > -

{recurringUnit}

+

{translateUnit(recurringUnit)}

{/* Info: (20240926 - Julian) recurring unit dropdown */} {recurringUnitMenu} diff --git a/src/components/voucher/reverse_section.tsx b/src/components/voucher/reverse_section.tsx index e4b7c0b6a..85e03cd00 100644 --- a/src/components/voucher/reverse_section.tsx +++ b/src/components/voucher/reverse_section.tsx @@ -1,5 +1,6 @@ import React, { useState } from 'react'; import Image from 'next/image'; +import { useTranslation } from 'next-i18next'; import { BsChevronDown } from 'react-icons/bs'; import { FiTrash2 } from 'react-icons/fi'; import { LuPlus } from 'react-icons/lu'; @@ -15,6 +16,8 @@ interface IReverseSectionProps { } const ReverseLine: React.FC = ({ isShowReverseVoucherHint = false }) => { + const { t } = useTranslation('common'); + const [selectedVoucher, setSelectedVoucher] = useState(null); const [reverseAmountInput, setReverseAmountInput] = useState(''); // ToDo: (20241009 - Julian) Send reverse amount to backend @@ -57,7 +60,7 @@ const ReverseLine: React.FC = ({ isShowReverseVoucherHint

- Please select... + {t('journal:REVERSE_SECTION.REVERSE_VOUCHER_PLACEHOLDER')}

); @@ -96,7 +99,7 @@ const ReverseLine: React.FC = ({ isShowReverseVoucherHint {/* Info: (20241009 - Julian) reverse voucher */}

- Reverse Voucher + {t('journal:REVERSE_SECTION.REVERSE_VOUCHER')} *

= ({ isShowReverseVoucherHint {/* Info: (20241009 - Julian) reverse amount */}

- Reverse Amount + {t('journal:REVERSE_SECTION.REVERSE_AMOUNT')} *

@@ -146,6 +149,8 @@ const ReverseLine: React.FC = ({ isShowReverseVoucherHint }; const ReverseSection: React.FC = () => { + const { t } = useTranslation('common'); + const [reverseLineItems, setReverseLineItems] = useState([1]); // ToDo: (20241009 - Julian) Implement addReverseLineItem @@ -164,7 +169,7 @@ const ReverseSection: React.FC = () => {
bell_icon -

Reverse

+

{t('journal:REVERSE_SECTION.TITLE')}


@@ -178,7 +183,7 @@ const ReverseSection: React.FC = () => { onClick={addReverseLineItem} > -

Add more reverse voucher

+

{t('journal:REVERSE_SECTION.ADD_BTN')}

diff --git a/src/constants/asset.ts b/src/constants/asset.ts index 940c34be4..77b5c7f57 100644 --- a/src/constants/asset.ts +++ b/src/constants/asset.ts @@ -67,5 +67,5 @@ export const AccountCodesOfAsset = [ export const AccountCodesOfAPandAR = [ '1172', // 應收帳款 - '2170', // 應付帳款 + '2171', // 應付帳款 ]; diff --git a/src/locales/cn/journal.json b/src/locales/cn/journal.json index 00fdb8489..17cc25fee 100644 --- a/src/locales/cn/journal.json +++ b/src/locales/cn/journal.json @@ -246,5 +246,17 @@ "INCOME": "收益", "EXPENSE": "支出", "GAIN_OR_LOSS": "收益或损失" + }, + "ASSET_SECTION": { + "TITLE": "资产", + "EMPTY_HINT": "请新增至少 1 笔资产!", + "ADD_BTN": "新增资产" + }, + "REVERSE_SECTION": { + "TITLE": "冲销", + "REVERSE_VOUCHER": "冲销传票", + "REVERSE_VOUCHER_PLACEHOLDER": "请选择...", + "REVERSE_AMOUNT": "冲销金额", + "ADD_BTN": "新增更多冲销传票" } } diff --git a/src/locales/en/journal.json b/src/locales/en/journal.json index e1eaff797..5166f8baf 100644 --- a/src/locales/en/journal.json +++ b/src/locales/en/journal.json @@ -246,5 +246,17 @@ "INCOME": "Income", "EXPENSE": "Expenses", "GAIN_OR_LOSS": "Gain or Loss" + }, + "ASSET_SECTION": { + "TITLE": "Asset", + "EMPTY_HINT": "Please add at least 1 asset!", + "ADD_BTN": "Add New Asset" + }, + "REVERSE_SECTION": { + "TITLE": "Reverse", + "REVERSE_VOUCHER": "Reverse Voucher", + "REVERSE_VOUCHER_PLACEHOLDER": "Please select...", + "REVERSE_AMOUNT": "Reverse Amount", + "ADD_BTN": "Add more reverse voucher" } } diff --git a/src/locales/tw/journal.json b/src/locales/tw/journal.json index 4fe1abfb6..156703e06 100644 --- a/src/locales/tw/journal.json +++ b/src/locales/tw/journal.json @@ -246,5 +246,17 @@ "INCOME": "收益", "EXPENSE": "支出", "GAIN_OR_LOSS": "收益或損失" + }, + "ASSET_SECTION": { + "TITLE": "資產", + "EMPTY_HINT": "請新增至少 1 筆資產!", + "ADD_BTN": "新增資產" + }, + "REVERSE_SECTION": { + "TITLE": "沖銷", + "REVERSE_VOUCHER": "沖銷傳票", + "REVERSE_VOUCHER_PLACEHOLDER": "請選擇...", + "REVERSE_AMOUNT": "沖銷金額", + "ADD_BTN": "新增更多沖銷傳票" } } diff --git a/src/pages/users/accounting/add_new_voucher.tsx b/src/pages/users/accounting/add_new_voucher.tsx index 36dcb6a8e..f0a85c5ab 100644 --- a/src/pages/users/accounting/add_new_voucher.tsx +++ b/src/pages/users/accounting/add_new_voucher.tsx @@ -5,10 +5,37 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { ILocale } from '@/interfaces/locale'; import NewVoucherForm from '@/components/voucher/new_voucher_form'; +// Info: (20241009 - Julian) For layout testing, to be removed +enum SidebarState { + COLLAPSED = 'collapsed', + OPEN = 'open', + EXPANDED = 'expanded', +} + const AddNewVoucherPage: React.FC = () => { const { t } = useTranslation('common'); - const [isSidebarOpen, setIsSidebarOpen] = useState(true); + const [sidebarState, setSidebarState] = useState(SidebarState.OPEN); + + const isSidebarCollapsed = sidebarState === SidebarState.COLLAPSED; + const isSidebarOpen = sidebarState === SidebarState.OPEN; + const isSidebarExpanded = sidebarState === SidebarState.EXPANDED; + + const toggleSidebar = () => { + if (isSidebarCollapsed) { + setSidebarState(SidebarState.OPEN); + } else { + setSidebarState(SidebarState.COLLAPSED); + } + }; + + const expandSidebar = () => { + if (isSidebarOpen) { + setSidebarState(SidebarState.EXPANDED); + } else { + setSidebarState(SidebarState.OPEN); + } + }; return ( <> @@ -19,28 +46,34 @@ const AddNewVoucherPage: React.FC = () => { {t('journal:ADD_NEW_VOUCHER.PAGE_TITLE')} - iSunFA - -
- This is header +
+
+ This is sidebar + +
+
+ Expand Area +
- This is sidebar + This is header
{/* Info: (20240925 - Julian) Body */}