Skip to content

Commit a4c522a

Browse files
committed
feat: 에러처리 추가
1 parent b74d69b commit a4c522a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/pages/deposit-search/deposit-search-page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ const DepositSearchPage = () => {
4444
const [depositList, setDepositList] = useState<ProductList[]>([]);
4545
const [loading, setIsLoading] = useState(true);
4646
const [selectedBanks, setSelectedBanks] = useState<string[]>([]);
47-
const [saveTerm, setSaveTerm] = useState<number>(DEFAULT_TERM);
47+
const [saveTerm, setSaveTerm] = useState<number>(DEFAULT_TERM);
48+
const [IsError, setIsError] = useState(false);
4849

4950
const fetchDepositList = async (banks: string[] | null, term: number) => {
5051
setIsLoading(true);
@@ -54,6 +55,10 @@ const DepositSearchPage = () => {
5455
(a, b) => b.maxRate - a.maxRate,
5556
);
5657
setDepositList(data);
58+
setIsError(false);
59+
} catch (error) {
60+
setDepositList([]);
61+
setIsError(true);
5762
} finally {
5863
setIsLoading(false);
5964
}
@@ -141,7 +146,7 @@ const DepositSearchPage = () => {
141146
>검색</button>
142147
</div>
143148
{/*상품 리스트*/}
144-
{!loading && (
149+
{!loading && !IsError && (
145150
<div className={styles.depositListContainer}>
146151
{depositList.length > 0 ? (
147152
depositList.map(item => (

src/pages/savings-search/savings-search-page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const SavingSearchPage = () => {
4646
const [loading, setIsLoading] = useState(true);
4747
const [selectedBanks, setSelectedBanks] = useState<string[]>([]);
4848
const [saveTerm, setSaveTerm] = useState<number>(DEFAULT_TERM);
49+
const [IsError, setIsError] = useState(false);
4950

5051
const fetchSavingList = async (banks: string[] | null, term: number) => {
5152
setIsLoading(true);
@@ -55,8 +56,10 @@ const SavingSearchPage = () => {
5556
(a, b) => b.maxRate - a.maxRate,
5657
);
5758
setSavingList(data);
59+
setIsError(false);
5860
} finally {
5961
setIsLoading(false);
62+
setIsError(true);
6063
}
6164
};
6265

@@ -142,7 +145,7 @@ const SavingSearchPage = () => {
142145
>검색</button>
143146
</div>
144147
{/*상품 리스트*/}
145-
{!loading && (
148+
{!loading && !IsError && (
146149
<div className={styles.savingListContainer}>
147150
{savingList.length > 0 ? (
148151
savingList.map(item => (

0 commit comments

Comments
 (0)