-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #554 from soma0078/React-이송아-sprint8
[이송아] sprint8
- Loading branch information
Showing
59 changed files
with
1,478 additions
and
572 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { BrowserRouter, Route, Routes } from 'react-router-dom'; | ||
import HomePage from './pages/HomePage/HomePage'; | ||
import LoginPage from './pages/LoginPage/LoginPage'; | ||
import MarketPage from './pages/MarketPage/MarketPage'; | ||
import AddItemPage from './pages/AddItemPage/AddItemPage'; | ||
import CommunityFeedPage from './pages/CommunityFeedPage/CommunityFeedPage'; | ||
import Header from './components/Layout/Header'; | ||
import ItemPage from './pages/ItemPage/ItemPage'; | ||
|
||
function App() { | ||
return ( | ||
<BrowserRouter> | ||
{/* Global Navigation Bar */} | ||
<Header /> | ||
|
||
<div className="withHeader"> | ||
<Routes> | ||
<Route index element={<HomePage />} /> | ||
<Route path="login" element={<LoginPage />} /> | ||
<Route path="items" element={<MarketPage />} /> | ||
<Route path="items/:productId" element={<ItemPage />} /> | ||
<Route path="additem" element={<AddItemPage />} /> | ||
<Route path="community" element={<CommunityFeedPage />} /> | ||
</Routes> | ||
</div> | ||
</BrowserRouter> | ||
); | ||
} | ||
|
||
export default App; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
interface Entity { | ||
id: string; | ||
name: string; | ||
} | ||
|
||
interface Product extends Entity { | ||
price: number; | ||
} | ||
|
||
interface ProductDetail extends Entity { | ||
description: string; | ||
} | ||
|
||
interface Comment extends Entity { | ||
productId: string; | ||
content: string; | ||
} | ||
|
||
interface ProductResponse { | ||
list: Product[]; | ||
totalCount: number; | ||
} | ||
|
||
export async function getProducts(params: { | ||
orderBy: string; | ||
page: number; | ||
pageSize: number; | ||
}): Promise<ProductResponse> { | ||
const query = new URLSearchParams({ | ||
orderBy: params.orderBy, | ||
page: params.page.toString(), | ||
pageSize: params.pageSize.toString(), | ||
}).toString(); | ||
|
||
try { | ||
const response = await fetch(`https://panda-market-api.vercel.app/products?${query}`); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch products:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function getProductDetail(productId: string): Promise<ProductDetail> { | ||
if (!productId) { | ||
throw new Error('Invalid product ID'); | ||
} | ||
|
||
try { | ||
const response = await fetch(`https://panda-market-api.vercel.app/products/${productId}`); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch product detail:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function getProductComments(params: { | ||
productId: string; | ||
params?: Record<string, any>; | ||
}): Promise<Comment[]> { | ||
const { productId, params: queryParams } = params; | ||
|
||
if (!productId) { | ||
throw new Error('Invalid product ID'); | ||
} | ||
|
||
try { | ||
const query = new URLSearchParams(queryParams).toString(); | ||
const response = await fetch(`https://panda-market-api.vercel.app/products/${productId}/comments?${query}`); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch product comments:', error); | ||
throw error; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.