@effijs/templates 0.0.0-stage → 1.0.0-alpha.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/CONTRIBUTING.md +27 -0
- package/LICENSE +22 -0
- package/README.md +32 -2
- package/ai/SETUP.md +5 -0
- package/docs/catalog.md +85 -0
- package/forge.manifest.js +75 -0
- package/lib/compat.js +40 -0
- package/lib/docs/build.js +146 -0
- package/lib/install.js +51 -0
- package/lib/journal.js +40 -0
- package/lib/jsonConfig.js +33 -0
- package/lib/migration.js +35 -0
- package/lib/names.js +42 -0
- package/lib/patch.js +62 -0
- package/lib/paths.js +12 -0
- package/lib/project.js +48 -0
- package/lib/registry.js +99 -0
- package/package.json +46 -4
- package/platforms/react-native/CATALOG.md +391 -0
- package/platforms/react-native/ORIGIN.md +42 -0
- package/platforms/react-native/README.md +78 -0
- package/platforms/react-native/ai/AGENTS.md.hbs +36 -0
- package/platforms/react-native/ai/SETUP.md +89 -0
- package/platforms/react-native/compat/matrix.js +150 -0
- package/platforms/react-native/configs/babel.js +63 -0
- package/platforms/react-native/configs/forgeConfig.js +35 -0
- package/platforms/react-native/configs/jsConfigs.js +96 -0
- package/platforms/react-native/configs/metro.js +86 -0
- package/platforms/react-native/generators/add/generator.js +12 -0
- package/platforms/react-native/generators/add/run.js +64 -0
- package/platforms/react-native/generators/component/generator.js +75 -0
- package/platforms/react-native/generators/component/render.js +69 -0
- package/platforms/react-native/generators/component/templates/Common.tsx.hbs +13 -0
- package/platforms/react-native/generators/component/templates/index.ts.hbs +13 -0
- package/platforms/react-native/generators/component/templates/pm.ts.hbs +7 -0
- package/platforms/react-native/generators/component/templates/types.ts.hbs +3 -0
- package/platforms/react-native/generators/demo/files/api/app.http +8 -0
- package/platforms/react-native/generators/demo/files/api/environment/http-client.env.json +5 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.api.ts +18 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.dto.ts +15 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.service.ts +42 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.store.ts +26 -0
- package/platforms/react-native/generators/demo/files/entity/category/index.ts +2 -0
- package/platforms/react-native/generators/demo/files/entity/product/index.ts +2 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.api.ts +49 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.dto.ts +120 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.service.ts +139 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.store.ts +37 -0
- package/platforms/react-native/generators/demo/files/feature/product/components/Product.CategorySelect.tsx +36 -0
- package/platforms/react-native/generators/demo/files/feature/product/detail/Product.Detail.Screen.tsx +100 -0
- package/platforms/react-native/generators/demo/files/feature/product/detail/product.detail.service.ts +33 -0
- package/platforms/react-native/generators/demo/files/feature/product/filter/Product.Filter.Screen.tsx +59 -0
- package/platforms/react-native/generators/demo/files/feature/product/filter/product.filter.service.ts +78 -0
- package/platforms/react-native/generators/demo/files/feature/product/form/Product.Form.Screen.tsx +71 -0
- package/platforms/react-native/generators/demo/files/feature/product/form/product.form.service.ts +142 -0
- package/platforms/react-native/generators/demo/files/feature/product/index.ts +7 -0
- package/platforms/react-native/generators/demo/files/feature/product/list/Product.List.Item.tsx +34 -0
- package/platforms/react-native/generators/demo/files/feature/product/list/Product.List.Screen.tsx +106 -0
- package/platforms/react-native/generators/demo/files/feature/product/list/product.list.service.ts +47 -0
- package/platforms/react-native/generators/demo/files/feature/product/product.feature.ts +29 -0
- package/platforms/react-native/generators/demo/files/feature/product/product.hooks.ts +7 -0
- package/platforms/react-native/generators/demo/files/feature/product/search/Product.Search.Screen.tsx +82 -0
- package/platforms/react-native/generators/demo/files/feature/product/search/product.search.service.ts +97 -0
- package/platforms/react-native/generators/demo/files/navigation/navigation.product.ts +46 -0
- package/platforms/react-native/generators/demo/generator.js +93 -0
- package/platforms/react-native/generators/entity/generator.js +68 -0
- package/platforms/react-native/generators/feature/generator.js +224 -0
- package/platforms/react-native/generators/feature/render.js +163 -0
- package/platforms/react-native/generators/feature/templates/detail.screen.tsx.hbs +25 -0
- package/platforms/react-native/generators/feature/templates/detail.service.ts.hbs +14 -0
- package/platforms/react-native/generators/feature/templates/feature.ts.hbs +18 -0
- package/platforms/react-native/generators/feature/templates/filter.screen.tsx.hbs +17 -0
- package/platforms/react-native/generators/feature/templates/filter.service.ts.hbs +14 -0
- package/platforms/react-native/generators/feature/templates/form.screen.tsx.hbs +21 -0
- package/platforms/react-native/generators/feature/templates/form.service.ts.hbs +37 -0
- package/platforms/react-native/generators/feature/templates/hooks.ts.hbs +7 -0
- package/platforms/react-native/generators/feature/templates/index.ts.hbs +2 -0
- package/platforms/react-native/generators/feature/templates/list.item.tsx.hbs +16 -0
- package/platforms/react-native/generators/feature/templates/list.screen.tsx.hbs +34 -0
- package/platforms/react-native/generators/feature/templates/list.service.ts.hbs +15 -0
- package/platforms/react-native/generators/feature/templates/navigation.ts.hbs +12 -0
- package/platforms/react-native/generators/feature/templates/search.screen.tsx.hbs +24 -0
- package/platforms/react-native/generators/feature/templates/search.service.ts.hbs +13 -0
- package/platforms/react-native/generators/feature/templates/tab.tsx.hbs +8 -0
- package/platforms/react-native/generators/init/files/app/app.controller.ts +41 -0
- package/platforms/react-native/generators/init/files/app/app.error.ts +1 -0
- package/platforms/react-native/generators/init/files/app/app.store.ts +12 -0
- package/platforms/react-native/generators/init/files/app/index.ts +19 -0
- package/platforms/react-native/generators/init/files/app/splash/Onboarding.Screen.tsx +31 -0
- package/platforms/react-native/generators/init/files/app/splash/Splash.Screen.tsx +14 -0
- package/platforms/react-native/generators/init/files/app/tabs/home/Home.tab.tsx +24 -0
- package/platforms/react-native/generators/init/files/app/tabs/profile/Profile.tab.tsx +1 -0
- package/platforms/react-native/generators/init/files/configs/dev.ts.hbs +5 -0
- package/platforms/react-native/generators/init/files/configs/index.ts +4 -0
- package/platforms/react-native/generators/init/files/configs/prod.ts.hbs +5 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.api.ts +36 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.dto.ts +26 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.service.ts +94 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.session.store.ts +14 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.store.ts +20 -0
- package/platforms/react-native/generators/init/files/entity/auth/index.ts +2 -0
- package/platforms/react-native/generators/init/files/entity/index.ts +2 -0
- package/platforms/react-native/generators/init/files/feature/auth/auth.feature.ts +10 -0
- package/platforms/react-native/generators/init/files/feature/auth/auth.hooks.ts +7 -0
- package/platforms/react-native/generators/init/files/feature/auth/index.ts +1 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-in/SignIn.Screen.tsx +39 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-in/signIn.service.ts +54 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-up/SignUp.Screen.tsx +64 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-up/signUp.service.ts +73 -0
- package/platforms/react-native/generators/init/files/feature/feature.hooks.ts +15 -0
- package/platforms/react-native/generators/init/files/feature/index.ts +3 -0
- package/platforms/react-native/generators/init/files/feature/profile/Profile.Screen.tsx +52 -0
- package/platforms/react-native/generators/init/files/feature/profile/index.ts +1 -0
- package/platforms/react-native/generators/init/files/feature/profile/profile.feature.ts +18 -0
- package/platforms/react-native/generators/init/files/feature/profile/profile.hooks.ts +7 -0
- package/platforms/react-native/generators/init/files/index.ts +16 -0
- package/platforms/react-native/generators/init/files/navigation/index.ts +18 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.app.ts +58 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.features.ts +9 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.hooks.ts +5 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.tabs.ts +55 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.widgets.ts +23 -0
- package/platforms/react-native/generators/init/files/services/http/http.base.ts +69 -0
- package/platforms/react-native/generators/init/files/services/http/http.error.ts +10 -0
- package/platforms/react-native/generators/init/files/services/http/http.service.ts +24 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/index.ts +12 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/middleware.error.ts +36 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/middleware.registry.ts +3 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/middleware.token.ts +97 -0
- package/platforms/react-native/generators/init/files/services/index.ts +15 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/Common.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/box.pm.ts +111 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/box.types.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/index.ts +13 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/Common.tsx +50 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/Touchable.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/button.pm.ts +197 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/button.types.ts +22 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/button.utils.ts +16 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/index.ts +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Colours.tsx +50 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Common.tsx +38 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/ErrorText.tsx +11 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Input.tsx +115 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/InputArea.tsx +70 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Label.tsx +18 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Select.tsx +86 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/components/SecureTextEntry.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/form.error.ts +18 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/form.pm.ts +134 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/form.types.ts +59 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/index.ts +67 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/Common.tsx +11 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/grid.pm.ts +93 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/grid.types.ts +79 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/index.ts +13 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/Common.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/icons.pm.ts +74 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/icons.types.ts +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/index.ts +3 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/Loading.tsx +10 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/loading.hook.ts +5 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/loading.service.ts +22 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/loading.store.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/Common.tsx +87 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/Content.tsx +77 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/Header.tsx +80 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/HeaderTab.tsx +17 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/SafeAreaHOC.tsx +9 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/index.ts +22 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/Common.tsx +20 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/index.ts +13 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/text.pm.ts +55 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/text.types.ts +27 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/Common.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/index.ts +15 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/textInput.pm.ts +65 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/textInput.types.ts +16 -0
- package/platforms/react-native/generators/init/files/ui/components/ThemePicker/ThemePicker.tsx +92 -0
- package/platforms/react-native/generators/init/files/ui/components/ThemePicker/index.ts +1 -0
- package/platforms/react-native/generators/init/files/ui/components/index.ts +27 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/color.ts +19 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/index.ts +3 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/useLoading.hook.spec.tsx +202 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/useLoading.hook.ts +172 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/useStore.ts +34 -0
- package/platforms/react-native/generators/init/files/ui/fonts/font-icons.ttf +0 -0
- package/platforms/react-native/generators/init/files/ui/icons/font-icons.json +53 -0
- package/platforms/react-native/generators/init/files/ui/icons/logo.png +0 -0
- package/platforms/react-native/generators/init/files/ui/icons/logo.svg +304 -0
- package/platforms/react-native/generators/init/files/ui/icons/tabs/icon-1.png +0 -0
- package/platforms/react-native/generators/init/files/ui/icons/tabs/icon-2.png +0 -0
- package/platforms/react-native/generators/init/files/ui/theme/black/black.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/black/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/blue/blue.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/blue/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/green/green.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/green/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/index.ts +11 -0
- package/platforms/react-native/generators/init/files/ui/theme/pink/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/pink/pink.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/index.ts +23 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.color.ts +139 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.radius.ts +21 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.spacing.ts +24 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.ts +25 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.typography.ts +98 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/index.ts +4 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.color.base.ts +79 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.radius.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.spacing.ts +9 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.typography.ts +105 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.hooks.ts +7 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.meta.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.provider.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.service.ts +36 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.ts +27 -0
- package/platforms/react-native/generators/init/files/ui/widgets/index.ts +1 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Item.tsx +175 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Overlay.tsx +46 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Stack.tsx +75 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/index.ts +7 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.hooks.ts +18 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.service.ts +39 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.store.ts +59 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.types.ts +18 -0
- package/platforms/react-native/generators/init/files/ui/widgets/widgets.feature.ts +14 -0
- package/platforms/react-native/generators/init/files/utils/date.ts +11 -0
- package/platforms/react-native/generators/init/files/utils/index.ts +12 -0
- package/platforms/react-native/generators/init/files/utils/store.persistent.ts +103 -0
- package/platforms/react-native/generators/init/files/utils/store.registry.ts +14 -0
- package/platforms/react-native/generators/init/files/utils/string.ts +100 -0
- package/platforms/react-native/generators/init/generator.js +86 -0
- package/platforms/react-native/generators/init/kit.js +23 -0
- package/platforms/react-native/generators/init/navigators/expo-router/index.ts +18 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.app.ts +8 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.features.ts +9 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.hooks.ts +5 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.tabs.ts +7 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.widgets.ts +5 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/index.ts +18 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.app.ts +8 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.features.ts +9 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.hooks.ts +5 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.tabs.ts +7 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.widgets.ts +5 -0
- package/platforms/react-native/generators/setup/generator.js +225 -0
- package/platforms/react-native/generators/util/generator.js +12 -0
- package/platforms/react-native/platform.js +32 -0
- package/platforms/react-native/runtime.js +57 -0
- package/platforms/react-native/solutions/components/BottomSheet/README.md +29 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Common.tsx +120 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Content.tsx +57 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Context.tsx +22 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/FlatList.tsx +50 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Header.tsx +57 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Search.tsx +24 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/bottomSheet.constants.ts +13 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/bottomSheet.types.ts +31 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/index.ts +33 -0
- package/platforms/react-native/solutions/components/BottomSheet/solution.js +38 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/README.md +29 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/SelectPicker.tsx +47 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/Content.BottomSheet.tsx +22 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/DateTimePicker.BottomSheet.tsx +74 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/List.BottomSheet.tsx +62 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/solution.js +49 -0
- package/platforms/react-native/solutions/components/Calendar/README.md +29 -0
- package/platforms/react-native/solutions/components/Calendar/files/Common.tsx +16 -0
- package/platforms/react-native/solutions/components/Calendar/files/Context.tsx +466 -0
- package/platforms/react-native/solutions/components/Calendar/files/DayCell.tsx +89 -0
- package/platforms/react-native/solutions/components/Calendar/files/MonthView.tsx +41 -0
- package/platforms/react-native/solutions/components/Calendar/files/MonthYearOverlay.tsx +51 -0
- package/platforms/react-native/solutions/components/Calendar/files/SwipeablePeriod.tsx +44 -0
- package/platforms/react-native/solutions/components/Calendar/files/WeekDayTitles.tsx +31 -0
- package/platforms/react-native/solutions/components/Calendar/files/WeekView.tsx +40 -0
- package/platforms/react-native/solutions/components/Calendar/files/calendar.styles.ts +142 -0
- package/platforms/react-native/solutions/components/Calendar/files/calendar.types.ts +126 -0
- package/platforms/react-native/solutions/components/Calendar/files/calendar.utils.ts +143 -0
- package/platforms/react-native/solutions/components/Calendar/files/index.ts +40 -0
- package/platforms/react-native/solutions/components/Calendar/solution.js +38 -0
- package/platforms/react-native/solutions/components/Chart/README.md +29 -0
- package/platforms/react-native/solutions/components/Chart/files/Cilcular.tsx +140 -0
- package/platforms/react-native/solutions/components/Chart/files/index.ts +3 -0
- package/platforms/react-native/solutions/components/Chart/solution.js +38 -0
- package/platforms/react-native/solutions/components/CheckBox/README.md +29 -0
- package/platforms/react-native/solutions/components/CheckBox/files/Common.tsx +55 -0
- package/platforms/react-native/solutions/components/CheckBox/files/checkbox.pm.ts +71 -0
- package/platforms/react-native/solutions/components/CheckBox/files/index.ts +9 -0
- package/platforms/react-native/solutions/components/CheckBox/form/Checkbox.tsx +22 -0
- package/platforms/react-native/solutions/components/CheckBox/solution.js +57 -0
- package/platforms/react-native/solutions/components/DateTimePicker/README.md +29 -0
- package/platforms/react-native/solutions/components/DateTimePicker/files/DateTimePicker.tsx +44 -0
- package/platforms/react-native/solutions/components/DateTimePicker/solution.js +45 -0
- package/platforms/react-native/solutions/components/Image/README.md +29 -0
- package/platforms/react-native/solutions/components/Image/files/SVG.tsx +74 -0
- package/platforms/react-native/solutions/components/Image/files/image.pm.ts +25 -0
- package/platforms/react-native/solutions/components/Image/files/image.utils.ts +35 -0
- package/platforms/react-native/solutions/components/Image/files/index.ts +5 -0
- package/platforms/react-native/solutions/components/Image/solution.js +40 -0
- package/platforms/react-native/solutions/components/InputSecurity/README.md +29 -0
- package/platforms/react-native/solutions/components/InputSecurity/files/InputSecurity.ts +142 -0
- package/platforms/react-native/solutions/components/InputSecurity/solution.js +28 -0
- package/platforms/react-native/solutions/components/OTP/README.md +29 -0
- package/platforms/react-native/solutions/components/OTP/files/Item.tsx +16 -0
- package/platforms/react-native/solutions/components/OTP/files/Items.tsx +33 -0
- package/platforms/react-native/solutions/components/OTP/files/index.tsx +120 -0
- package/platforms/react-native/solutions/components/OTP/files/otp.pm.ts +30 -0
- package/platforms/react-native/solutions/components/OTP/solution.js +38 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/README.md +29 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/Circular.tsx +154 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/Linear.tsx +133 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/circular.pm.ts +34 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/index.ts +16 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/solution.js +39 -0
- package/platforms/react-native/solutions/components/Ruler/README.md +29 -0
- package/platforms/react-native/solutions/components/Ruler/files/Common.tsx +44 -0
- package/platforms/react-native/solutions/components/Ruler/files/Context.tsx +210 -0
- package/platforms/react-native/solutions/components/Ruler/files/Track.tsx +686 -0
- package/platforms/react-native/solutions/components/Ruler/files/Value.tsx +60 -0
- package/platforms/react-native/solutions/components/Ruler/files/index.ts +23 -0
- package/platforms/react-native/solutions/components/Ruler/files/ruler.constants.ts +70 -0
- package/platforms/react-native/solutions/components/Ruler/files/ruler.types.ts +98 -0
- package/platforms/react-native/solutions/components/Ruler/files/ruler.utils.ts +332 -0
- package/platforms/react-native/solutions/components/Ruler/solution.js +38 -0
- package/platforms/react-native/solutions/components/Section/README.md +29 -0
- package/platforms/react-native/solutions/components/Section/files/Common.tsx +144 -0
- package/platforms/react-native/solutions/components/Section/solution.js +37 -0
- package/platforms/react-native/solutions/components/Slider/README.md +29 -0
- package/platforms/react-native/solutions/components/Slider/files/Container.tsx +5 -0
- package/platforms/react-native/solutions/components/Slider/files/Content.tsx +44 -0
- package/platforms/react-native/solutions/components/Slider/files/Context.tsx +30 -0
- package/platforms/react-native/solutions/components/Slider/files/Pagination.Dot.tsx +61 -0
- package/platforms/react-native/solutions/components/Slider/files/index.ts +22 -0
- package/platforms/react-native/solutions/components/Slider/solution.js +38 -0
- package/platforms/react-native/solutions/components/Switch/README.md +29 -0
- package/platforms/react-native/solutions/components/Switch/files/Common.tsx +38 -0
- package/platforms/react-native/solutions/components/Switch/files/index.ts +9 -0
- package/platforms/react-native/solutions/components/Switch/files/switch.pm.ts +53 -0
- package/platforms/react-native/solutions/components/Switch/solution.js +38 -0
- package/platforms/react-native/solutions/install.js +97 -0
- package/platforms/react-native/solutions/services/firebase-core/README.md +31 -0
- package/platforms/react-native/solutions/services/firebase-core/files/index.ts +5 -0
- package/platforms/react-native/solutions/services/firebase-core/solution.js +39 -0
- package/platforms/react-native/solutions/services/firebase-messaging/README.md +31 -0
- package/platforms/react-native/solutions/services/firebase-messaging/files/index.ts +20 -0
- package/platforms/react-native/solutions/services/firebase-messaging/solution.js +42 -0
- package/platforms/react-native/solutions/utils/permissions/README.md +29 -0
- package/platforms/react-native/solutions/utils/permissions/files/permissions.ts +10 -0
- package/platforms/react-native/solutions/utils/permissions/solution.js +32 -0
- package/presets/react-native-fsd/index.js +25 -0
- package/shared/generators/entity/render.js +88 -0
- package/shared/generators/entity/templates/crud/api.ts.hbs +36 -0
- package/shared/generators/entity/templates/crud/dto.ts.hbs +36 -0
- package/shared/generators/entity/templates/crud/service.ts.hbs +73 -0
- package/shared/generators/entity/templates/crud/store.ts.hbs +27 -0
- package/shared/generators/entity/templates/index.ts.hbs +2 -0
- package/shared/generators/entity/templates/simple/api.ts.hbs +16 -0
- package/shared/generators/entity/templates/simple/dto.ts.hbs +5 -0
- package/shared/generators/entity/templates/simple/service.ts.hbs +26 -0
- package/shared/generators/entity/templates/simple/store.ts.hbs +18 -0
- package/shared/solutions/utils/date/README.md +29 -0
- package/shared/solutions/utils/date/files/date.ts +11 -0
- package/shared/solutions/utils/date/solution.js +27 -0
- package/shared/solutions/utils/string/README.md +29 -0
- package/shared/solutions/utils/string/files/string.ts +100 -0
- package/shared/solutions/utils/string/solution.js +27 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Entity, Pagination } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { ProductApi } from './product.api';
|
|
4
|
+
import { ProductCreatePayload, ProductData, ProductListQuery, ProductUpdatePayload } from './product.dto';
|
|
5
|
+
import { ProductIdsIndex, ProductStore } from './product.store';
|
|
6
|
+
|
|
7
|
+
export type { ProductIdsIndex } from './product.store';
|
|
8
|
+
|
|
9
|
+
@Entity.Decorators.Service()
|
|
10
|
+
export class ProductService {
|
|
11
|
+
pagination: Record<ProductIdsIndex, Pagination.OffsetPagination>;
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
private api: ProductApi,
|
|
15
|
+
readonly store: ProductStore,
|
|
16
|
+
) {
|
|
17
|
+
this.pagination = {
|
|
18
|
+
list: new Pagination.OffsetPagination(this.store, 'list', { limit: 20, offset: 0 }),
|
|
19
|
+
search: new Pagination.OffsetPagination(this.store, 'search', { limit: 20, offset: 0 }),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getById = (id: string) => this.store.getByPath(`product.${String(id)}`) as ProductData | undefined;
|
|
24
|
+
|
|
25
|
+
getListIds = (index: ProductIdsIndex = 'list') =>
|
|
26
|
+
(this.store.getByPath(`ids.${index}`) as string[] | undefined) ?? [];
|
|
27
|
+
|
|
28
|
+
getQuery = (index: ProductIdsIndex): ProductListQuery =>
|
|
29
|
+
(this.store.getByPath(`query.${index}`) as ProductListQuery | undefined) ?? {};
|
|
30
|
+
|
|
31
|
+
hasQuery = (index: ProductIdsIndex) => {
|
|
32
|
+
const query = this.getQuery(index);
|
|
33
|
+
return Boolean(
|
|
34
|
+
query.title ||
|
|
35
|
+
query.price != null ||
|
|
36
|
+
query.price_min != null ||
|
|
37
|
+
query.price_max != null ||
|
|
38
|
+
query.categoryId != null,
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
setQuery = (index: ProductIdsIndex, params?: Record<string, unknown>) => {
|
|
43
|
+
this.store.set(`query.${index}`, ProductListQuery.transform(params));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
clearQuery = (index: ProductIdsIndex) => {
|
|
47
|
+
this.store.set(`query.${index}`, {});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
upsertToStore = (data: ProductData) => {
|
|
51
|
+
this.store.set(`product.${String(data.id)}`, data);
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
private upsertEntities(items: ProductData[]) {
|
|
56
|
+
return items.map(item => {
|
|
57
|
+
this.upsertToStore(item);
|
|
58
|
+
return String(item.id);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private writeIds(index: ProductIdsIndex, incoming: string[], mode: Pagination.ListMergeMode) {
|
|
63
|
+
this.store.set(`ids.${index}`, Pagination.mergeIds(this.getListIds(index), incoming, mode));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private appendToList = (id: string) => {
|
|
67
|
+
const list = this.getListIds('list');
|
|
68
|
+
if (!list.includes(id)) {
|
|
69
|
+
this.store.set('ids.list', [id, ...list]);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
private removeFromIndexes = (id: string) => {
|
|
74
|
+
(['list', 'search'] as ProductIdsIndex[]).forEach(index => {
|
|
75
|
+
this.store.set(
|
|
76
|
+
`ids.${index}`,
|
|
77
|
+
this.getListIds(index).filter(itemId => itemId !== id),
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
async fetchList(
|
|
83
|
+
index: ProductIdsIndex = 'list',
|
|
84
|
+
options?: { signal?: AbortSignal; mode?: Pagination.ListMergeMode },
|
|
85
|
+
) {
|
|
86
|
+
const mode = options?.mode ?? 'replace';
|
|
87
|
+
const slot = this.pagination[index];
|
|
88
|
+
|
|
89
|
+
if (mode === 'replace') {
|
|
90
|
+
slot.reset();
|
|
91
|
+
} else if (!slot.hasMore) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const query = this.getQuery(index);
|
|
96
|
+
const pagination = slot.params();
|
|
97
|
+
const { data } = await this.api.list(
|
|
98
|
+
{ ...query, ...pagination },
|
|
99
|
+
{
|
|
100
|
+
signal: options?.signal,
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
|
+
slot.apply({ items: data });
|
|
104
|
+
slot.next();
|
|
105
|
+
this.writeIds(index, this.upsertEntities(data), mode);
|
|
106
|
+
return data;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async fetchById(id: string, options?: { force?: boolean; signal?: AbortSignal }) {
|
|
110
|
+
if (!options?.force) {
|
|
111
|
+
const cached = this.getById(id);
|
|
112
|
+
if (cached) return cached;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const { data } = await this.api.getById(id, { signal: options?.signal });
|
|
116
|
+
this.upsertToStore(data);
|
|
117
|
+
return data;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async create(payload: ProductCreatePayload) {
|
|
121
|
+
const { data } = await this.api.create(payload);
|
|
122
|
+
this.upsertToStore(data);
|
|
123
|
+
this.appendToList(String(data.id));
|
|
124
|
+
return data;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async update(payload: ProductUpdatePayload) {
|
|
128
|
+
const { data } = await this.api.update(payload);
|
|
129
|
+
this.upsertToStore(data);
|
|
130
|
+
return data;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async remove(id: string | number) {
|
|
134
|
+
await this.api.delete(id);
|
|
135
|
+
const key = String(id);
|
|
136
|
+
this.store.delete(`product.${key}`);
|
|
137
|
+
this.removeFromIndexes(key);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Entity, Pagination, Store } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { StoreRegistry } from '@utils';
|
|
4
|
+
|
|
5
|
+
import { ProductData, ProductListQuery } from './product.dto';
|
|
6
|
+
|
|
7
|
+
export type ProductIdsIndex = 'list' | 'search';
|
|
8
|
+
|
|
9
|
+
export type ProductStoreState = {
|
|
10
|
+
product: Record<string, ProductData>;
|
|
11
|
+
ids: Record<ProductIdsIndex, string[]>;
|
|
12
|
+
pagination: Record<ProductIdsIndex, Pagination.OffsetState | undefined>;
|
|
13
|
+
query: Record<ProductIdsIndex, ProductListQuery>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
@Entity.Decorators.Store()
|
|
17
|
+
export class ProductStore extends Store.Common<ProductStoreState> {
|
|
18
|
+
constructor(private registry: StoreRegistry) {
|
|
19
|
+
super({
|
|
20
|
+
product: {},
|
|
21
|
+
ids: {
|
|
22
|
+
list: [],
|
|
23
|
+
search: [],
|
|
24
|
+
},
|
|
25
|
+
pagination: {
|
|
26
|
+
list: undefined,
|
|
27
|
+
search: undefined,
|
|
28
|
+
},
|
|
29
|
+
query: {
|
|
30
|
+
list: {},
|
|
31
|
+
search: {},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
registry.register(this);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Button, Grid, useStore } from '@components';
|
|
4
|
+
import { useProductFeature } from '@feature/product/product.hooks';
|
|
5
|
+
|
|
6
|
+
export default function ProductCategorySelect({
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
}: {
|
|
10
|
+
value?: number;
|
|
11
|
+
onChange?: (value?: number) => void;
|
|
12
|
+
}) {
|
|
13
|
+
const feature = useProductFeature();
|
|
14
|
+
const ids = useStore(feature.categoryService.store, 'ids.list') ?? [];
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Grid row style={{ flexWrap: 'wrap' }}>
|
|
18
|
+
{ids.map(id => (
|
|
19
|
+
<CategoryOption key={id} id={id} selected={String(value) === id} onPress={() => onChange?.(Number(id))} />
|
|
20
|
+
))}
|
|
21
|
+
</Grid>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function CategoryOption({ id, selected, onPress }: { id: string; selected: boolean; onPress: () => void }) {
|
|
26
|
+
const feature = useProductFeature();
|
|
27
|
+
const category = useStore(feature.categoryService.store, `category.${id}`);
|
|
28
|
+
|
|
29
|
+
if (!category) return null;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Button type={selected ? 'filled' : 'text'} color="primary" onPress={onPress}>
|
|
33
|
+
{category.name}
|
|
34
|
+
</Button>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ProcessBuilder } from '@effijs/common';
|
|
2
|
+
import { useNavigation } from '@effijs/navigation-react-native';
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
|
+
import { StyleSheet } from 'react-native';
|
|
5
|
+
|
|
6
|
+
import { Button, Grid, Image, Screen, Text, useStore } from '@components';
|
|
7
|
+
import { useProcess } from '@feature/feature.hooks';
|
|
8
|
+
import { useProductFeature } from '@feature/product/product.hooks';
|
|
9
|
+
import type { ProductDetailScreenProps } from '@navigation/navigation.product';
|
|
10
|
+
|
|
11
|
+
export default function ProductDetailScreen({ id }: ProductDetailScreenProps) {
|
|
12
|
+
const { close } = useNavigation();
|
|
13
|
+
const feature = useProductFeature();
|
|
14
|
+
const item = useStore(feature.store, `product.${id}`);
|
|
15
|
+
const process = useProcess(`product-${id}`);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
feature.detail.load(id).id(`product-${id}`).run();
|
|
19
|
+
return () => {
|
|
20
|
+
ProcessBuilder.getProcess(`product-${id}`).abort();
|
|
21
|
+
};
|
|
22
|
+
}, [id, feature.detail]);
|
|
23
|
+
|
|
24
|
+
if (process?.loading && !item) {
|
|
25
|
+
return (
|
|
26
|
+
<Screen>
|
|
27
|
+
<Screen.Header title="Product" />
|
|
28
|
+
<Screen.Content sa-b>
|
|
29
|
+
<Grid mh-s mt-l>
|
|
30
|
+
<Text body-m color="onSurfaceVariant">
|
|
31
|
+
Loading...
|
|
32
|
+
</Text>
|
|
33
|
+
</Grid>
|
|
34
|
+
</Screen.Content>
|
|
35
|
+
</Screen>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!item) {
|
|
40
|
+
return (
|
|
41
|
+
<Screen>
|
|
42
|
+
<Screen.Header title="Product" />
|
|
43
|
+
<Screen.Content sa-b>
|
|
44
|
+
<Grid mh-s mt-l>
|
|
45
|
+
<Text body-m color="onSurfaceVariant">
|
|
46
|
+
Not found
|
|
47
|
+
</Text>
|
|
48
|
+
</Grid>
|
|
49
|
+
</Screen.Content>
|
|
50
|
+
</Screen>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const image = item.images?.[0];
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Screen>
|
|
58
|
+
<Screen.Header title="Product" />
|
|
59
|
+
<Screen.Content sa-b>
|
|
60
|
+
<Grid mh-s gap-m>
|
|
61
|
+
{image ? <Image.Native source={{ uri: image }} style={styles.cover} /> : null}
|
|
62
|
+
<Text display-s color="outline">
|
|
63
|
+
{item.title}
|
|
64
|
+
</Text>
|
|
65
|
+
<Text body-m color="onSurfaceVariant">
|
|
66
|
+
${item.price}
|
|
67
|
+
</Text>
|
|
68
|
+
{item.category?.name ? (
|
|
69
|
+
<Text body-s color="onSurfaceVariant">
|
|
70
|
+
{item.category.name}
|
|
71
|
+
</Text>
|
|
72
|
+
) : null}
|
|
73
|
+
<Text body-m color="outline">
|
|
74
|
+
{item.description}
|
|
75
|
+
</Text>
|
|
76
|
+
<Button type="filled" color="primary" mt-l onPress={() => feature.detail.openEdit(item)}>
|
|
77
|
+
Edit
|
|
78
|
+
</Button>
|
|
79
|
+
<Button
|
|
80
|
+
type="outlined"
|
|
81
|
+
color="error"
|
|
82
|
+
mt-s
|
|
83
|
+
onPress={() =>
|
|
84
|
+
feature.detail
|
|
85
|
+
.remove(id)
|
|
86
|
+
.id(`product-remove`)
|
|
87
|
+
.onDone(() => close?.())
|
|
88
|
+
.run()
|
|
89
|
+
}>
|
|
90
|
+
Delete
|
|
91
|
+
</Button>
|
|
92
|
+
</Grid>
|
|
93
|
+
</Screen.Content>
|
|
94
|
+
</Screen>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const styles = StyleSheet.create({
|
|
99
|
+
cover: { width: '100%', height: 220, borderRadius: 12 },
|
|
100
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Entity, ProcessBuilder as PB } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { ProductData } from '@entity/product/product.dto';
|
|
4
|
+
import { ProductService } from '@entity/product/product.service';
|
|
5
|
+
import { Navigation } from '@navigation';
|
|
6
|
+
|
|
7
|
+
@Entity.Decorators.Service()
|
|
8
|
+
export class ProductDetailService {
|
|
9
|
+
constructor(
|
|
10
|
+
private navigation: Navigation,
|
|
11
|
+
private productService: ProductService,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
openEdit(product: ProductData) {
|
|
15
|
+
return this.navigation.features.product.form({ mode: 'edit', data: product });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
load = (id: string) =>
|
|
19
|
+
PB.process
|
|
20
|
+
.flow(
|
|
21
|
+
PB.step(async (_, { signal }) => {
|
|
22
|
+
await this.productService.fetchById(id, { force: true, signal });
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
25
|
+
.concurrent('abort');
|
|
26
|
+
|
|
27
|
+
remove = (id: string) =>
|
|
28
|
+
PB.process.flow(
|
|
29
|
+
PB.step(async () => {
|
|
30
|
+
await this.productService.remove(id);
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useNavigation } from '@effijs/navigation-react-native';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
import { BottomSheet, Button, Form, Grid } from '@components';
|
|
5
|
+
import ProductCategorySelect from '@feature/product/components/Product.CategorySelect';
|
|
6
|
+
import { useProductFeature } from '@feature/product/product.hooks';
|
|
7
|
+
import type { ProductFilterScreenProps } from '@navigation/navigation.product';
|
|
8
|
+
|
|
9
|
+
import { ProductFilterService } from './product.filter.service';
|
|
10
|
+
|
|
11
|
+
export default function ProductFilterScreen(_props: ProductFilterScreenProps) {
|
|
12
|
+
const { close } = useNavigation();
|
|
13
|
+
const feature = useProductFeature();
|
|
14
|
+
const service = Form.useFormService(ProductFilterService, () =>
|
|
15
|
+
ProductFilterService.prepare(feature.service.getQuery('list')),
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
service.loadCategories().id('category-list').run();
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<BottomSheet onClose={close} maxHeight="90%">
|
|
24
|
+
<BottomSheet.Header title="Filter" trailingActions={['close']} />
|
|
25
|
+
<BottomSheet.Content>
|
|
26
|
+
<Form service={service}>
|
|
27
|
+
<Form.Item name="price_min">
|
|
28
|
+
<Form.Element.Input label="Min price" keyboardType="numeric" />
|
|
29
|
+
</Form.Item>
|
|
30
|
+
<Form.Item name="price_max">
|
|
31
|
+
<Form.Element.Input label="Max price" keyboardType="numeric" />
|
|
32
|
+
</Form.Item>
|
|
33
|
+
<Grid mt-s mb-s>
|
|
34
|
+
<Form.Element.Label>Category</Form.Element.Label>
|
|
35
|
+
<Form.Item name="categoryId">
|
|
36
|
+
<ProductCategorySelect />
|
|
37
|
+
</Form.Item>
|
|
38
|
+
</Grid>
|
|
39
|
+
<Button
|
|
40
|
+
type="filled"
|
|
41
|
+
color="primary"
|
|
42
|
+
mt-l
|
|
43
|
+
mb-l
|
|
44
|
+
onPress={() =>
|
|
45
|
+
service
|
|
46
|
+
.apply()
|
|
47
|
+
.onDone(() => {
|
|
48
|
+
feature.list.load().id('product-list').run();
|
|
49
|
+
close?.();
|
|
50
|
+
})
|
|
51
|
+
.run()
|
|
52
|
+
}>
|
|
53
|
+
Apply
|
|
54
|
+
</Button>
|
|
55
|
+
</Form>
|
|
56
|
+
</BottomSheet.Content>
|
|
57
|
+
</BottomSheet>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Entity, FormStore, ProcessBuilder as PB, Validator } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { FormError } from '@components/Form/form.error';
|
|
4
|
+
import { CategoryService } from '@entity/category/category.service';
|
|
5
|
+
import { ProductListQuery } from '@entity/product/product.dto';
|
|
6
|
+
import { ProductService } from '@entity/product/product.service';
|
|
7
|
+
import { Navigation } from '@navigation';
|
|
8
|
+
|
|
9
|
+
@Validator.Decorators.Options({ skipMissingProperties: true })
|
|
10
|
+
class ProductFilterData extends Validator.WithValidator {
|
|
11
|
+
@Validator.Decorators.Property()
|
|
12
|
+
price_min?: string;
|
|
13
|
+
|
|
14
|
+
@Validator.Decorators.Property()
|
|
15
|
+
price_max?: string;
|
|
16
|
+
|
|
17
|
+
@Validator.Decorators.Property()
|
|
18
|
+
categoryId?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Entity.Decorators.Service()
|
|
22
|
+
export class ProductFilterService extends FormStore.FormStoreService<ProductFilterData> {
|
|
23
|
+
constructor(
|
|
24
|
+
private productService: ProductService,
|
|
25
|
+
private categoryService: CategoryService,
|
|
26
|
+
private navigation: Navigation,
|
|
27
|
+
) {
|
|
28
|
+
super();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static prepare(query: ProductListQuery = {}): Partial<ProductFilterData> {
|
|
32
|
+
return {
|
|
33
|
+
price_min: query.price_min != null ? String(query.price_min) : '',
|
|
34
|
+
price_max: query.price_max != null ? String(query.price_max) : '',
|
|
35
|
+
categoryId: query.categoryId,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
init(initial?: Partial<ProductFilterData>) {
|
|
40
|
+
super.init({
|
|
41
|
+
price_min: '',
|
|
42
|
+
price_max: '',
|
|
43
|
+
...(initial || {}),
|
|
44
|
+
});
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
loadCategories = () =>
|
|
49
|
+
PB.process
|
|
50
|
+
.flow(
|
|
51
|
+
PB.step(async (_, { signal }) => {
|
|
52
|
+
await this.categoryService.fetchList({ signal });
|
|
53
|
+
}),
|
|
54
|
+
)
|
|
55
|
+
.concurrent('join')
|
|
56
|
+
.onError(({ error }) => {
|
|
57
|
+
if (error?.message) {
|
|
58
|
+
this.navigation.widgets.showToast({ type: 'message', title: error.message });
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
apply = () =>
|
|
63
|
+
PB.process
|
|
64
|
+
.flow(
|
|
65
|
+
PB.step(() => {
|
|
66
|
+
const { error, data } = this.validate((raw, options) => ProductFilterData.validate(raw, options));
|
|
67
|
+
if (error) {
|
|
68
|
+
throw new FormError('Please fill required fields', error);
|
|
69
|
+
}
|
|
70
|
+
this.productService.setQuery('list', data);
|
|
71
|
+
}),
|
|
72
|
+
)
|
|
73
|
+
.onError(({ error }) => {
|
|
74
|
+
if (error?.message) {
|
|
75
|
+
this.navigation.widgets.showToast({ type: 'message', title: error.message });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
package/platforms/react-native/generators/demo/files/feature/product/form/Product.Form.Screen.tsx
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ProcessBuilder as PB } from '@effijs/common';
|
|
2
|
+
import { useNavigation } from '@effijs/navigation-react-native';
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
import { Button, Form, Grid, Screen, Text } from '@components';
|
|
6
|
+
import ProductCategorySelect from '@feature/product/components/Product.CategorySelect';
|
|
7
|
+
import type { ProductFormScreenProps } from '@navigation/navigation.product';
|
|
8
|
+
|
|
9
|
+
import { ProductFormService } from './product.form.service';
|
|
10
|
+
|
|
11
|
+
export default function ProductFormScreen({ mode, data }: ProductFormScreenProps) {
|
|
12
|
+
const { close } = useNavigation();
|
|
13
|
+
const service = Form.useFormService(ProductFormService, () => {
|
|
14
|
+
if (mode === 'create') {
|
|
15
|
+
return ProductFormService.prepareCreate();
|
|
16
|
+
}
|
|
17
|
+
return ProductFormService.prepareFromEntity(data);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
service.loadCategories().id('category-list').run();
|
|
22
|
+
return () => {
|
|
23
|
+
PB.getProcess('product-form').abort();
|
|
24
|
+
};
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Screen>
|
|
29
|
+
<Screen.Header title={service.mode === 'edit' ? 'Edit product' : 'New product'} />
|
|
30
|
+
<Screen.Content sa-b>
|
|
31
|
+
<Grid mh-s>
|
|
32
|
+
<Form service={service}>
|
|
33
|
+
<Form.Item name="title">
|
|
34
|
+
<Form.Element.Input label="Title" autoCapitalize="sentences" />
|
|
35
|
+
</Form.Item>
|
|
36
|
+
<Form.Item name="price">
|
|
37
|
+
<Form.Element.Input label="Price" keyboardType="numeric" />
|
|
38
|
+
</Form.Item>
|
|
39
|
+
<Form.Item name="description">
|
|
40
|
+
<Form.Element.InputArea label="Description" />
|
|
41
|
+
</Form.Item>
|
|
42
|
+
<Grid mt-s mb-s>
|
|
43
|
+
<Text body-s color="onSurfaceVariant" mb-s>
|
|
44
|
+
Category
|
|
45
|
+
</Text>
|
|
46
|
+
<Form.Item name="categoryId">
|
|
47
|
+
<ProductCategorySelect />
|
|
48
|
+
</Form.Item>
|
|
49
|
+
</Grid>
|
|
50
|
+
<Form.Item name="images">
|
|
51
|
+
<Form.Element.Input label="Image URL" autoCapitalize="none" />
|
|
52
|
+
</Form.Item>
|
|
53
|
+
<Button
|
|
54
|
+
type="filled"
|
|
55
|
+
color="primary"
|
|
56
|
+
mt-l
|
|
57
|
+
onPress={() =>
|
|
58
|
+
service
|
|
59
|
+
.submit()
|
|
60
|
+
.id('product-form')
|
|
61
|
+
.onDone(() => close?.())
|
|
62
|
+
.run()
|
|
63
|
+
}>
|
|
64
|
+
Save
|
|
65
|
+
</Button>
|
|
66
|
+
</Form>
|
|
67
|
+
</Grid>
|
|
68
|
+
</Screen.Content>
|
|
69
|
+
</Screen>
|
|
70
|
+
);
|
|
71
|
+
}
|
package/platforms/react-native/generators/demo/files/feature/product/form/product.form.service.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Entity, FormStore, ProcessBuilder as PB, Validator } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { FormError } from '@components/Form/form.error';
|
|
4
|
+
import { CategoryService } from '@entity/category/category.service';
|
|
5
|
+
import { ProductCreatePayload, ProductData, ProductUpdatePayload } from '@entity/product/product.dto';
|
|
6
|
+
import { ProductService } from '@entity/product/product.service';
|
|
7
|
+
import { Navigation } from '@navigation';
|
|
8
|
+
import { HttpError } from '@services/http/http.error';
|
|
9
|
+
|
|
10
|
+
const PLACEHOLDER_IMAGE = 'https://placehold.co/600x400';
|
|
11
|
+
|
|
12
|
+
@Validator.Decorators.Options({ skipMissingProperties: true })
|
|
13
|
+
class ProductFormData extends Validator.WithValidator {
|
|
14
|
+
@Validator.Decorators.IsDefined('Title is required')
|
|
15
|
+
title!: string;
|
|
16
|
+
|
|
17
|
+
@Validator.Decorators.IsDefined('Price is required')
|
|
18
|
+
price!: string;
|
|
19
|
+
|
|
20
|
+
@Validator.Decorators.IsDefined('Description is required')
|
|
21
|
+
description!: string;
|
|
22
|
+
|
|
23
|
+
@Validator.Decorators.IsDefined('Category is required')
|
|
24
|
+
categoryId!: number;
|
|
25
|
+
|
|
26
|
+
images!: string;
|
|
27
|
+
id?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Entity.Decorators.Service()
|
|
31
|
+
export class ProductFormService extends FormStore.FormStoreService<ProductFormData> {
|
|
32
|
+
mode: 'create' | 'edit' = 'create';
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
private productService: ProductService,
|
|
36
|
+
private categoryService: CategoryService,
|
|
37
|
+
private navigation: Navigation,
|
|
38
|
+
) {
|
|
39
|
+
super();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static prepareCreate(): Partial<ProductFormData> & { mode: 'create' } {
|
|
43
|
+
return {
|
|
44
|
+
mode: 'create',
|
|
45
|
+
title: '',
|
|
46
|
+
price: '',
|
|
47
|
+
description: '',
|
|
48
|
+
images: PLACEHOLDER_IMAGE,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static prepareFromEntity(entity: ProductData): Partial<ProductFormData> & { mode: 'edit' } {
|
|
53
|
+
return {
|
|
54
|
+
mode: 'edit',
|
|
55
|
+
id: entity.id,
|
|
56
|
+
title: entity.title,
|
|
57
|
+
price: String(entity.price ?? ''),
|
|
58
|
+
description: entity.description,
|
|
59
|
+
categoryId: entity.category?.id,
|
|
60
|
+
images: entity.images?.[0] || PLACEHOLDER_IMAGE,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
init(initial?: Partial<ProductFormData> & { mode?: 'create' | 'edit' }) {
|
|
65
|
+
this.mode = initial?.mode ?? (initial?.id ? 'edit' : 'create');
|
|
66
|
+
|
|
67
|
+
super.init({
|
|
68
|
+
title: '',
|
|
69
|
+
price: '',
|
|
70
|
+
description: '',
|
|
71
|
+
images: PLACEHOLDER_IMAGE,
|
|
72
|
+
...(initial || {}),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private toCreatePayload(formData: ProductFormData) {
|
|
79
|
+
return ProductCreatePayload.transform({
|
|
80
|
+
title: formData.title,
|
|
81
|
+
price: formData.price,
|
|
82
|
+
description: formData.description,
|
|
83
|
+
categoryId: formData.categoryId,
|
|
84
|
+
images: formData.images?.trim() ? [formData.images.trim()] : [],
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private toUpdatePayload(formData: ProductFormData) {
|
|
89
|
+
return ProductUpdatePayload.transform({
|
|
90
|
+
id: formData.id,
|
|
91
|
+
title: formData.title,
|
|
92
|
+
price: formData.price,
|
|
93
|
+
description: formData.description,
|
|
94
|
+
categoryId: formData.categoryId,
|
|
95
|
+
images: formData.images?.trim() ? [formData.images.trim()] : [],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
loadCategories = () =>
|
|
100
|
+
PB.process
|
|
101
|
+
.flow(
|
|
102
|
+
PB.step(async (_, { signal }) => {
|
|
103
|
+
await this.categoryService.fetchList({ signal });
|
|
104
|
+
}),
|
|
105
|
+
)
|
|
106
|
+
.concurrent('join')
|
|
107
|
+
.onError(({ error }) => {
|
|
108
|
+
if (error?.message) {
|
|
109
|
+
this.navigation.widgets.showToast({ type: 'message', title: error.message });
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
submit = () =>
|
|
114
|
+
PB.process
|
|
115
|
+
.flow(
|
|
116
|
+
PB.step(() => {
|
|
117
|
+
const { error, data } = this.validate((raw, options) => ProductFormData.validate(raw, options));
|
|
118
|
+
if (error) {
|
|
119
|
+
throw new FormError('Please fill required fields', error);
|
|
120
|
+
}
|
|
121
|
+
return { formData: data };
|
|
122
|
+
}),
|
|
123
|
+
PB.step(async ({ formData }) => {
|
|
124
|
+
if (this.mode === 'create') {
|
|
125
|
+
await this.productService.create(this.toCreatePayload(formData));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
await this.productService.update(this.toUpdatePayload(formData));
|
|
129
|
+
}),
|
|
130
|
+
)
|
|
131
|
+
.onError(({ error }) => {
|
|
132
|
+
if (error instanceof HttpError) {
|
|
133
|
+
Object.entries(error.data || {}).forEach(([path, e]) => {
|
|
134
|
+
this.store.error.set(path, e);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (error?.message) {
|
|
139
|
+
this.navigation.widgets.showToast({ type: 'message', title: error.message });
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|