diff --git a/libs/features/src/lib/cart/cart.modal/cart.modal.item.view.tsx b/libs/features/src/lib/cart/cart.modal/cart.modal.item.view.tsx index f8fd3cd..637ae66 100644 --- a/libs/features/src/lib/cart/cart.modal/cart.modal.item.view.tsx +++ b/libs/features/src/lib/cart/cart.modal/cart.modal.item.view.tsx @@ -20,8 +20,13 @@ import { styles } from './cart.modal.module'; import useCartModalItemLogic from './use.cart.modal.item.logic'; const CartModalItem = ({ el }: any): ReactElement => { - const { onHandleRemoveFromCart, onHandleAddToCart, onHandleRemoveCartItem } = - useCartModalItemLogic(); + const { + updateIsPending, + deleteIsPending, + onHandleRemoveFromCart, + onHandleAddToCart, + onHandleRemoveCartItem, + } = useCartModalItemLogic(); const { newStyles } = useRenderStyles(styles); const { getThemeClass } = usePokemonThemeLogic(el?.types); @@ -56,12 +61,14 @@ const CartModalItem = ({ el }: any): ReactElement => { onHandleRemoveFromCart(el?.id)} /> {el?.quantity} onHandleAddToCart(el?.id)} /> @@ -70,6 +77,7 @@ const CartModalItem = ({ el }: any): ReactElement => { onHandleRemoveCartItem(el?.id)} /> diff --git a/libs/features/src/lib/cart/cart.modal/use.cart.modal.item.logic.ts b/libs/features/src/lib/cart/cart.modal/use.cart.modal.item.logic.ts index 0fadb1e..f508924 100644 --- a/libs/features/src/lib/cart/cart.modal/use.cart.modal.item.logic.ts +++ b/libs/features/src/lib/cart/cart.modal/use.cart.modal.item.logic.ts @@ -1,7 +1,11 @@ +import { useEffect } from 'react'; + import { useDeleteCartItem, useUpdateCart } from '@pokemon-pet-shop/services'; import { GenericNonReturnType } from '@pokemon-pet-shop/typing'; interface UseCartModalReturn { + updateIsPending: boolean; + deleteIsPending: boolean; onHandleRemoveFromCart: GenericNonReturnType; onHandleAddToCart: GenericNonReturnType; onHandleRemoveCartItem: GenericNonReturnType; @@ -31,7 +35,14 @@ const useCartModalItemLogic = (): UseCartModalReturn => { }); }; + useEffect(() => { + console.log('updateCartMutation.error', updateCartMutation.error); + console.log('deleteCartMutation.error', deleteCartMutation.error); + }, [updateCartMutation.error, deleteCartMutation.error]); + return { + updateIsPending: updateCartMutation.isPending, + deleteIsPending: deleteCartMutation.isPending, onHandleRemoveFromCart: handleRemoveFromCart, onHandleAddToCart: handleAddToCart, onHandleRemoveCartItem: handleRemoveCartItem, diff --git a/libs/features/src/lib/footer/footer.tsx b/libs/features/src/lib/footer/footer.tsx index cfbc412..37a3e67 100644 --- a/libs/features/src/lib/footer/footer.tsx +++ b/libs/features/src/lib/footer/footer.tsx @@ -1,4 +1,10 @@ -import { IconTypeEnum, UiElementLayout, UiIcon, UiTypography } from '@pokemon-pet-shop/ui'; +import { + IconColorEnum, + IconTypeEnum, + UiElementLayout, + UiIcon, + UiTypography, +} from '@pokemon-pet-shop/ui'; import { styles } from './footer.module'; @@ -10,10 +16,16 @@ const Footer = () => { return ( - + Github Project - | + | + Scan QR code for mobile app ); diff --git a/libs/features/src/lib/pokemon/pokemon.detail.modal/pokemon.detail.modal.view.tsx b/libs/features/src/lib/pokemon/pokemon.detail.modal/pokemon.detail.modal.view.tsx index bdef5fb..7ed9bbc 100644 --- a/libs/features/src/lib/pokemon/pokemon.detail.modal/pokemon.detail.modal.view.tsx +++ b/libs/features/src/lib/pokemon/pokemon.detail.modal/pokemon.detail.modal.view.tsx @@ -12,6 +12,7 @@ import { UiTagWrapper, UiTagItem, ButtonSizeEnum, + UiSkeleton, } from '@pokemon-pet-shop/ui'; import { globalStyles } from '@pokemon-pet-shop/ui/styles/global'; import { @@ -31,6 +32,9 @@ const PokemonDetailModal = (): ReactElement => { const { modalData, speciesData, + isPendingUpdateCart, + speciesIsLoading, + pricingIsLoading, onConvertKgToLbs, onConvertMetersToFtIn, onGetPricingFormat, @@ -53,7 +57,13 @@ const PokemonDetailModal = (): ReactElement => { className={classNamesUtil(newStyles.imageContainer, newStyles?.[`${getThemeClass}ImageBg`])} > - {onGetPricingFormat} + + {!pricingIsLoading && !speciesIsLoading ? ( + onGetPricingFormat + ) : ( + + )} + { className={newStyles.cardDescription} typographyType={TypographyTypeEnum.P} > - {removeHtmlCodeInDescription} + {!speciesIsLoading ? removeHtmlCodeInDescription : } @@ -144,8 +154,9 @@ const PokemonDetailModal = (): ReactElement => { diff --git a/libs/features/src/lib/pokemon/pokemon.detail.modal/use.pokemon.detail.modal.logic.ts b/libs/features/src/lib/pokemon/pokemon.detail.modal/use.pokemon.detail.modal.logic.ts index 3a4a9fc..78f5e5b 100644 --- a/libs/features/src/lib/pokemon/pokemon.detail.modal/use.pokemon.detail.modal.logic.ts +++ b/libs/features/src/lib/pokemon/pokemon.detail.modal/use.pokemon.detail.modal.logic.ts @@ -12,14 +12,13 @@ import { pricingFormatUtil } from '@pokemon-pet-shop/utils'; interface PokemonDetailModalReturn { modalData: PokemonListApi; + isPendingUpdateCart: boolean; speciesData: PokemonSpeciesApi | undefined; speciesIsError: boolean; speciesIsLoading: boolean; - speciesIsFetching: boolean; pricingData: PricingApi | undefined; pricingIsError: boolean; pricingIsLoading: boolean; - pricingIsFetching: boolean; onConvertKgToLbs: any; onConvertMetersToFtIn: any; onGetPricingFormat: any; @@ -130,16 +129,17 @@ const usePokemonDetailModalLogic = (): PokemonDetailModalReturn => { pricingData, ]); + console.log('updateCartMutation', updateCartMutation); + return { modalData, speciesData, + isPendingUpdateCart: updateCartMutation?.isPending, speciesIsError, - speciesIsLoading, - speciesIsFetching, + speciesIsLoading: speciesIsLoading || speciesIsFetching, pricingData, pricingIsError, - pricingIsLoading, - pricingIsFetching, + pricingIsLoading: pricingIsLoading || pricingIsFetching, onConvertKgToLbs: convertKgToLbs, onConvertMetersToFtIn: convertMetersToFtIn, onGetPricingFormat: getPricingFormat, diff --git a/libs/ui/src/index.ts b/libs/ui/src/index.ts index 9305d47..cd47aaf 100644 --- a/libs/ui/src/index.ts +++ b/libs/ui/src/index.ts @@ -15,3 +15,4 @@ export * from './lib-base/ui/card'; export * from './lib-base/ui/hide.in.mobile'; export * from './lib-base/ui/tag'; export * from './lib-base/ui/switch'; +export * from './lib-base/ui/skeleton'; diff --git a/libs/ui/src/lib-base/styles/css/global.module.css b/libs/ui/src/lib-base/styles/css/global.module.css index 8d04fe7..83eed79 100644 --- a/libs/ui/src/lib-base/styles/css/global.module.css +++ b/libs/ui/src/lib-base/styles/css/global.module.css @@ -1,7 +1,24 @@ .fontBold { - font-weight: bold; + font-weight: bold !important; } .pointerCursor { - cursor: pointer; + cursor: pointer !important; +} + +.disabledElement { + cursor: not-allowed !important; + + /* opacity: 0.5 !important; */ +} + +.disabledElementText { + cursor: not-allowed !important; + color: var(--theme-netural-600) !important; +} + +.disabledElementBg { + cursor: not-allowed !important; + color: var(--theme-netural-100) !important; + background-color: var(--theme-netural-600) !important; } diff --git a/libs/ui/src/lib-base/ui/button/button.module.css b/libs/ui/src/lib-base/ui/button/button.module.css index 5ff6ef6..de5620b 100644 --- a/libs/ui/src/lib-base/ui/button/button.module.css +++ b/libs/ui/src/lib-base/ui/button/button.module.css @@ -1,7 +1,6 @@ .button { border-radius: var(--theme-radius-pill); cursor: pointer; - background: none; border: 0; text-align: center; } diff --git a/libs/ui/src/lib-base/ui/button/button.view.tsx b/libs/ui/src/lib-base/ui/button/button.view.tsx index 08d9ce7..486f5e6 100644 --- a/libs/ui/src/lib-base/ui/button/button.view.tsx +++ b/libs/ui/src/lib-base/ui/button/button.view.tsx @@ -3,6 +3,8 @@ import { memo, ReactElement, useMemo } from 'react'; import { useRenderStyles } from '@pokemon-pet-shop/hooks'; import { classNamesUtil } from '@pokemon-pet-shop/utils'; +import { globalStyles } from '../../styles/css/global.module'; + import ButtonElement from './button.element.view'; import { ButtonSizeEnum, ButtonTypeEnum } from './button.enum'; import { ButtonProps } from './button.interface'; @@ -38,10 +40,20 @@ const Button = ({ } }, [size, newStyles]); + const getDisabledStyles = useMemo(() => { + return isDisabled ? globalStyles.disabledElementBg : ''; + }, [isDisabled]); + return ( diff --git a/libs/ui/src/lib-base/ui/icon/icon.enum.ts b/libs/ui/src/lib-base/ui/icon/icon.enum.ts index 3c63911..85c3d2c 100644 --- a/libs/ui/src/lib-base/ui/icon/icon.enum.ts +++ b/libs/ui/src/lib-base/ui/icon/icon.enum.ts @@ -1,4 +1,9 @@ -import { THEME_NETURAL_100, THEME_RED_600, THEME_BLUE_600 } from '../../styles/ts/variables'; +import { + THEME_NETURAL_100, + THEME_RED_600, + THEME_BLUE_600, + THEME_NETURAL_900, +} from '../../styles/ts/variables'; export enum IconTypeEnum { ICON_SHOPPING_CART = 'IconShoppingCart', @@ -18,4 +23,5 @@ export enum IconColorEnum { BLUE = THEME_BLUE_600, RED = THEME_RED_600, WHITE = THEME_NETURAL_100, + BLACK = THEME_NETURAL_900, } diff --git a/libs/ui/src/lib-base/ui/icon/icon.module.css b/libs/ui/src/lib-base/ui/icon/icon.module.css deleted file mode 100644 index 77f6427..0000000 --- a/libs/ui/src/lib-base/ui/icon/icon.module.css +++ /dev/null @@ -1,7 +0,0 @@ -.icon { - cursor: pointer; -} - -.iconWrapper { - cursor: pointer; -} diff --git a/libs/ui/src/lib-base/ui/icon/icon.view.tsx b/libs/ui/src/lib-base/ui/icon/icon.view.tsx index b35ab95..617ac28 100644 --- a/libs/ui/src/lib-base/ui/icon/icon.view.tsx +++ b/libs/ui/src/lib-base/ui/icon/icon.view.tsx @@ -2,11 +2,12 @@ import { memo, ReactElement, useCallback, useMemo } from 'react'; import { classNamesUtil } from '@pokemon-pet-shop/utils'; +import { globalStyles } from '../../styles/css/global.module'; +import { THEME_NETURAL_600 } from '../../styles/ts/variables'; import { UiElementLayout } from '../element.layout'; import { IconColorEnum, IconTypeEnum } from './icon.enum'; import { IconProps } from './icon.interface'; -import styles from './icon.module.css'; import { IconMap } from './icon.util'; const Icon = ({ @@ -36,20 +37,23 @@ const Icon = ({ }, [onClick, isDisabled]); const renderIcon = useMemo(() => { + const disabledStyles = isDisabled ? globalStyles.disabledElement : ''; + const clickableStyles = onClick ? globalStyles.pointerCursor : ''; + return ( ); - }, [size, IconComponent, classNameIcon, iconClick, onClick]); + }, [size, IconComponent, color, classNameIcon, iconClick, isDisabled, onClick]); if (displayWrapper) { return ( {renderIcon} diff --git a/libs/ui/src/lib-base/ui/skeleton/skeleton.view.tsx b/libs/ui/src/lib-base/ui/skeleton/skeleton.view.tsx index 0f429a3..3ce9d20 100644 --- a/libs/ui/src/lib-base/ui/skeleton/skeleton.view.tsx +++ b/libs/ui/src/lib-base/ui/skeleton/skeleton.view.tsx @@ -2,8 +2,7 @@ import { ReactElement } from 'react'; import Skeleton from 'react-loading-skeleton'; -import { THEME_RADIUS_8, THEME_RADIUS_CIRCLE } from '../../styles/ts/variables'; -import { UiElementLayout } from '../element.layout'; +import { THEME_RADIUS_8 } from '../../styles/ts/variables'; import { SkeletonProps } from './skeleton.interface'; @@ -31,6 +30,7 @@ const SkeletonView = ({ return (