components APIs
- Header
- Button
- Layout
- Footer
- Text
- Box
- Card
- Table
- Loading
- Select
- Loader
- Toolbar
- Icon
- CodeInput
- BottomSheet
- InfoBlock
- LanguageToggle
- ProgressCircles
- Ripple
- Toggle
- Tag
- Input
- Paginator
- Filter
- AsyncSelect
- CatalogBigButton
- ReadMore
- ConditionalWrapper
- LastCheckedDisplay
- PriceLabel
- PageTitle
- CartTable
- CartFinalPriceTable
- LoadingSpin
- InfoModal
- ProductCard
- RecommendCoupon
- PriceVales
- NomalLayout
- Web3ReactManager
- Popups
- CurrencyInput
- TransactionErrorContent
- TransactionConfirmationModal
- ConfirmationModalContent
- DoubleCurrencyLogo
- CustomModal
- CurrencySearchModal
- CurrencyLogo
- NumericalInput
- Logo
- QuestionHelper
- ListLogo
- DataTable
- WalletModal
- CustomTable
- MinimalPositionCard
- RemoveLiquidityModal
- CustomTooltip
- ColoredSlider
- ToggleSwitch
- FormattedPriceImpact
- SettingsModal
- ConfirmSwapModal
- AdvancedSwapDetails
- AddressInput
- LineChart
- StakeSyrupModal
- AccountDetails
- BetaWarningBanner
- AreaChart
- ChartType
- TokensTable
- PairTable
- TopMovers
- BarChart
- TransactionsTable
- StakeQuickModal
- UnstakeQuickModal
- SyrupCard
- CustomMenu
- SearchInput
- CustomSwitch
- FarmCard
- BuyFiatModal
- MoonpayModal
- RewardSlider
- Swap
- AddLiquidity
- PoolFinderModal
- PoolPositionCard
- SwapTokenDetails
- SuperHeader
- GlobalStyles
- PrimaryButton
- SectionTitle
- Section
- AccentSection
- ChainSelection
- CoinSelection
- AddressSelection
- SendAction
- Buttons
- Content
- Particles
- IconButton
- NotSupported
- InputSearch
- RouteGuard
- SearchBar
- FileInput
- GovBanner
- AuthForm
- DomainDetails
- Subnav
- ColumnFilter
- ImportExport
- selectFilter
- TaggedArrayInput
- FacetFilter
- ButtonSingleLine
- TextMultiline
- ButtonSelect
- BottomSheetBehavior
- InfoButton
- BulletPointX
- BulletPointCheck
- Title
- LoadingIcon
- SelectFilterControls
- CORInputForm
- SdnInputForm
- Navbar
- HomeRoute
- AuthRoute
- DocumentDetails
- DocumentStepper
- AddGame
- Auth
- Effectiveness
- Export
- PokemonType
- Moves
- Member
- MoveSelector
- Type
- Natures
- Move
- PokeInfo
- Share
- Badges
- Status
- UpdateSW
- About
- Builder
- Calculator
- Changelog
- Import
- Pokestats
- Report
- Rules
- Settings
- Tracker
- DarkThemeProvider
- NotificationHandler
- Background
- Indicator
- StyledButton
- StyledText
- Illustration
- OnboardingSlider
- FlexList
- AppLayout
- ScrollableList
- Visualization
- DataSearch
- Region
- App
- CompareApiLegend
- CompareApiBreadcrumbs
- CompareApiLink
- CompareApiCard
- ExploreApiBreadcrumbs
- ExploreApiLink
- ExploreApiSearch
- ExploreApiConst
- ApiLoader
- RefreshButton
- Listing
- PriceModal
- ConfirmationModal
- Transition
- AutoComplete
- useInput
- Avatar
- Badge
- Breadcrumbs
- ButtonDropdown
- ButtonGroup
- Capacity
- Checkbox
- Code
- Collapse
- CssBaseline
- GeistProvider
- Description
- Display
- Divider
- Dot
- Drawer
- useModal
- Fieldset
- Grid
- Image
- Keyboard
- Link
- Modal
- Note
- Page
- Pagination
- Popover
- Progress
- Radio
- Rating
- Slider
- Snippet
- Spacer
- Spinner
- Tabs
- Textarea
- Tooltip
- Tree
- useBodyScroll
- useClasses
- useClickAway
- useClipboard
- useCurrentState
- useKeyboard
- KeyMod
- KeyCode
- useMediaQuery
- useTabs
- useToasts
- User
- useTheme
- Themes
- GeistUIThemes
- useAllThemes
- CollapsableDialog
- Map
- IPForm
- IPMenu
- Container
- Parallax
- Nav
- SEO
- BlogNav
- ExtensionCard
- MenuComp
Other Related APIs
- react#useState
- react#useEffect
- react#useCallback
- react-router-dom#NavLink
- react-redux#useDispatch
- react-redux#useSelector
- antd#Button
- antd#Modal
- antd#Row
- antd#Col
- antd#Alert
- antd#Divider
- antd#Pagination
- antd#Empty
- components#CartTable
- components#CartFinalPriceTable
- components#LoadingSpin
- components#InfoModal
- components#ProductCard
components#PageTitle TypeScript Examples
The following examples show how to use
components#PageTitle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Cart.tsx From Shopping-Cart with MIT License | 4 votes |
Cart = () => {
const dispatch = useDispatch();
const { isLoading, items } = useSelector(cartedProductSelector);
const { tableDataSource, recommend } = useSelector(
paymentCartedProductSelector,
);
useEffect(() => {
if (storageService.getItem('cart-class101')) {
dispatch(
fetchCartedProductListAsync.request({
productIdList: JSON.parse(
storageService.getItem('cart-class101') as string,
),
}),
);
dispatch(fetchPaymentCartedProductListAsync.request({ id: [] }));
}
}, [storageService.getItem]);
const handleCartTableClick = useCallback(() => {
storageService.removeItem('cart-class101');
dispatch(fetchCartedProductListAsync.request({}));
}, [storageService.removeItem]);
const handleCartTableChange = useCallback(
(id: ProductModel['id'], quantity: number) => {
dispatch(fetchCartedProductListEditAsync.request({ id, quantity }));
},
[dispatch],
);
const handleSelectChange = useCallback(
(selectedRowKeys: any, selectedRows: any) => {
// antd에서 타입을 any로 해놔서 일단, any로 받음. 나머지 로직에서 타입 체크를 차라리 제대로 하자.
dispatch(
fetchPaymentCartedProductListAsync.request({
id: selectedRowKeys as ProductModel['id'][], // 다른 곳에서라도 타입을 정확하게 판단하기 위해 강제 어썰션
ProductModelList: selectedRows as ProductModel[],
}),
);
},
[dispatch],
);
const handlePaymentClick = useCallback(() => {
InfoModal('error', '경고', '결제는 안되요~');
}, [InfoModal]);
if (isLoading && !items) {
return <LoadingSpin />;
}
return (
<>
<Row>
<Col span={24}>
<PageTitle title="장바구니" />
</Col>
</Row>
<Row style={{ marginBottom: 50 }}>
<CartTable
dataSource={items}
onClick={handleCartTableClick}
onChange={handleCartTableChange}
onSelectChange={handleSelectChange}
/>
</Row>
<Row>
<Divider orientation="left">최종 결제 금액</Divider>
<CartFinalPriceTable
dataSource={tableDataSource}
recommend={recommend}
/>
<Divider />
</Row>
<Row style={{ textAlign: 'right' }}>
<NavLink to={PRODUCTS_LIST_PATH}>
<Button size="large" style={{ marginRight: 8 }}>
뒤로 가기
</Button>
</NavLink>
<Button
type="danger"
size="large"
style={{ marginRight: 6 }}
disabled={!tableDataSource.totalPrice}
onClick={handlePaymentClick}
>
결제하기
</Button>
</Row>
</>
);
}
Example #2
Source File: ProductsList.tsx From Shopping-Cart with MIT License | 4 votes |
ProductsList = () => {
const dispatch = useDispatch();
const [currentPage, setCurrentPage] = useState<number>(1);
const [cartItems, setCartItems] = useState<ProductModel['id'][]>([]);
const { isLoading, items, totalProducts } = useSelector(
(state: RootState) => state.productReducer,
);
const itemList = items && Object.entries(items).map(item => item[1]);
useEffect(() => {
dispatch(fetchProductListAsync.request({ currentPage }));
}, [dispatch, currentPage]);
useEffect(() => {
if (storageService.getItem('cart-class101')) {
setCartItems(
JSON.parse(storageService.getItem('cart-class101') as string),
);
}
}, [setCartItems, storageService.setItem]);
// 제품 카트 클릭 이벤트 핸들러
const handleProductCardClick = useCallback(
(id: ProductModel['id']) => {
if (cartItems.includes(id)) {
storageService.setItem(
'cart-class101',
JSON.stringify([...cartItems.filter(value => value !== id)]),
);
setCartItems([...cartItems.filter(value => value !== id)]);
} else if (cartItems.length >= 3) {
InfoModal('warning', '주의', '장바구니에는 3개 이상 담을 수 없습니다.');
} else {
cartItems.push(id);
storageService.setItem('cart-class101', JSON.stringify([...cartItems]));
}
},
[cartItems, setCartItems, storageService.setItem, storageService.getItem],
);
// 페이지네이션 onChange
const handlePaginationOnChange = useCallback(
(page: number, pageNumber?: number) => {
setCurrentPage(page);
},
[setCurrentPage],
);
if (isLoading) return <LoadingSpin />;
return (
<>
<Row>
<Col span={24}>
<PageTitle title="상품 목록" />
</Col>
</Row>
<Row>
{itemList ? (
itemList.map(product => (
<Col xs={24} sm={12} lg={6} key={product.id}>
{' '}
<ProductCard
onClick={handleProductCardClick}
product={product}
/>{' '}
</Col>
))
) : (
<Empty />
)}
</Row>
<Row style={{ marginTop: '15px' }}>
<Col span={24} style={{ textAlign: 'right' }}>
<Pagination
defaultCurrent={1}
defaultPageSize={4}
total={totalProducts}
onChange={handlePaginationOnChange}
/>
</Col>
</Row>
</>
);
}