@4alldigital/foundation-ui--core 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -0
- package/package.json +35 -0
- package/src/__mocks__/_examples/cnbc.ts +146 -0
- package/src/__mocks__/_examples/nrg.ts +222 -0
- package/src/__mocks__/empty-module.js +0 -0
- package/src/__mocks__/fileMock.js +3 -0
- package/src/__mocks__/fileTransformer.js +8 -0
- package/src/__mocks__/mockSearchData.js +511 -0
- package/src/__mocks__/nrglogo.svg +74 -0
- package/src/__mocks__/styleMock.js +3 -0
- package/src/__mocks__/tempPolyFills.js +5 -0
- package/src/components/Accordion/Accordion.stories.tsx +33 -0
- package/src/components/Accordion/Accordion.tsx +53 -0
- package/src/components/Accordion/Accordion.types.ts +8 -0
- package/src/components/Accordion/index.ts +1 -0
- package/src/components/AnimationCounter/AnimationCounter.stories.tsx +22 -0
- package/src/components/AnimationCounter/AnimationCounter.tsx +51 -0
- package/src/components/AnimationCounter/AnimationCounter.types.ts +10 -0
- package/src/components/AnimationCounter/index.ts +1 -0
- package/src/components/AnimationSet1/AnimationSet1.stories.tsx +36 -0
- package/src/components/AnimationSet1/AnimationSet1.tsx +107 -0
- package/src/components/AnimationSet1/AnimationSet1.types.ts +12 -0
- package/src/components/AnimationSet1/index.ts +1 -0
- package/src/components/Authenticator/Authenticator.stories.tsx +37 -0
- package/src/components/Authenticator/Authenticator.tsx +84 -0
- package/src/components/Authenticator/Authenticator.types.ts +7 -0
- package/src/components/Authenticator/index.ts +1 -0
- package/src/components/Avatar/Avatar.stories.tsx +26 -0
- package/src/components/Avatar/Avatar.tsx +88 -0
- package/src/components/Avatar/Avatar.types.ts +8 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Banner/Banner.stories.tsx +59 -0
- package/src/components/Banner/Banner.tsx +60 -0
- package/src/components/Banner/Banner.types.ts +9 -0
- package/src/components/Banner/index.ts +1 -0
- package/src/components/Blockquote/Blockquote.stories.tsx +20 -0
- package/src/components/Blockquote/Blockquote.tsx +32 -0
- package/src/components/Blockquote/Blockquote.types.ts +8 -0
- package/src/components/Blockquote/index.ts +1 -0
- package/src/components/Button/Button.stories.tsx +50 -0
- package/src/components/Button/Button.tsx +117 -0
- package/src/components/Button/Button.types.ts +43 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +59 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +35 -0
- package/src/components/ButtonGroup/ButtonGroup.types.ts +5 -0
- package/src/components/ButtonGroup/index.ts +1 -0
- package/src/components/Calendar/Calendar.stories.tsx +100 -0
- package/src/components/Calendar/Calendar.tsx +91 -0
- package/src/components/Calendar/Calendar.types.ts +10 -0
- package/src/components/Calendar/index.ts +2 -0
- package/src/components/Card/Card.stories.tsx +487 -0
- package/src/components/Card/Card.tsx +32 -0
- package/src/components/Card/Card.types.ts +79 -0
- package/src/components/Card/constants/index.ts +8 -0
- package/src/components/Card/index.ts +1 -0
- package/src/components/Card/types/CardBasic/CardBasic.tsx +262 -0
- package/src/components/Card/types/CardBasic/CardBasic.types.ts +7 -0
- package/src/components/Card/types/CardBasic/index.ts +1 -0
- package/src/components/Card/types/CardData/CardData.tsx +68 -0
- package/src/components/Card/types/CardData/CardData.types.ts +21 -0
- package/src/components/Card/types/CardData/index.ts +1 -0
- package/src/components/Card/types/CardHorz/CardHorz.tsx +80 -0
- package/src/components/Card/types/CardHorz/CardHorz.types.ts +8 -0
- package/src/components/Card/types/CardHorz/index.ts +1 -0
- package/src/components/Card/types/CardIcon/CardIcon.tsx +76 -0
- package/src/components/Card/types/CardIcon/CardIcon.types.ts +8 -0
- package/src/components/Card/types/CardIcon/index.ts +1 -0
- package/src/components/Card/types/CardMedia/CardMedia.tsx +277 -0
- package/src/components/Card/types/CardMedia/CardMedia.types.ts +5 -0
- package/src/components/Card/types/CardMedia/index.ts +1 -0
- package/src/components/Card/types/CardVideo/CardVideo.tsx +262 -0
- package/src/components/Card/types/CardVideo/CardVideo.types.ts +11 -0
- package/src/components/Card/types/CardVideo/index.ts +1 -0
- package/src/components/CardGrid/CardGrid.stories.tsx +122 -0
- package/src/components/CardGrid/CardGrid.tsx +25 -0
- package/src/components/CardGrid/CardGrid.types.ts +7 -0
- package/src/components/CardGrid/index.ts +1 -0
- package/src/components/Carousel/Carousel.stories.tsx +351 -0
- package/src/components/Carousel/Carousel.tsx +174 -0
- package/src/components/Carousel/Carousel.types.ts +32 -0
- package/src/components/Carousel/MIGRATION.md +156 -0
- package/src/components/Carousel/index.ts +1 -0
- package/src/components/Cart/Cart.stories.tsx +92 -0
- package/src/components/Cart/Cart.tsx +194 -0
- package/src/components/Cart/Cart.types.ts +4 -0
- package/src/components/Cart/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +18 -0
- package/src/components/Checkbox/Checkbox.tsx +38 -0
- package/src/components/Checkbox/Checkbox.types.ts +15 -0
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/Chip/Chip.stories.tsx +37 -0
- package/src/components/Chip/Chip.tsx +104 -0
- package/src/components/Chip/Chip.types.ts +13 -0
- package/src/components/Chip/index.ts +1 -0
- package/src/components/Collapsible/Collapsible.stories.tsx +139 -0
- package/src/components/Collapsible/Collapsible.tsx +75 -0
- package/src/components/Collapsible/Collapsible.types.ts +14 -0
- package/src/components/Collapsible/index.ts +3 -0
- package/src/components/Container/Container.stories.tsx +17 -0
- package/src/components/Container/Container.tsx +51 -0
- package/src/components/Container/Container.types.ts +17 -0
- package/src/components/Container/index.ts +1 -0
- package/src/components/ContentPageLayout/ContentPageLayout.stories.tsx +17 -0
- package/src/components/ContentPageLayout/ContentPageLayout.tsx +38 -0
- package/src/components/ContentPageLayout/ContentPageLayout.types.ts +17 -0
- package/src/components/ContentPageLayout/index.ts +1 -0
- package/src/components/ContentRowsLayout/ContentRowsLayout.stories.tsx +19 -0
- package/src/components/ContentRowsLayout/ContentRowsLayout.tsx +30 -0
- package/src/components/ContentRowsLayout/ContentRowsLayout.types.ts +15 -0
- package/src/components/ContentRowsLayout/index.ts +1 -0
- package/src/components/Copy/Copy.stories.tsx +28 -0
- package/src/components/Copy/Copy.tsx +43 -0
- package/src/components/Copy/Copy.types.tsx +53 -0
- package/src/components/Copy/index.tsx +1 -0
- package/src/components/DisplayHeading/DisplayHeading.stories.tsx +17 -0
- package/src/components/DisplayHeading/DisplayHeading.tsx +43 -0
- package/src/components/DisplayHeading/DisplayHeading.types.ts +8 -0
- package/src/components/DisplayHeading/index.ts +1 -0
- package/src/components/FileUpload/FileUpload.stories.tsx +18 -0
- package/src/components/FileUpload/FileUpload.tsx +41 -0
- package/src/components/FileUpload/FileUpload.types.ts +9 -0
- package/src/components/FileUpload/index.ts +1 -0
- package/src/components/Footer/Footer.stories.tsx +17 -0
- package/src/components/Footer/Footer.tsx +78 -0
- package/src/components/Footer/Footer.types.ts +4 -0
- package/src/components/Footer/index.ts +1 -0
- package/src/components/Form/Form.stories.tsx +81 -0
- package/src/components/Form/Form.tsx +98 -0
- package/src/components/Form/Form.types.ts +34 -0
- package/src/components/Form/index.ts +1 -0
- package/src/components/FormField/FormField.stories.tsx +205 -0
- package/src/components/FormField/FormField.tsx +258 -0
- package/src/components/FormField/FormField.types.ts +89 -0
- package/src/components/FormField/index.ts +1 -0
- package/src/components/FormSelect/FormSelect.stories.tsx +27 -0
- package/src/components/FormSelect/FormSelect.tsx +46 -0
- package/src/components/FormSelect/FormSelect.types.ts +45 -0
- package/src/components/FormSelect/index.ts +1 -0
- package/src/components/FullContentBackgroundImage/FullContentBackgroundImage.stories.tsx +18 -0
- package/src/components/FullContentBackgroundImage/FullContentBackgroundImage.tsx +26 -0
- package/src/components/FullContentBackgroundImage/FullContentBackgroundImage.types.ts +6 -0
- package/src/components/FullContentBackgroundImage/index.ts +1 -0
- package/src/components/FullScreenVideoModal/FullScreenVideoModal.stories.tsx +34 -0
- package/src/components/FullScreenVideoModal/FullScreenVideoModal.tsx +41 -0
- package/src/components/FullScreenVideoModal/FullScreenVideoModal.types.ts +9 -0
- package/src/components/FullScreenVideoModal/index.ts +1 -0
- package/src/components/Header/Header.stories.tsx +51 -0
- package/src/components/Header/Header.tsx +170 -0
- package/src/components/Header/Header.types.ts +11 -0
- package/src/components/Header/index.ts +1 -0
- package/src/components/Heading/Heading.stories.tsx +57 -0
- package/src/components/Heading/Heading.tsx +47 -0
- package/src/components/Heading/Heading.types.ts +35 -0
- package/src/components/Heading/index.ts +1 -0
- package/src/components/Hero/Hero.stories.tsx +17 -0
- package/src/components/Hero/Hero.tsx +28 -0
- package/src/components/Hero/Hero.types.ts +17 -0
- package/src/components/Hero/index.ts +1 -0
- package/src/components/Hr/Hr.stories.tsx +13 -0
- package/src/components/Hr/Hr.tsx +16 -0
- package/src/components/Hr/Hr.types.ts +3 -0
- package/src/components/Hr/index.ts +1 -0
- package/src/components/HtmlContent/HtmlContent.stories.tsx +29 -0
- package/src/components/HtmlContent/HtmlContent.tsx +36 -0
- package/src/components/HtmlContent/HtmlContent.types.ts +6 -0
- package/src/components/HtmlContent/index.ts +1 -0
- package/src/components/Icon/Icon.stories.tsx +26 -0
- package/src/components/Icon/Icon.tsx +24 -0
- package/src/components/Icon/Icon.types.ts +8 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Image/Image.stories.tsx +32 -0
- package/src/components/Image/Image.tsx +71 -0
- package/src/components/Image/Image.types.ts +20 -0
- package/src/components/Image/index.ts +1 -0
- package/src/components/Label/Label.stories.tsx +18 -0
- package/src/components/Label/Label.tsx +17 -0
- package/src/components/Label/Label.types.ts +9 -0
- package/src/components/Label/index.ts +1 -0
- package/src/components/Link/Link.stories.tsx +25 -0
- package/src/components/Link/Link.tsx +85 -0
- package/src/components/Link/Link.types.ts +14 -0
- package/src/components/Link/index.ts +1 -0
- package/src/components/List/List.stories.tsx +38 -0
- package/src/components/List/List.tsx +17 -0
- package/src/components/List/List.types.ts +27 -0
- package/src/components/List/index.ts +1 -0
- package/src/components/ListItem/ListItem.stories.tsx +61 -0
- package/src/components/ListItem/ListItem.tsx +53 -0
- package/src/components/ListItem/ListItem.types.ts +10 -0
- package/src/components/ListItem/index.ts +1 -0
- package/src/components/Loader/Loader.stories.tsx +17 -0
- package/src/components/Loader/Loader.tsx +34 -0
- package/src/components/Loader/Loader.types.ts +5 -0
- package/src/components/Loader/index.ts +1 -0
- package/src/components/Logo/Logo.stories.tsx +17 -0
- package/src/components/Logo/Logo.tsx +17 -0
- package/src/components/Logo/Logo.types.ts +6 -0
- package/src/components/Logo/index.ts +1 -0
- package/src/components/Menu/Menu.stories.tsx +37 -0
- package/src/components/Menu/Menu.tsx +45 -0
- package/src/components/Menu/Menu.types.ts +15 -0
- package/src/components/Menu/index.ts +1 -0
- package/src/components/Notice/Notice.stories.tsx +49 -0
- package/src/components/Notice/Notice.tsx +63 -0
- package/src/components/Notice/Notice.types.ts +11 -0
- package/src/components/Notice/index.ts +1 -0
- package/src/components/OTPInput/OTPInput.stories.tsx +18 -0
- package/src/components/OTPInput/OTPInput.tsx +80 -0
- package/src/components/OTPInput/OTPInput.types.ts +8 -0
- package/src/components/OTPInput/index.ts +1 -0
- package/src/components/PanelCards/PanelCards.stories.tsx +125 -0
- package/src/components/PanelCards/PanelCards.tsx +81 -0
- package/src/components/PanelCards/PanelCards.types.ts +11 -0
- package/src/components/PanelCards/index.ts +1 -0
- package/src/components/PanelCustom/PanelCustom.stories.tsx +18 -0
- package/src/components/PanelCustom/PanelCustom.tsx +39 -0
- package/src/components/PanelCustom/PanelCustom.types.ts +20 -0
- package/src/components/PanelCustom/index.ts +1 -0
- package/src/components/PanelFeature/PanelFeature.stories.tsx +46 -0
- package/src/components/PanelFeature/PanelFeature.tsx +83 -0
- package/src/components/PanelFeature/PanelFeature.types.ts +27 -0
- package/src/components/PanelFeature/index.ts +1 -0
- package/src/components/PanelHero/PanelHero.stories.tsx +126 -0
- package/src/components/PanelHero/PanelHero.tsx +184 -0
- package/src/components/PanelHero/PanelHero.types.ts +19 -0
- package/src/components/PanelHero/index.ts +1 -0
- package/src/components/PanelIntro/PanelIntro.stories.tsx +38 -0
- package/src/components/PanelIntro/PanelIntro.tsx +139 -0
- package/src/components/PanelIntro/PanelIntro.types.ts +19 -0
- package/src/components/PanelIntro/index.ts +1 -0
- package/src/components/PanelProduct/PanelProduct.stories.tsx +24 -0
- package/src/components/PanelProduct/PanelProduct.tsx +87 -0
- package/src/components/PanelProduct/PanelProduct.types.ts +14 -0
- package/src/components/PanelProduct/index.ts +1 -0
- package/src/components/PanelScroller/PanelScroller.stories.tsx +81 -0
- package/src/components/PanelScroller/PanelScroller.tsx +58 -0
- package/src/components/PanelScroller/PanelScroller.types.ts +8 -0
- package/src/components/PanelScroller/index.ts +1 -0
- package/src/components/PanelVideo/PanelVideo.stories.tsx +42 -0
- package/src/components/PanelVideo/PanelVideo.tsx +81 -0
- package/src/components/PanelVideo/PanelVideo.types.ts +11 -0
- package/src/components/PanelVideo/index.ts +1 -0
- package/src/components/Radio/Radio.stories.tsx +24 -0
- package/src/components/Radio/Radio.tsx +44 -0
- package/src/components/Radio/Radio.types.ts +13 -0
- package/src/components/Radio/index.ts +1 -0
- package/src/components/Schedule/Schedule.stories.tsx +96 -0
- package/src/components/Schedule/Schedule.tsx +118 -0
- package/src/components/Schedule/Schedule.types.ts +64 -0
- package/src/components/Schedule/index.ts +1 -0
- package/src/components/ScheduleItem/ScheduleItem.stories.tsx +21 -0
- package/src/components/ScheduleItem/ScheduleItem.tsx +77 -0
- package/src/components/ScheduleItem/ScheduleItem.types.ts +8 -0
- package/src/components/ScheduleItem/index.ts +1 -0
- package/src/components/Screen/Screen.stories.tsx +27 -0
- package/src/components/Screen/Screen.tsx +63 -0
- package/src/components/Screen/Screen.types.ts +16 -0
- package/src/components/Screen/index.ts +1 -0
- package/src/components/ShadcnButton/ShadcnButton.tsx +57 -0
- package/src/components/ShadcnButton/index.ts +2 -0
- package/src/components/ShadcnCarousel/ShadcnCarousel.tsx +261 -0
- package/src/components/ShadcnCarousel/index.ts +9 -0
- package/src/components/Share/Share.stories.tsx +17 -0
- package/src/components/Share/Share.tsx +60 -0
- package/src/components/Share/Share.types.ts +12 -0
- package/src/components/Share/index.ts +1 -0
- package/src/components/SubscriptionManager/SubscriptionManager.stories.tsx +177 -0
- package/src/components/SubscriptionManager/SubscriptionManager.tsx +369 -0
- package/src/components/SubscriptionManager/SubscriptionManager.types.ts +36 -0
- package/src/components/SubscriptionManager/index.ts +1 -0
- package/src/components/Switch/Switch.stories.tsx +20 -0
- package/src/components/Switch/Switch.tsx +30 -0
- package/src/components/Switch/Switch.types.ts +7 -0
- package/src/components/Switch/index.ts +1 -0
- package/src/components/Tabs/Tabs.stories.tsx +34 -0
- package/src/components/Tabs/Tabs.tsx +42 -0
- package/src/components/Tabs/Tabs.types.ts +8 -0
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/TextInput/TextInput.stories.tsx +18 -0
- package/src/components/TextInput/TextInput.tsx +78 -0
- package/src/components/TextInput/TextInput.types.ts +81 -0
- package/src/components/TextInput/index.ts +1 -0
- package/src/components/Video/Video.stories.tsx +75 -0
- package/src/components/Video/Video.tsx +280 -0
- package/src/components/Video/Video.types.ts +147 -0
- package/src/components/Video/index.ts +1 -0
- package/src/components/VisitUs/VisitUs.stories.tsx +32 -0
- package/src/components/VisitUs/VisitUs.tsx +56 -0
- package/src/components/VisitUs/VisitUs.types.ts +13 -0
- package/src/components/VisitUs/index.ts +1 -0
- package/src/components/index.ts +143 -0
- package/src/constants/index.ts +6 -0
- package/src/context/Amplify/index.tsx +65 -0
- package/src/context/App/index.tsx +93 -0
- package/src/context/Cart/index.tsx +64 -0
- package/src/context/ExampleContext/index.tsx +34 -0
- package/src/context/Theme/index.tsx +37 -0
- package/src/context/index.ts +18 -0
- package/src/features/Search/Search.stories.tsx +395 -0
- package/src/features/Search/Search.tsx +204 -0
- package/src/features/Search/Search.types.ts +41 -0
- package/src/features/Search/config/config-helper.ts +219 -0
- package/src/features/Search/index.ts +1 -0
- package/src/features/Search/view-helpers/appendClassName.ts +14 -0
- package/src/features/Search/view-helpers/formatResult.ts +97 -0
- package/src/features/Search/view-helpers/getFilterValueDisplay.ts +10 -0
- package/src/features/Search/view-helpers/getUrlSanitizer.ts +23 -0
- package/src/features/Search/view-helpers/index.ts +4 -0
- package/src/features/Search/views/Layout/Layout.tsx +50 -0
- package/src/features/Search/views/Layout/Layout.types.ts +13 -0
- package/src/features/Search/views/Layout/index.ts +1 -0
- package/src/features/Search/views/MultiCheckboxFacet/MultiCheckboxFacet.tsx +85 -0
- package/src/features/Search/views/MultiCheckboxFacet/MultiCheckboxFacet.types.ts +5 -0
- package/src/features/Search/views/MultiCheckboxFacet/index.ts +1 -0
- package/src/features/Search/views/Paging/Paging.tsx +35 -0
- package/src/features/Search/views/Paging/Paging.types.ts +24 -0
- package/src/features/Search/views/Paging/index.ts +1 -0
- package/src/features/Search/views/PagingInfo/PagingInfo.tsx +34 -0
- package/src/features/Search/views/PagingInfo/PagingInfo.types.ts +26 -0
- package/src/features/Search/views/PagingInfo/index.ts +1 -0
- package/src/features/Search/views/Result/Result.tsx +84 -0
- package/src/features/Search/views/Result/Result.types.ts +47 -0
- package/src/features/Search/views/Result/index.ts +1 -0
- package/src/features/Search/views/Results/Results.tsx +16 -0
- package/src/features/Search/views/Results/Results.types.ts +24 -0
- package/src/features/Search/views/Results/index.ts +1 -0
- package/src/features/Search/views/ResultsPerPage/ResultsPerPage.tsx +32 -0
- package/src/features/Search/views/ResultsPerPage/ResultsPerPage.types.ts +26 -0
- package/src/features/Search/views/ResultsPerPage/index.ts +1 -0
- package/src/features/Search/views/SearchBox/SearchBox.tsx +51 -0
- package/src/features/Search/views/SearchBox/SearchBox.types.ts +10 -0
- package/src/features/Search/views/SearchBox/index.ts +1 -0
- package/src/features/Search/views/Sidebar/Sidebar.tsx +14 -0
- package/src/features/Search/views/Sidebar/Sidebar.types.ts +3 -0
- package/src/features/Search/views/Sidebar/index.ts +1 -0
- package/src/features/Search/views/SingleLinksFacet/SingleLinksFacet.tsx +62 -0
- package/src/features/Search/views/SingleLinksFacet/SingleLinksFacet.types.ts +5 -0
- package/src/features/Search/views/SingleLinksFacet/index.ts +1 -0
- package/src/features/Search/views/SingleSelectFacet/SingleSelectFacet.tsx +34 -0
- package/src/features/Search/views/SingleSelectFacet/SingleSelectFacet.types.ts +5 -0
- package/src/features/Search/views/SingleSelectFacet/index.ts +1 -0
- package/src/features/Search/views/Sorting/Sorting.tsx +24 -0
- package/src/features/Search/views/Sorting/Sorting.types.ts +25 -0
- package/src/features/Search/views/Sorting/index.ts +1 -0
- package/src/features/index.ts +11 -0
- package/src/forms/ForgotPasswordForm/ForgotPasswordForm.stories.tsx +19 -0
- package/src/forms/ForgotPasswordForm/ForgotPasswordForm.tsx +28 -0
- package/src/forms/ForgotPasswordForm/ForgotPasswordForm.types.ts +3 -0
- package/src/forms/ForgotPasswordForm/index.ts +1 -0
- package/src/forms/LoginForm/LoginForm.stories.tsx +67 -0
- package/src/forms/LoginForm/LoginForm.tsx +112 -0
- package/src/forms/LoginForm/LoginForm.types.ts +7 -0
- package/src/forms/LoginForm/index.ts +1 -0
- package/src/forms/ProfileForm/ProfileForm.stories.tsx +23 -0
- package/src/forms/ProfileForm/ProfileForm.tsx +40 -0
- package/src/forms/ProfileForm/ProfileForm.types.ts +6 -0
- package/src/forms/ProfileForm/index.ts +1 -0
- package/src/forms/PromoCodeForm/PromoCodeForm.stories.tsx +19 -0
- package/src/forms/PromoCodeForm/PromoCodeForm.tsx +22 -0
- package/src/forms/PromoCodeForm/PromoCodeForm.types.ts +4 -0
- package/src/forms/PromoCodeForm/index.ts +1 -0
- package/src/forms/RegisterForm/RegisterForm.stories.tsx +85 -0
- package/src/forms/RegisterForm/RegisterForm.tsx +108 -0
- package/src/forms/RegisterForm/RegisterForm.types.ts +6 -0
- package/src/forms/RegisterForm/index.ts +1 -0
- package/src/forms/ResetPasswordAuthForm/ResetPasswordAuthForm.stories.tsx +23 -0
- package/src/forms/ResetPasswordAuthForm/ResetPasswordAuthForm.tsx +39 -0
- package/src/forms/ResetPasswordAuthForm/ResetPasswordAuthForm.types.ts +3 -0
- package/src/forms/ResetPasswordAuthForm/index.ts +1 -0
- package/src/forms/ResetPasswordForm/ResetPasswordForm.stories.tsx +23 -0
- package/src/forms/ResetPasswordForm/ResetPasswordForm.tsx +30 -0
- package/src/forms/ResetPasswordForm/ResetPasswordForm.types.ts +3 -0
- package/src/forms/ResetPasswordForm/index.ts +1 -0
- package/src/forms/SubscriptionForm/SubscriptionForm.stories.tsx +31 -0
- package/src/forms/SubscriptionForm/SubscriptionForm.tsx +46 -0
- package/src/forms/SubscriptionForm/SubscriptionForm.types.ts +6 -0
- package/src/forms/SubscriptionForm/index.ts +1 -0
- package/src/forms/constants/index.ts +13 -0
- package/src/forms/index.ts +17 -0
- package/src/forms/validations/index.ts +39 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useLanguage.ts +18 -0
- package/src/hooks/useTheme.ts +6 -0
- package/src/index.ts +8 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/setupTests.ts +5 -0
- package/src/templates/AccountScreen/AccountScreen.stories.tsx +67 -0
- package/src/templates/AccountScreen/AccountScreen.tsx +78 -0
- package/src/templates/AccountScreen/AccountScreen.types.ts +31 -0
- package/src/templates/AccountScreen/index.ts +1 -0
- package/src/templates/AuthScreen/AuthScreen.stories.tsx +33 -0
- package/src/templates/AuthScreen/AuthScreen.tsx +21 -0
- package/src/templates/AuthScreen/AuthScreen.types.ts +8 -0
- package/src/templates/AuthScreen/index.ts +1 -0
- package/src/templates/CardGridScreen/CardGridScreen.stories.tsx +95 -0
- package/src/templates/CardGridScreen/CardGridScreen.tsx +43 -0
- package/src/templates/CardGridScreen/CardGridScreen.types.ts +11 -0
- package/src/templates/CardGridScreen/index.ts +1 -0
- package/src/templates/CatalogueScreen/CatalogueScreen.stories.tsx +31 -0
- package/src/templates/CatalogueScreen/CatalogueScreen.tsx +21 -0
- package/src/templates/CatalogueScreen/CatalogueScreen.types.ts +8 -0
- package/src/templates/CatalogueScreen/index.ts +1 -0
- package/src/templates/ChallengeLibraryScreen/ChallengeLibraryScreen.stories.tsx +171 -0
- package/src/templates/ChallengeLibraryScreen/ChallengeLibraryScreen.tsx +36 -0
- package/src/templates/ChallengeLibraryScreen/ChallengeLibraryScreen.types.ts +9 -0
- package/src/templates/ChallengeLibraryScreen/index.ts +1 -0
- package/src/templates/ChallengeScreen/ChallengeScreen.stories.tsx +65 -0
- package/src/templates/ChallengeScreen/ChallengeScreen.tsx +88 -0
- package/src/templates/ChallengeScreen/ChallengeScreen.types.ts +22 -0
- package/src/templates/ChallengeScreen/index.ts +1 -0
- package/src/templates/ContentScreen/ContentScreen.stories.tsx +71 -0
- package/src/templates/ContentScreen/ContentScreen.tsx +55 -0
- package/src/templates/ContentScreen/ContentScreen.types.ts +9 -0
- package/src/templates/ContentScreen/index.ts +1 -0
- package/src/templates/DashboardScreen/DashboardScreen.stories.tsx +490 -0
- package/src/templates/DashboardScreen/DashboardScreen.tsx +156 -0
- package/src/templates/DashboardScreen/DashboardScreen.types.ts +28 -0
- package/src/templates/DashboardScreen/index.ts +1 -0
- package/src/templates/FAQScreen/FAQScreen.stories.tsx +278 -0
- package/src/templates/FAQScreen/FAQScreen.tsx +32 -0
- package/src/templates/FAQScreen/FAQScreen.types.ts +14 -0
- package/src/templates/FAQScreen/index.ts +1 -0
- package/src/templates/HomeScreen/HomeScreen.stories.tsx +315 -0
- package/src/templates/HomeScreen/HomeScreen.tsx +50 -0
- package/src/templates/HomeScreen/HomeScreen.types.ts +23 -0
- package/src/templates/HomeScreen/index.ts +1 -0
- package/src/templates/LogoutScreen/LogoutScreen.stories.tsx +20 -0
- package/src/templates/LogoutScreen/LogoutScreen.tsx +25 -0
- package/src/templates/LogoutScreen/LogoutScreen.types.ts +4 -0
- package/src/templates/LogoutScreen/index.ts +1 -0
- package/src/templates/MenuScreen/MenuScreen.stories.tsx +36 -0
- package/src/templates/MenuScreen/MenuScreen.tsx +32 -0
- package/src/templates/MenuScreen/MenuScreen.types.ts +11 -0
- package/src/templates/MenuScreen/index.ts +1 -0
- package/src/templates/NotFoundScreen/NotFoundScreen.stories.tsx +20 -0
- package/src/templates/NotFoundScreen/NotFoundScreen.tsx +31 -0
- package/src/templates/NotFoundScreen/NotFoundScreen.types.ts +5 -0
- package/src/templates/NotFoundScreen/index.ts +1 -0
- package/src/templates/PasswordResetAuthScreen/PasswordResetAuthScreen.stories.tsx +27 -0
- package/src/templates/PasswordResetAuthScreen/PasswordResetAuthScreen.tsx +20 -0
- package/src/templates/PasswordResetAuthScreen/PasswordResetAuthScreen.types.ts +6 -0
- package/src/templates/PasswordResetAuthScreen/index.ts +1 -0
- package/src/templates/PasswordResetScreen/PasswordResetScreen.stories.tsx +22 -0
- package/src/templates/PasswordResetScreen/PasswordResetScreen.tsx +19 -0
- package/src/templates/PasswordResetScreen/PasswordResetScreen.types.ts +6 -0
- package/src/templates/PasswordResetScreen/index.ts +1 -0
- package/src/templates/ProfileScreen/ProfileScreen.stories.tsx +41 -0
- package/src/templates/ProfileScreen/ProfileScreen.tsx +30 -0
- package/src/templates/ProfileScreen/ProfileScreen.types.ts +24 -0
- package/src/templates/ProfileScreen/index.ts +1 -0
- package/src/templates/ScheduleScreen/ScheduleScreen.stories.tsx +174 -0
- package/src/templates/ScheduleScreen/ScheduleScreen.tsx +29 -0
- package/src/templates/ScheduleScreen/ScheduleScreen.types.ts +9 -0
- package/src/templates/ScheduleScreen/index.ts +1 -0
- package/src/templates/SubscriptionScreen/SubscriptionScreen.stories.tsx +98 -0
- package/src/templates/SubscriptionScreen/SubscriptionScreen.tsx +49 -0
- package/src/templates/SubscriptionScreen/SubscriptionScreen.types.ts +28 -0
- package/src/templates/SubscriptionScreen/index.ts +1 -0
- package/src/templates/WorkoutScreen/WorkoutScreen.stories.tsx +173 -0
- package/src/templates/WorkoutScreen/WorkoutScreen.tsx +230 -0
- package/src/templates/WorkoutScreen/WorkoutScreen.types.ts +34 -0
- package/src/templates/WorkoutScreen/index.ts +1 -0
- package/src/templates/index.ts +40 -0
- package/src/translations/en.ts +777 -0
- package/src/translations/fr.ts +182 -0
- package/src/translations/index.ts +2 -0
- package/src/utils/htmlParser/index.tsx +22 -0
- package/src/utils/index.ts +38 -0
- package/src/utils/parseDuration/index.ts +94 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { Props } from './LoginForm.types';
|
|
4
|
+
import { socialLoginUrlApple, socialLoginUrlGoogle } from '../constants';
|
|
5
|
+
import { Auth, Hub } from 'aws-amplify';
|
|
6
|
+
import { CognitoHostedUIIdentityProvider } from '@aws-amplify/auth';
|
|
7
|
+
import { validEmail } from '../validations';
|
|
8
|
+
import STRINGS from '../../translations';
|
|
9
|
+
import Form from '../../components/Form';
|
|
10
|
+
import FormField from '../../components/FormField';
|
|
11
|
+
import { FIELD_TYPES } from '../../components/FormField/FormField.types';
|
|
12
|
+
import Button from '../../components/Button';
|
|
13
|
+
import { BTN_VARIANTS } from '../../components/Button/Button.types';
|
|
14
|
+
import Hr from '../../components/Hr';
|
|
15
|
+
import { toast } from 'react-toastify';
|
|
16
|
+
import { useLanguage } from '../../hooks';
|
|
17
|
+
|
|
18
|
+
const LoginForm = ({
|
|
19
|
+
handleSubmit,
|
|
20
|
+
initialValues,
|
|
21
|
+
handleTokenCallback,
|
|
22
|
+
showSocialButtons = false,
|
|
23
|
+
className,
|
|
24
|
+
}: Props) => {
|
|
25
|
+
const T = useLanguage();
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const unsubscribe = Hub.listen('auth', ({ payload: { event, data } }) => {
|
|
29
|
+
switch (event) {
|
|
30
|
+
case 'signIn':
|
|
31
|
+
if (handleTokenCallback && typeof handleTokenCallback === 'function') {
|
|
32
|
+
handleTokenCallback(data.signInUserSession);
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
case 'signOut':
|
|
36
|
+
toast.success('You have been signed out');
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return unsubscribe;
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
43
|
+
const authWithSocial = async (provider: CognitoHostedUIIdentityProvider) => {
|
|
44
|
+
try {
|
|
45
|
+
Auth.federatedSignIn({
|
|
46
|
+
provider: provider,
|
|
47
|
+
});
|
|
48
|
+
} catch (error: any) {
|
|
49
|
+
console.log(error);
|
|
50
|
+
toast.error(error.message || T?.ERRORS?.GENERIC_ERROR);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div data-testid="LoginForm" className={cx("form-wrapper", className)}>
|
|
56
|
+
<Form
|
|
57
|
+
onSubmit={handleSubmit}
|
|
58
|
+
submit={STRINGS.FORMS.LOGIN_FORM.SUBMIT}
|
|
59
|
+
initialValues={initialValues}>
|
|
60
|
+
<FormField
|
|
61
|
+
name="email"
|
|
62
|
+
type={FIELD_TYPES.EMAIL}
|
|
63
|
+
label={STRINGS.FORMS.LOGIN_FORM.EMAIL}
|
|
64
|
+
required
|
|
65
|
+
validations={validEmail}
|
|
66
|
+
autoComplete="email"
|
|
67
|
+
/>
|
|
68
|
+
<FormField
|
|
69
|
+
name="password"
|
|
70
|
+
type={FIELD_TYPES.PASSWORD}
|
|
71
|
+
label={STRINGS.FORMS.LOGIN_FORM.PASSWORD}
|
|
72
|
+
required
|
|
73
|
+
autoComplete="current-password"
|
|
74
|
+
/>
|
|
75
|
+
</Form>
|
|
76
|
+
{showSocialButtons && (
|
|
77
|
+
<>
|
|
78
|
+
<Hr />
|
|
79
|
+
<div className="flex flex-col gap-4 items-center">
|
|
80
|
+
<div className="flex flex-col gap-4 max-w-[250px]">
|
|
81
|
+
{socialLoginUrlGoogle && (
|
|
82
|
+
<Button
|
|
83
|
+
// onClick={() => window.location.assign(socialLoginUrlGoogle)}
|
|
84
|
+
onClick={() => authWithSocial(CognitoHostedUIIdentityProvider.Google)}
|
|
85
|
+
variant={BTN_VARIANTS.PRIMARY}
|
|
86
|
+
iconFirst
|
|
87
|
+
icon="mdi:google">
|
|
88
|
+
{STRINGS.UI.LOGIN_WITH_GOOGLE}
|
|
89
|
+
</Button>
|
|
90
|
+
)}
|
|
91
|
+
{socialLoginUrlApple && (
|
|
92
|
+
<Button
|
|
93
|
+
// onClick={() => window.location.assign(socialLoginUrlApple)}
|
|
94
|
+
onClick={() => authWithSocial(CognitoHostedUIIdentityProvider.Apple)}
|
|
95
|
+
variant={BTN_VARIANTS.PRIMARY}
|
|
96
|
+
iconFirst
|
|
97
|
+
icon="mdi:apple">
|
|
98
|
+
{STRINGS.UI.LOGIN_WITH_APPLE}
|
|
99
|
+
</Button>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
LoginForm.displayName = 'LoginForm';
|
|
110
|
+
|
|
111
|
+
export default LoginForm;
|
|
112
|
+
export type { Props };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './LoginForm';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/nextjs';
|
|
2
|
+
import ProfileForm from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof ProfileForm> = {
|
|
5
|
+
title: 'FORMS/ProfileForm',
|
|
6
|
+
component: ProfileForm,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type Story = StoryObj<typeof ProfileForm>;
|
|
10
|
+
|
|
11
|
+
export const Default: Story = {
|
|
12
|
+
args: {
|
|
13
|
+
handleSubmit: (values) => console.log('values', values),
|
|
14
|
+
initialValues: {
|
|
15
|
+
firstName: 'Joe',
|
|
16
|
+
lastName: 'Bloggs',
|
|
17
|
+
email: 'joe@bloggs.com',
|
|
18
|
+
picture: 'http://via.placeholder.com/450x400',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Props } from './ProfileForm.types';
|
|
3
|
+
import { FIELD_TYPES } from '../../components/FormField/FormField.types';
|
|
4
|
+
import Form from '../../components/Form';
|
|
5
|
+
import FormField from '../../components/FormField';
|
|
6
|
+
import { validEmail } from '../validations';
|
|
7
|
+
import Avatar from '../../components/Avatar';
|
|
8
|
+
import { useLanguage } from '../../hooks';
|
|
9
|
+
|
|
10
|
+
const ProfileForm = ({ testID, initialValues, handleSubmit, avatarUpdateCallback }: Props) => {
|
|
11
|
+
const T = useLanguage();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div data-testid={testID || '"ProfileForm"'} className="form-wrapper">
|
|
15
|
+
<Form
|
|
16
|
+
onSubmit={handleSubmit}
|
|
17
|
+
submit={T.FORMS.PROFILE_FORM.SUBMIT}
|
|
18
|
+
initialValues={initialValues}>
|
|
19
|
+
<div className="mb-4 items-center justify-center flex">
|
|
20
|
+
<Avatar name="avatar" initValue={initialValues?.picture} fileUpdateCallback={avatarUpdateCallback} />
|
|
21
|
+
</div>
|
|
22
|
+
<FormField name="picture" type={FIELD_TYPES.HIDDEN} />
|
|
23
|
+
<FormField name="firstName" type={FIELD_TYPES.TEXT} label={T.FORMS.PROFILE_FORM.FIRST_NAME} required />
|
|
24
|
+
<FormField name="lastName" type={FIELD_TYPES.TEXT} label={T.FORMS.PROFILE_FORM.LAST_NAME} required />
|
|
25
|
+
<FormField
|
|
26
|
+
name="email"
|
|
27
|
+
type={FIELD_TYPES.EMAIL}
|
|
28
|
+
label={T.FORMS.PROFILE_FORM.EMAIL}
|
|
29
|
+
required
|
|
30
|
+
validations={validEmail}
|
|
31
|
+
/>
|
|
32
|
+
</Form>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
ProfileForm.displayName = 'ProfileForm';
|
|
38
|
+
|
|
39
|
+
export default ProfileForm;
|
|
40
|
+
export type { Props };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ProfileForm';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/nextjs';
|
|
2
|
+
import PromoCodeForm from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof PromoCodeForm> = {
|
|
5
|
+
title: 'FORMS/PromoCodeForm',
|
|
6
|
+
component: PromoCodeForm,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type Story = StoryObj<typeof PromoCodeForm>;
|
|
10
|
+
|
|
11
|
+
export const Default: Story = {
|
|
12
|
+
args: {
|
|
13
|
+
handleSubmit: async (values: any) => {
|
|
14
|
+
console.log('Promocode values', values);
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Props } from './PromoCodeForm.types';
|
|
3
|
+
import { useLanguage } from '../../hooks';
|
|
4
|
+
import Form from '../../components/Form';
|
|
5
|
+
import FormField from '../../components/FormField';
|
|
6
|
+
import { FIELD_TYPES } from '../../components/FormField/FormField.types';
|
|
7
|
+
|
|
8
|
+
const PromoCodeForm = ({ handleSubmit = () => {} }: Props) => {
|
|
9
|
+
const T = useLanguage();
|
|
10
|
+
return (
|
|
11
|
+
<div data-testid="PromoCodeForm" className="form-wrapper">
|
|
12
|
+
<Form onSubmit={handleSubmit} submit={T?.FORMS?.PROMO_CODE_FORM?.SUBMIT}>
|
|
13
|
+
<FormField name="promoCode" type={FIELD_TYPES.TEXT} label={T?.FORMS?.PROMO_CODE_FORM?.PROMO_CODE} />
|
|
14
|
+
</Form>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
PromoCodeForm.displayName = 'PromoCodeForm';
|
|
20
|
+
|
|
21
|
+
export default PromoCodeForm;
|
|
22
|
+
export type { Props };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './PromoCodeForm';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/nextjs';
|
|
2
|
+
import RegisterForm from '.';
|
|
3
|
+
import { toast } from 'react-toastify';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof RegisterForm> = {
|
|
6
|
+
title: 'FORMS/RegisterForm',
|
|
7
|
+
component: RegisterForm,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type Story = StoryObj<typeof RegisterForm>;
|
|
11
|
+
|
|
12
|
+
export const Default: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
handleSubmit: async (values: any) => {
|
|
15
|
+
console.log('Register values', values);
|
|
16
|
+
try {
|
|
17
|
+
console.log('Login values', values);
|
|
18
|
+
const response = await fetch('http://localhost:9003/1.0/user/login', {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify(values),
|
|
24
|
+
});
|
|
25
|
+
const json = await response.json();
|
|
26
|
+
if (response.ok) {
|
|
27
|
+
console.log('Login json', json);
|
|
28
|
+
toast.info(json?.message);
|
|
29
|
+
}
|
|
30
|
+
throw new Error(json?.message);
|
|
31
|
+
} catch (err: any) {
|
|
32
|
+
console.log(err);
|
|
33
|
+
toast.error(err.message);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
showSocialButtons: false,
|
|
37
|
+
},
|
|
38
|
+
render: (args) => {
|
|
39
|
+
// const [accessToken, setAccessToken] = useState<string | null>(null);
|
|
40
|
+
|
|
41
|
+
// const handleTokenCallback = (tokens: any) => {
|
|
42
|
+
// console.log('handleTokenCallback', tokens);
|
|
43
|
+
// setAccessToken(tokens.accessToken);
|
|
44
|
+
// };
|
|
45
|
+
|
|
46
|
+
// const handleSubmit = async (values: any) => {
|
|
47
|
+
// try {
|
|
48
|
+
// console.log('Login values', values);
|
|
49
|
+
// const response = await fetch('http://localhost:9003/1.0/user/login', {
|
|
50
|
+
// method: 'POST',
|
|
51
|
+
// headers: {
|
|
52
|
+
// 'Content-Type': 'application/json',
|
|
53
|
+
// },
|
|
54
|
+
// body: JSON.stringify(values),
|
|
55
|
+
// });
|
|
56
|
+
// const json = await response.json();
|
|
57
|
+
// if (response.ok) {
|
|
58
|
+
// console.log('Login json', json);
|
|
59
|
+
// toast.info(json?.message);
|
|
60
|
+
// }
|
|
61
|
+
// throw new Error(json?.message);
|
|
62
|
+
// } catch (err: any) {
|
|
63
|
+
// console.log(err);
|
|
64
|
+
// toast.error(err.message);
|
|
65
|
+
// }
|
|
66
|
+
// };
|
|
67
|
+
|
|
68
|
+
// const now = new Date().getTime();
|
|
69
|
+
// const initialValues = {
|
|
70
|
+
// email: `joe+${now}@4alldigital.com`,
|
|
71
|
+
// password: 'Password123!',
|
|
72
|
+
// };
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<RegisterForm
|
|
76
|
+
{...args}
|
|
77
|
+
// handleSubmit={handleSubmit}
|
|
78
|
+
// initialValues={initialValues}
|
|
79
|
+
// showSocialButtons={false}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default meta;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { Auth, Hub } from 'aws-amplify';
|
|
4
|
+
import { CognitoHostedUIIdentityProvider } from '@aws-amplify/auth';
|
|
5
|
+
import Form from '../../components/Form';
|
|
6
|
+
import FormField from '../../components/FormField';
|
|
7
|
+
import { FIELD_TYPES } from '../../components/FormField/FormField.types';
|
|
8
|
+
import Button from '../../components/Button';
|
|
9
|
+
import { BTN_VARIANTS } from '../../components/Button/Button.types';
|
|
10
|
+
import Hr from '../../components/Hr';
|
|
11
|
+
// import { socialLoginUrlApple, socialLoginUrlGoogle } from '../constants';
|
|
12
|
+
import { validEmail, validPassword } from '../validations';
|
|
13
|
+
import STRINGS from '../../translations';
|
|
14
|
+
import { useLanguage } from '../../hooks';
|
|
15
|
+
import { Props } from './RegisterForm.types';
|
|
16
|
+
import { toast } from 'react-toastify';
|
|
17
|
+
|
|
18
|
+
const RegisterForm = ({
|
|
19
|
+
handleSubmit,
|
|
20
|
+
handleTokenCallback,
|
|
21
|
+
showSocialButtons = false,
|
|
22
|
+
className,
|
|
23
|
+
}: Props) => {
|
|
24
|
+
const T = useLanguage();
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const unsubscribe = Hub.listen('auth', ({ payload: { event, data } }) => {
|
|
28
|
+
switch (event) {
|
|
29
|
+
case 'signUp':
|
|
30
|
+
if (handleTokenCallback && typeof handleTokenCallback === 'function') {
|
|
31
|
+
handleTokenCallback(data.signInUserSession);
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return unsubscribe;
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
39
|
+
const authWithSocial = async (provider: CognitoHostedUIIdentityProvider) => {
|
|
40
|
+
try {
|
|
41
|
+
Auth.federatedSignIn({
|
|
42
|
+
provider: provider,
|
|
43
|
+
});
|
|
44
|
+
} catch (error: any) {
|
|
45
|
+
console.log(error);
|
|
46
|
+
// Toast.show({
|
|
47
|
+
// type: 'error',
|
|
48
|
+
// text1: T.UI.ERROR,
|
|
49
|
+
// text2: error.message || T.ERRORS.GENERIC_ERROR,
|
|
50
|
+
// });
|
|
51
|
+
toast.error(error.message || T?.ERRORS?.GENERIC_ERROR);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div data-testid="RegisterForm" className={cx('form-wrapper', className)}>
|
|
57
|
+
<Form onSubmit={handleSubmit} submit={STRINGS.FORMS.REGISTER_FORM.SUBMIT}>
|
|
58
|
+
<FormField
|
|
59
|
+
name="email"
|
|
60
|
+
type={FIELD_TYPES.EMAIL}
|
|
61
|
+
label={STRINGS.FORMS.REGISTER_FORM.EMAIL}
|
|
62
|
+
required
|
|
63
|
+
validations={validEmail}
|
|
64
|
+
autoComplete="email"
|
|
65
|
+
/>
|
|
66
|
+
<FormField
|
|
67
|
+
name="password"
|
|
68
|
+
type={FIELD_TYPES.PASSWORD}
|
|
69
|
+
label={STRINGS.FORMS.REGISTER_FORM.PASSWORD}
|
|
70
|
+
required
|
|
71
|
+
description={STRINGS.FORMS.REGISTER_FORM.PASSWORD_DESCRIPTION}
|
|
72
|
+
validations={validPassword}
|
|
73
|
+
autoComplete="new-password"
|
|
74
|
+
/>
|
|
75
|
+
</Form>
|
|
76
|
+
{showSocialButtons && (
|
|
77
|
+
<>
|
|
78
|
+
<Hr />
|
|
79
|
+
<div className="flex flex-col gap-4 items-center">
|
|
80
|
+
<div className="flex flex-col gap-4 max-w-[250px]">
|
|
81
|
+
<Button
|
|
82
|
+
// onClick={() => window.location.assign(socialLoginUrlGoogle)}
|
|
83
|
+
onClick={() => authWithSocial(CognitoHostedUIIdentityProvider.Google)}
|
|
84
|
+
variant={BTN_VARIANTS.PRIMARY}
|
|
85
|
+
iconFirst
|
|
86
|
+
icon="mdi:google">
|
|
87
|
+
{STRINGS.UI.SIGNUP_WITH_GOOGLE}
|
|
88
|
+
</Button>
|
|
89
|
+
<Button
|
|
90
|
+
// onClick={() => window.location.assign(socialLoginUrlApple)}
|
|
91
|
+
onClick={() => authWithSocial(CognitoHostedUIIdentityProvider.Apple)}
|
|
92
|
+
variant={BTN_VARIANTS.PRIMARY}
|
|
93
|
+
iconFirst
|
|
94
|
+
icon="mdi:apple">
|
|
95
|
+
{STRINGS.UI.SIGNUP_WITH_APPLE}
|
|
96
|
+
</Button>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
RegisterForm.displayName = 'RegisterForm';
|
|
106
|
+
|
|
107
|
+
export default RegisterForm;
|
|
108
|
+
export type { Props };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './RegisterForm';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/nextjs';
|
|
2
|
+
import ResetPasswordAuthForm from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof ResetPasswordAuthForm> = {
|
|
5
|
+
title: 'FORMS/ResetPasswordAuthForm',
|
|
6
|
+
component: ResetPasswordAuthForm,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type Story = StoryObj<typeof ResetPasswordAuthForm>;
|
|
10
|
+
|
|
11
|
+
export const Default: Story = {
|
|
12
|
+
args: {
|
|
13
|
+
handleSubmit: async (values: any) => {
|
|
14
|
+
console.log('ResetPassword values', values);
|
|
15
|
+
const randomIntBetweenOneAndTwenty = Math.floor(Math.random() * 20) + 1;
|
|
16
|
+
const response = await fetch(`https://jsonplaceholder.typicode.com/todos/${randomIntBetweenOneAndTwenty}`);
|
|
17
|
+
const json = await response.json();
|
|
18
|
+
console.log('ResetPassword json', json);
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Props } from './ResetPasswordAuthForm.types';
|
|
3
|
+
import { useLanguage } from '../../hooks';
|
|
4
|
+
import Form from '../../components/Form/Form';
|
|
5
|
+
import FormField from '../../components/FormField';
|
|
6
|
+
import { FIELD_TYPES } from '../../components/FormField/FormField.types';
|
|
7
|
+
import { validPassword } from '../validations';
|
|
8
|
+
|
|
9
|
+
const ResetPasswordAuthForm = ({ handleSubmit }: Props) => {
|
|
10
|
+
const T = useLanguage();
|
|
11
|
+
return (
|
|
12
|
+
<div data-testid="ResetPasswordAuthForm" className="form-wrapper">
|
|
13
|
+
<Form onSubmit={handleSubmit} submit={T.FORMS.RESET_PASSWORD_FORM.SUBMIT}>
|
|
14
|
+
<FormField
|
|
15
|
+
name="current-password"
|
|
16
|
+
autoComplete="current-password"
|
|
17
|
+
type={FIELD_TYPES.PASSWORD}
|
|
18
|
+
label={T.FORMS.RESET_PASSWORD_FORM_AUTH.CURRENT_PASSWORD}
|
|
19
|
+
required
|
|
20
|
+
validations={validPassword}
|
|
21
|
+
/>
|
|
22
|
+
<FormField
|
|
23
|
+
name="new-password"
|
|
24
|
+
autoComplete="new-password"
|
|
25
|
+
type={FIELD_TYPES.PASSWORD}
|
|
26
|
+
label={T.FORMS.RESET_PASSWORD_FORM_AUTH.NEW_PASSWORD}
|
|
27
|
+
required
|
|
28
|
+
validations={validPassword}
|
|
29
|
+
/>
|
|
30
|
+
</Form>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
ResetPasswordAuthForm.displayName = 'ResetPasswordAuthForm';
|
|
36
|
+
|
|
37
|
+
export default ResetPasswordAuthForm;
|
|
38
|
+
export type { Props };
|
|
39
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ResetPasswordAuthForm';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/nextjs';
|
|
2
|
+
import ResetPasswordForm from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof ResetPasswordForm> = {
|
|
5
|
+
title: 'FORMS/ResetPasswordForm',
|
|
6
|
+
component: ResetPasswordForm,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type Story = StoryObj<typeof ResetPasswordForm>;
|
|
10
|
+
|
|
11
|
+
export const Default: Story = {
|
|
12
|
+
args: {
|
|
13
|
+
handleSubmit: async (values: any) => {
|
|
14
|
+
console.log('ResetPassword values', values);
|
|
15
|
+
const randomIntBetweenOneAndTwenty = Math.floor(Math.random() * 20) + 1;
|
|
16
|
+
const response = await fetch(`https://jsonplaceholder.typicode.com/todos/${randomIntBetweenOneAndTwenty}`);
|
|
17
|
+
const json = await response.json();
|
|
18
|
+
console.log('ResetPassword json', json);
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Props } from './ResetPasswordForm.types';
|
|
3
|
+
import Form from '../../components/Form/Form';
|
|
4
|
+
import FormField from '../../components/FormField';
|
|
5
|
+
import { FIELD_TYPES } from '../../components/FormField/FormField.types';
|
|
6
|
+
import { validPassword } from '../validations';
|
|
7
|
+
import { useLanguage } from '../../hooks';
|
|
8
|
+
|
|
9
|
+
const ResetPasswordForm = ({ handleSubmit }: Props) => {
|
|
10
|
+
const T = useLanguage();
|
|
11
|
+
return (
|
|
12
|
+
<div data-testid="ResetPasswordForm" className="form-wrapper">
|
|
13
|
+
<Form onSubmit={handleSubmit} submit={T.FORMS.RESET_PASSWORD_FORM.SUBMIT}>
|
|
14
|
+
<FormField
|
|
15
|
+
name="password"
|
|
16
|
+
autoComplete='new-password'
|
|
17
|
+
type={FIELD_TYPES.PASSWORD}
|
|
18
|
+
label={T.FORMS.RESET_PASSWORD_FORM.PASSWORD}
|
|
19
|
+
required
|
|
20
|
+
validations={validPassword}
|
|
21
|
+
/>
|
|
22
|
+
</Form>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
ResetPasswordForm.displayName = 'ResetPasswordForm';
|
|
28
|
+
|
|
29
|
+
export default ResetPasswordForm;
|
|
30
|
+
export type { Props };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ResetPasswordForm';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/nextjs';
|
|
2
|
+
import SubscriptionForm from '.';
|
|
3
|
+
import { Container } from '../../components';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof SubscriptionForm> = {
|
|
6
|
+
title: 'FORMS/SubscriptionForm',
|
|
7
|
+
component: SubscriptionForm,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type Story = StoryObj<typeof SubscriptionForm>;
|
|
11
|
+
|
|
12
|
+
export const Default: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
handleSubmit: values => console.log('values', values),
|
|
15
|
+
initialValues: {
|
|
16
|
+
subscriptionStatus: 'Active',
|
|
17
|
+
plan: 'Premium',
|
|
18
|
+
price: '$9.99',
|
|
19
|
+
billingDate: '2024-12-31',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
render: props => {
|
|
23
|
+
return (
|
|
24
|
+
<Container>
|
|
25
|
+
<SubscriptionForm {...props} />
|
|
26
|
+
</Container>
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default meta;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Props } from './SubscriptionForm.types';
|
|
3
|
+
import Form from '../../components/Form/Form';
|
|
4
|
+
import FormField from '../../components/FormField';
|
|
5
|
+
import { FIELD_TYPES } from '../../components/FormField/FormField.types';
|
|
6
|
+
import { useLanguage } from '../../hooks';
|
|
7
|
+
|
|
8
|
+
const SubscriptionForm = ({ testID, initialValues, handleSubmit, isDisabled = true }: Props) => {
|
|
9
|
+
const T = useLanguage();
|
|
10
|
+
return (
|
|
11
|
+
<div data-testid={testID || '"SubscriptionForm"'} className="form-wrapper">
|
|
12
|
+
<Form onSubmit={handleSubmit} isDisabled={isDisabled} initialValues={initialValues}>
|
|
13
|
+
<FormField
|
|
14
|
+
name="status"
|
|
15
|
+
type={FIELD_TYPES.TEXT}
|
|
16
|
+
label={T.FORMS.ACCOUNT.SUBSCRIPTION_STATUS_LABEL}
|
|
17
|
+
disabled={isDisabled}
|
|
18
|
+
/>
|
|
19
|
+
<FormField
|
|
20
|
+
name="plan"
|
|
21
|
+
type={FIELD_TYPES.TEXT}
|
|
22
|
+
label={T.FORMS.ACCOUNT.SUBSCRIPTION_PLAN_LABEL}
|
|
23
|
+
disabled={isDisabled}
|
|
24
|
+
/>
|
|
25
|
+
<FormField
|
|
26
|
+
name="price"
|
|
27
|
+
type={FIELD_TYPES.TEXT}
|
|
28
|
+
label={T.FORMS.ACCOUNT.SUBSCRIPTION_PRICE_LABEL}
|
|
29
|
+
disabled={isDisabled}
|
|
30
|
+
/>
|
|
31
|
+
<FormField
|
|
32
|
+
name="billingDate"
|
|
33
|
+
type={FIELD_TYPES.TEXT}
|
|
34
|
+
label={T.FORMS.ACCOUNT.SUBSCRIPTION_BILLING_DATE_LABEL}
|
|
35
|
+
required
|
|
36
|
+
disabled={isDisabled}
|
|
37
|
+
/>
|
|
38
|
+
</Form>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
SubscriptionForm.displayName = 'SubscriptionForm';
|
|
44
|
+
|
|
45
|
+
export default SubscriptionForm;
|
|
46
|
+
export type { Props };
|