@@ -3,27 +3,18 @@ import { useAtomValue, useSetAtom } from 'jotai';
33
44import { CartData } from '@pokemon-pet-shop/types' ;
55import { Box , Typography } from '@pokemon-pet-shop/ui-primitives' ;
6- import { Modal , ModalScroll } from '@pokemon-pet-shop/ui-components' ;
6+ import { Modal , ModalScroll , SuspenseBoundary , Skeleton } from '@pokemon-pet-shop/ui-components' ;
77import { useGetCart } from '@pokemon-pet-shop/service-cart' ;
88import { pricingFormatUSD } from '@pokemon-pet-shop/util-pricing' ;
99
1010import CartModalItem from './cart-modal-item' ;
1111import { closeSideCartModalAtom , isSideCartModalOpenAtom } from './cart-modal-atom.state' ;
1212
13- export const CartModal = ( ) : ReactElement => {
13+ const CartModalContent = ( ) : ReactElement => {
1414 const { data } = useGetCart ( ) ;
1515
16- const isOpen = useAtomValue ( isSideCartModalOpenAtom ) ;
17- const closeModal = useSetAtom ( closeSideCartModalAtom ) ;
18-
1916 return (
20- < Modal
21- title = "Pokecart"
22- headlineType = "relative"
23- modalAlignment = "right"
24- isOpen = { isOpen }
25- onClick = { closeModal }
26- >
17+ < >
2718 < ModalScroll >
2819 < Box className = "pb-[150px]" >
2920 { ( data ?. data ?? [ ] ) . map ( ( el : CartData , i : number ) => {
@@ -45,6 +36,33 @@ export const CartModal = (): ReactElement => {
4536 { pricingFormatUSD ( Number ( data ?. total ) ) }
4637 </ Typography >
4738 </ Box >
39+ </ >
40+ ) ;
41+ } ;
42+
43+ const CartModalSkeleton = ( ) : ReactElement => {
44+ return (
45+ < Box className = "p-lg" >
46+ < Skeleton count = { 3 } height = { 60 } />
47+ </ Box >
48+ ) ;
49+ } ;
50+
51+ export const CartModal = ( ) : ReactElement => {
52+ const isOpen = useAtomValue ( isSideCartModalOpenAtom ) ;
53+ const closeModal = useSetAtom ( closeSideCartModalAtom ) ;
54+
55+ return (
56+ < Modal
57+ title = "Pokecart"
58+ headlineType = "relative"
59+ modalAlignment = "right"
60+ isOpen = { isOpen }
61+ onClick = { closeModal }
62+ >
63+ < SuspenseBoundary fallback = { < CartModalSkeleton /> } >
64+ < CartModalContent />
65+ </ SuspenseBoundary >
4866 </ Modal >
4967 ) ;
5068} ;
0 commit comments