@shopify/shop-minis-cli 0.0.37 → 0.0.82
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/.eslintrc.cjs +78 -0
- package/.vscode/extensions.json +3 -0
- package/.vscode/launch.json +29 -0
- package/.vscode/settings.json +8 -0
- package/.vscode/shop-minis-cli.code-workspace +8 -0
- package/build/commands/cancel-submission/cancel-submission.d.ts +1 -0
- package/build/commands/cancel-submission/cancel-submission.js +57 -0
- package/build/commands/cancel-submission/cancel-submission.js.map +1 -0
- package/build/commands/cancel-submission/index.d.ts +2 -0
- package/build/commands/cancel-submission/index.js +18 -0
- package/build/commands/cancel-submission/index.js.map +1 -0
- package/build/commands/cancel-submission/types.d.ts +3 -0
- package/build/commands/cancel-submission/types.js +2 -0
- package/build/commands/cancel-submission/types.js.map +1 -0
- package/build/commands/check-submission/index.d.ts +2 -0
- package/build/commands/check-submission/index.js +55 -0
- package/build/commands/check-submission/index.js.map +1 -0
- package/build/commands/check-submission/types.d.ts +3 -0
- package/build/commands/check-submission/types.js +2 -0
- package/build/commands/check-submission/types.js.map +1 -0
- package/build/commands/codemod/index.d.ts +3 -0
- package/build/commands/codemod/index.js +47 -0
- package/build/commands/codemod/index.js.map +1 -0
- package/build/commands/codemod/releases/index.d.ts +7 -0
- package/build/commands/codemod/releases/index.js +58 -0
- package/build/commands/codemod/releases/index.js.map +1 -0
- package/build/commands/codemod/releases/types.d.ts +9 -0
- package/build/commands/codemod/releases/types.js +2 -0
- package/build/commands/codemod/releases/types.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-42/index.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-42/index.js +46 -0
- package/build/commands/codemod/releases/v0-0-42/index.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-42/reset-files.d.ts +7 -0
- package/build/commands/codemod/releases/v0-0-42/reset-files.js +83 -0
- package/build/commands/codemod/releases/v0-0-42/reset-files.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-43.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-43.js +32 -0
- package/build/commands/codemod/releases/v0-0-43.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-44.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-44.js +214 -0
- package/build/commands/codemod/releases/v0-0-44.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-45.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-45.js +23 -0
- package/build/commands/codemod/releases/v0-0-45.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-50.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-50.js +34 -0
- package/build/commands/codemod/releases/v0-0-50.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-54.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-54.js +70 -0
- package/build/commands/codemod/releases/v0-0-54.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-56.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-56.js +48 -0
- package/build/commands/codemod/releases/v0-0-56.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-57.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-57.js +41 -0
- package/build/commands/codemod/releases/v0-0-57.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-58.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-58.js +68 -0
- package/build/commands/codemod/releases/v0-0-58.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-61.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-61.js +30 -0
- package/build/commands/codemod/releases/v0-0-61.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-63.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-63.js +42 -0
- package/build/commands/codemod/releases/v0-0-63.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-64.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-64.js +47 -0
- package/build/commands/codemod/releases/v0-0-64.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-75.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-75.js +30 -0
- package/build/commands/codemod/releases/v0-0-75.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-76.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-76.js +32 -0
- package/build/commands/codemod/releases/v0-0-76.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-77.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-77.js +39 -0
- package/build/commands/codemod/releases/v0-0-77.js.map +1 -0
- package/build/commands/codemod/releases/v0-0-79.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-79.js +35 -0
- package/build/commands/codemod/releases/v0-0-79.js.map +1 -0
- package/build/commands/config.d.ts +14 -0
- package/build/commands/config.js +42 -0
- package/build/commands/config.js.map +1 -0
- package/build/commands/create-mini/index.js +84 -68
- package/build/commands/create-mini/index.js.map +1 -1
- package/build/commands/create-mini/utils/template-app.d.ts +1 -1
- package/build/commands/create-mini/utils/template-app.js +38 -38
- package/build/commands/create-mini/utils/template-app.js.map +1 -1
- package/build/commands/dev/index.d.ts +3 -0
- package/build/commands/dev/index.js +51 -22
- package/build/commands/dev/index.js.map +1 -1
- package/build/commands/dev/utils/android.d.ts +6 -4
- package/build/commands/dev/utils/android.js +55 -67
- package/build/commands/dev/utils/android.js.map +1 -1
- package/build/commands/dev/utils/binaries.d.ts +2 -80
- package/build/commands/dev/utils/binaries.js +10 -166
- package/build/commands/dev/utils/binaries.js.map +1 -1
- package/build/commands/dev/utils/build-type.d.ts +2 -0
- package/build/commands/dev/utils/build-type.js +14 -0
- package/build/commands/dev/utils/build-type.js.map +1 -0
- package/build/commands/dev/utils/deeplink.d.ts +3 -3
- package/build/commands/dev/utils/deeplink.js +13 -18
- package/build/commands/dev/utils/deeplink.js.map +1 -1
- package/build/commands/dev/utils/interactive-terminal.d.ts +4 -2
- package/build/commands/dev/utils/interactive-terminal.js +66 -107
- package/build/commands/dev/utils/interactive-terminal.js.map +1 -1
- package/build/commands/dev/utils/metro/metro-config.js +17 -20
- package/build/commands/dev/utils/metro/metro-config.js.map +1 -1
- package/build/commands/dev/utils/metro/metro-reporter.d.ts +3 -4
- package/build/commands/dev/utils/metro/metro-reporter.js +6 -13
- package/build/commands/dev/utils/metro/metro-reporter.js.map +1 -1
- package/build/commands/dev/utils/metro/metro-server-middleware.d.ts +1 -0
- package/build/commands/dev/utils/metro/metro-server-middleware.js +11 -12
- package/build/commands/dev/utils/metro/metro-server-middleware.js.map +1 -1
- package/build/commands/dev/utils/metro/metro-server.d.ts +2 -2
- package/build/commands/dev/utils/metro/metro-server.js +7 -14
- package/build/commands/dev/utils/metro/metro-server.js.map +1 -1
- package/build/commands/dev/utils/network.d.ts +20 -0
- package/build/commands/dev/utils/network.js +122 -0
- package/build/commands/dev/utils/network.js.map +1 -0
- package/build/commands/dev/utils/platform.d.ts +18 -0
- package/build/commands/dev/utils/platform.js +41 -0
- package/build/commands/dev/utils/platform.js.map +1 -0
- package/build/commands/dev/utils/prompt-binary-upgrade.d.ts +1 -0
- package/build/commands/dev/utils/prompt-binary-upgrade.js +12 -0
- package/build/commands/dev/utils/prompt-binary-upgrade.js.map +1 -0
- package/build/commands/dev/utils/qr-code.js +3 -10
- package/build/commands/dev/utils/qr-code.js.map +1 -1
- package/build/commands/dev/utils/simulator.d.ts +5 -2
- package/build/commands/dev/utils/simulator.js +43 -37
- package/build/commands/dev/utils/simulator.js.map +1 -1
- package/build/commands/dev/utils/start-app/config.d.ts +5 -0
- package/build/commands/dev/utils/start-app/config.js +25 -0
- package/build/commands/dev/utils/start-app/config.js.map +1 -0
- package/build/commands/dev/utils/start-app/start-app-with-options.d.ts +2 -0
- package/build/commands/dev/utils/start-app/start-app-with-options.js +94 -0
- package/build/commands/dev/utils/start-app/start-app-with-options.js.map +1 -0
- package/build/commands/dev/utils/start-app/start-app.d.ts +2 -0
- package/build/commands/dev/utils/start-app/start-app.js +10 -0
- package/build/commands/dev/utils/start-app/start-app.js.map +1 -0
- package/build/commands/dev/utils/start-app/types.d.ts +20 -0
- package/build/commands/dev/utils/start-app/types.js +2 -0
- package/build/commands/dev/utils/start-app/types.js.map +1 -0
- package/build/commands/dev/utils/types.d.ts +24 -0
- package/build/commands/dev/utils/types.js +7 -0
- package/build/commands/dev/utils/types.js.map +1 -0
- package/build/commands/dev/utils/version.d.ts +64 -0
- package/build/commands/dev/utils/version.js +101 -0
- package/build/commands/dev/utils/version.js.map +1 -0
- package/build/commands/dev/utils/with-retries.js +1 -5
- package/build/commands/dev/utils/with-retries.js.map +1 -1
- package/build/commands/doctor/index.d.ts +6 -0
- package/build/commands/doctor/index.js +21 -0
- package/build/commands/doctor/index.js.map +1 -0
- package/build/commands/doctor/utils/diagnose-dependencies.d.ts +7 -0
- package/build/commands/doctor/utils/diagnose-dependencies.js +108 -0
- package/build/commands/doctor/utils/diagnose-dependencies.js.map +1 -0
- package/build/commands/generate-graphql-types/index.d.ts +1 -0
- package/build/commands/generate-graphql-types/index.js +43 -27
- package/build/commands/generate-graphql-types/index.js.map +1 -1
- package/build/commands/info/index.d.ts +3 -0
- package/build/commands/info/index.js +42 -0
- package/build/commands/info/index.js.map +1 -0
- package/build/commands/setup/index.d.ts +2 -0
- package/build/commands/setup/index.js +81 -0
- package/build/commands/setup/index.js.map +1 -0
- package/build/commands/submit/config.d.ts +9 -0
- package/build/commands/submit/config.js +18 -0
- package/build/commands/submit/config.js.map +1 -0
- package/build/commands/submit/errors.d.ts +19 -0
- package/build/commands/submit/errors.js +87 -0
- package/build/commands/submit/errors.js.map +1 -0
- package/build/commands/submit/gcs.d.ts +6 -0
- package/build/commands/submit/gcs.js +10 -0
- package/build/commands/submit/gcs.js.map +1 -0
- package/build/commands/submit/index.d.ts +2 -0
- package/build/commands/submit/index.js +25 -0
- package/build/commands/submit/index.js.map +1 -0
- package/build/commands/submit/submit.d.ts +5 -0
- package/build/commands/submit/submit.js +222 -0
- package/build/commands/submit/submit.js.map +1 -0
- package/build/commands/submit/tasks.d.ts +37 -0
- package/build/commands/submit/tasks.js +91 -0
- package/build/commands/submit/tasks.js.map +1 -0
- package/build/commands/submit/types.d.ts +14 -0
- package/build/commands/submit/types.js +2 -0
- package/build/commands/submit/types.js.map +1 -0
- package/build/commands/submit/utils/assert-core-dependencies-version.d.ts +1 -0
- package/build/commands/submit/utils/assert-core-dependencies-version.js +58 -0
- package/build/commands/submit/utils/assert-core-dependencies-version.js.map +1 -0
- package/build/commands/submit/utils/request-entry-point-params.d.ts +1 -0
- package/build/commands/submit/utils/request-entry-point-params.js +41 -0
- package/build/commands/submit/utils/request-entry-point-params.js.map +1 -0
- package/build/commands/submit/validation.d.ts +1 -0
- package/build/commands/submit/validation.js +11 -0
- package/build/commands/submit/validation.js.map +1 -0
- package/build/commands/upgrade/index.d.ts +13 -0
- package/build/commands/upgrade/index.js +53 -0
- package/build/commands/upgrade/index.js.map +1 -0
- package/build/commands/upgrade/utils/cli.d.ts +1 -0
- package/build/commands/upgrade/utils/cli.js +15 -0
- package/build/commands/upgrade/utils/cli.js.map +1 -0
- package/build/commands/validate-manifest/index.d.ts +3 -0
- package/build/commands/validate-manifest/index.js +29 -0
- package/build/commands/validate-manifest/index.js.map +1 -0
- package/build/data/accept-invitation.d.ts +4 -0
- package/build/data/accept-invitation.js +16 -0
- package/build/data/accept-invitation.js.map +1 -0
- package/build/data/cancel-submission.d.ts +22 -0
- package/build/data/cancel-submission.js +26 -0
- package/build/data/cancel-submission.js.map +1 -0
- package/build/data/create-submission.d.ts +20 -0
- package/build/data/create-submission.js +27 -0
- package/build/data/create-submission.js.map +1 -0
- package/build/data/create-upload.d.ts +21 -0
- package/build/data/create-upload.js +40 -0
- package/build/data/create-upload.js.map +1 -0
- package/build/data/get-submissions.d.ts +27 -0
- package/build/data/get-submissions.js +33 -0
- package/build/data/get-submissions.js.map +1 -0
- package/build/data/gql-client.d.ts +8 -0
- package/build/data/gql-client.js +9 -0
- package/build/data/gql-client.js.map +1 -0
- package/build/data/mini.d.ts +5 -0
- package/build/data/mini.js +14 -0
- package/build/data/mini.js.map +1 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/fragment-masking.d.ts +13 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/fragment-masking.js +7 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/fragment-masking.js.map +1 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/gql.d.ts +75 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/gql.js +24 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/gql.js.map +1 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/graphql.d.ts +1570 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/graphql.js +1062 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/graphql.js.map +1 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/index.d.ts +2 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/index.js +3 -0
- package/build/data/types/autogenerated/shop-minis-admin-api/index.js.map +1 -0
- package/build/dev-panel/asset-manifest.json +6 -9
- package/build/dev-panel/index.html +1 -1
- package/build/dev-panel/static/css/{main.31436fe3.css → main.7f1ee407.css} +2 -2
- package/build/dev-panel/static/css/main.7f1ee407.css.map +1 -0
- package/build/dev-panel/static/js/{main.27f47095.js → main.6625699c.js} +3 -3
- package/build/dev-panel/static/js/main.6625699c.js.map +1 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +30 -15
- package/build/index.js.map +1 -1
- package/build/schemas/manifest.schema.json +198 -0
- package/build/utils/archive.d.ts +30 -0
- package/build/utils/archive.js +38 -0
- package/build/utils/archive.js.map +1 -0
- package/build/utils/common-tasks.d.ts +1 -0
- package/build/utils/common-tasks.js +49 -0
- package/build/utils/common-tasks.js.map +1 -0
- package/build/utils/development-params.d.ts +13 -0
- package/build/utils/development-params.js +42 -0
- package/build/utils/development-params.js.map +1 -0
- package/build/{commands/utils → utils}/exec-async-child-process.d.ts +1 -1
- package/build/{commands/utils → utils}/exec-async-child-process.js +6 -13
- package/build/utils/exec-async-child-process.js.map +1 -0
- package/build/utils/file.d.ts +1 -0
- package/build/utils/file.js +7 -0
- package/build/utils/file.js.map +1 -0
- package/build/utils/minis-manifest.d.ts +6 -0
- package/build/utils/minis-manifest.js +56 -0
- package/build/utils/minis-manifest.js.map +1 -0
- package/build/utils/package-manager.d.ts +38 -0
- package/build/utils/package-manager.js +98 -0
- package/build/utils/package-manager.js.map +1 -0
- package/build/utils/patch-package.d.ts +5 -0
- package/build/utils/patch-package.js +76 -0
- package/build/utils/patch-package.js.map +1 -0
- package/build/utils/replace-strings-in-template.d.ts +1 -0
- package/build/utils/replace-strings-in-template.js +15 -0
- package/build/utils/replace-strings-in-template.js.map +1 -0
- package/build/utils/semver.d.ts +1 -0
- package/build/utils/semver.js +19 -0
- package/build/utils/semver.js.map +1 -0
- package/build/{commands/utils → utils}/wrap-with-loading-indicator.d.ts +1 -1
- package/build/utils/wrap-with-loading-indicator.js +16 -0
- package/build/utils/wrap-with-loading-indicator.js.map +1 -0
- package/package.json +35 -28
- package/scripts/graphql-codegen.ts +23 -0
- package/scripts/test-template.ts +63 -0
- package/shipit.alpha.yml +3 -0
- package/templates/__template_blank/src/index.tsx +5 -4
- package/templates/__template_blank/src/types.ts +1 -1
- package/templates/__template_common/.eslintrc.js +16 -0
- package/templates/__template_common/assets.d.ts +14 -0
- package/templates/__template_common/babel.config.js +3 -17
- package/templates/__template_common/gitignore +2 -0
- package/templates/__template_common/index.tsx +3 -6
- package/templates/__template_common/metro.config.js +4 -30
- package/templates/__template_common/package.json +17 -47
- package/templates/__template_common/src/manifest.json +1 -27
- package/templates/__template_hello_world/src/components/ComponentLink.ts +31 -19
- package/templates/__template_hello_world/src/components/ComponentListItem.tsx +1 -0
- package/templates/__template_hello_world/src/components/FeaturedComponents.tsx +4 -2
- package/templates/__template_hello_world/src/components/quiz/ImageCarouselSlide.tsx +54 -0
- package/templates/__template_hello_world/src/components/quiz/MultipleChoiceSlide.tsx +77 -0
- package/templates/__template_hello_world/src/components/quiz/QuizProvider.tsx +64 -0
- package/templates/__template_hello_world/src/components/quiz/QuizSlide.tsx +79 -0
- package/templates/__template_hello_world/src/components/quiz/QuizSlideCommander.tsx +35 -0
- package/templates/__template_hello_world/src/components/quiz/TextFieldSlide.tsx +84 -0
- package/templates/__template_hello_world/src/components/quiz/TextSlide.tsx +6 -0
- package/templates/__template_hello_world/src/components/quiz/types.ts +72 -0
- package/templates/__template_hello_world/src/data/Test.graphql.d.ts +69 -76
- package/templates/__template_hello_world/src/data/TestProducts.graphql +30 -0
- package/templates/__template_hello_world/src/data/TestProducts.graphql.d.ts +159 -81
- package/templates/__template_hello_world/src/fixtures/mocked-products-with-variants.ts +274 -0
- package/templates/__template_hello_world/src/hooks/useQuizData.ts +26 -0
- package/templates/__template_hello_world/src/hooks/useQuizState.ts +27 -0
- package/templates/__template_hello_world/src/index.tsx +6 -5
- package/templates/__template_hello_world/src/routes.tsx +46 -22
- package/templates/__template_hello_world/src/screens/AccordionScreen.tsx +73 -0
- package/templates/__template_hello_world/src/screens/BottomSheetScreen.tsx +6 -5
- package/templates/__template_hello_world/src/screens/HomeScreen.tsx +14 -3
- package/templates/__template_hello_world/src/screens/{ImageCarouselScreen.tsx → ImageMultipleChoiceScreen.tsx} +4 -6
- package/templates/__template_hello_world/src/screens/InputScreen.tsx +13 -70
- package/templates/__template_hello_world/src/screens/QuizResultScreen.tsx +82 -0
- package/templates/__template_hello_world/src/screens/QuizScreen.tsx +40 -0
- package/templates/__template_hello_world/src/screens/QuizSlideScreen.tsx +150 -0
- package/templates/__template_hello_world/src/screens/ShopActionsScreen.tsx +48 -0
- package/templates/__template_hello_world/src/screens/VariantPickerScreen.tsx +120 -0
- package/templates/__template_hello_world/src/types.ts +27 -24
- package/templates/__template_hello_world/src/utils/mockQuizData.ts +330 -0
- package/templates/__template_hello_world/src/utils/quizUtils.ts +75 -0
- package/templates/__template_snowboardz/src/components/SkillLevelIcon.tsx +1 -4
- package/templates/__template_snowboardz/src/components/SkillLevelPicker.tsx +7 -1
- package/templates/__template_snowboardz/src/data/TestProducts.graphql +1 -1
- package/templates/__template_snowboardz/src/data/TestProducts.graphql.d.ts +84 -74
- package/templates/__template_snowboardz/src/index.tsx +6 -5
- package/templates/__template_snowboardz/src/routes.tsx +2 -2
- package/templates/__template_snowboardz/src/types.ts +3 -3
- package/build/commands/check/index.d.ts +0 -5
- package/build/commands/check/index.js +0 -77
- package/build/commands/check/index.js.map +0 -1
- package/build/commands/check/utils/versions.d.ts +0 -1
- package/build/commands/check/utils/versions.js +0 -14
- package/build/commands/check/utils/versions.js.map +0 -1
- package/build/commands/dev/utils/binaries.test.d.ts +0 -1
- package/build/commands/dev/utils/binaries.test.js +0 -275
- package/build/commands/dev/utils/binaries.test.js.map +0 -1
- package/build/commands/dev/utils/minis-manifest.d.ts +0 -1
- package/build/commands/dev/utils/minis-manifest.js +0 -24
- package/build/commands/dev/utils/minis-manifest.js.map +0 -1
- package/build/commands/utils/exec-async-child-process.js.map +0 -1
- package/build/commands/utils/wrap-with-loading-indicator.js +0 -23
- package/build/commands/utils/wrap-with-loading-indicator.js.map +0 -1
- package/build/dev-panel/middleware.d.ts +0 -4
- package/build/dev-panel/middleware.js +0 -11
- package/build/dev-panel/middleware.js.map +0 -1
- package/build/dev-panel/static/css/main.31436fe3.css.map +0 -1
- package/build/dev-panel/static/js/main.27f47095.js.map +0 -1
- package/build/dev-panel/static/media/bottomsheet.fe525b8722f6d504a185.png +0 -0
- package/build/dev-panel/static/media/navigation.597434370a97c328a970.png +0 -0
- package/build/dev-panel/static/media/stories.a425b6972a5338fabdad.png +0 -0
- package/templates/__template_blank/src/custom.d.ts +0 -4
- package/templates/__template_common/.eslintrc.json +0 -132
- package/templates/__template_common/patches/react-native+0.68.5.patch +0 -173
- package/templates/__template_hello_world/src/utils/getFlagEmoji.spec.tsx +0 -19
- /package/build/dev-panel/static/js/{main.27f47095.js.LICENSE.txt → main.6625699c.js.LICENSE.txt} +0 -0
|
@@ -2,22 +2,21 @@ import {ItemValue} from '@react-native-community/picker/typings/Picker'
|
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
DatePicker,
|
|
5
|
-
Icon,
|
|
6
5
|
KeyboardAvoidingView,
|
|
7
6
|
Picker,
|
|
8
7
|
TextField,
|
|
9
8
|
Text,
|
|
9
|
+
countryCodesAndPhonePrefixes,
|
|
10
|
+
getFlagEmoji,
|
|
10
11
|
} from '@shopify/shop-minis-platform-sdk'
|
|
11
12
|
import {useState} from 'react'
|
|
12
13
|
import {
|
|
13
14
|
NativeSyntheticEvent,
|
|
14
|
-
Pressable,
|
|
15
15
|
SafeAreaView,
|
|
16
16
|
ScrollView,
|
|
17
17
|
TextInputEndEditingEventData,
|
|
18
18
|
} from 'react-native'
|
|
19
19
|
|
|
20
|
-
import {getFlagEmoji} from '../utils/getFlagEmoji'
|
|
21
20
|
import {Header} from '../components/Header'
|
|
22
21
|
|
|
23
22
|
interface Item {
|
|
@@ -26,35 +25,16 @@ interface Item {
|
|
|
26
25
|
selected?: boolean
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const countryData: Item[] = [
|
|
37
|
-
{
|
|
38
|
-
value: 'US',
|
|
39
|
-
label: `US ${getFlagEmoji('US')}`,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
value: 'DE',
|
|
43
|
-
label: `DE ${getFlagEmoji('DE')}`,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
value: 'BR',
|
|
47
|
-
label: `BR ${getFlagEmoji('BR')}`,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
value: 'NL',
|
|
51
|
-
label: `NL ${getFlagEmoji('NL')}`,
|
|
52
|
-
},
|
|
53
|
-
]
|
|
28
|
+
const countryData: Item[] = countryCodesAndPhonePrefixes.map(
|
|
29
|
+
({code, name}) => ({
|
|
30
|
+
value: code,
|
|
31
|
+
label: `${name} ${getFlagEmoji(code)}`,
|
|
32
|
+
})
|
|
33
|
+
)
|
|
54
34
|
|
|
55
35
|
export const InputScreen = () => {
|
|
56
36
|
const [showCountryPicker, setShowCountryPicker] = useState(false)
|
|
57
|
-
const [selectedCountry, setSelectedCountry] = useState<string>(
|
|
37
|
+
const [selectedCountry, setSelectedCountry] = useState<string>()
|
|
58
38
|
|
|
59
39
|
const [showDatePicker, setShowDatePicker] = useState(false)
|
|
60
40
|
const [date, setDate] = useState(new Date())
|
|
@@ -76,22 +56,19 @@ export const InputScreen = () => {
|
|
|
76
56
|
}
|
|
77
57
|
return (
|
|
78
58
|
<SafeAreaView style={{flex: 1}}>
|
|
79
|
-
<Header />
|
|
80
59
|
<KeyboardAvoidingView>
|
|
81
60
|
<ScrollView style={{flex: 1}}>
|
|
61
|
+
<Header />
|
|
82
62
|
<Box padding="m">
|
|
83
63
|
<Box marginBottom="m">
|
|
84
64
|
<Text variant="headerBold">Inputs</Text>
|
|
85
65
|
</Box>
|
|
86
66
|
<Box marginBottom="s">
|
|
87
67
|
<Box marginBottom="xs">
|
|
88
|
-
<Text variant="bodyLargeBold">Text
|
|
68
|
+
<Text variant="bodyLargeBold">Text</Text>
|
|
89
69
|
</Box>
|
|
90
70
|
|
|
91
|
-
<TextField
|
|
92
|
-
placeholder="Enter your email"
|
|
93
|
-
onChangeText={console.log}
|
|
94
|
-
/>
|
|
71
|
+
<TextField placeholder="Enter a word" />
|
|
95
72
|
</Box>
|
|
96
73
|
<Box marginBottom="s">
|
|
97
74
|
<Box marginBottom="xs">
|
|
@@ -109,41 +86,7 @@ export const InputScreen = () => {
|
|
|
109
86
|
<Box marginBottom="xs">
|
|
110
87
|
<Text variant="bodyLargeBold">Multiline</Text>
|
|
111
88
|
</Box>
|
|
112
|
-
<TextField multiline
|
|
113
|
-
</Box>
|
|
114
|
-
<Box marginBottom="s">
|
|
115
|
-
<Box marginBottom="xs">
|
|
116
|
-
<Text variant="bodyLargeBold">Select / Trailing component</Text>
|
|
117
|
-
</Box>
|
|
118
|
-
<TextField
|
|
119
|
-
placeholder="Enter Your Phone"
|
|
120
|
-
leadingComponent={
|
|
121
|
-
selectedCountry ? (
|
|
122
|
-
<Text marginEnd="xs">
|
|
123
|
-
{
|
|
124
|
-
countryCodeToPrefixMap[
|
|
125
|
-
selectedCountry as keyof typeof countryCodeToPrefixMap
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
</Text>
|
|
129
|
-
) : null
|
|
130
|
-
}
|
|
131
|
-
trailingComponent={
|
|
132
|
-
<Pressable onPress={() => setShowCountryPicker(true)}>
|
|
133
|
-
<Box
|
|
134
|
-
flexDirection="row"
|
|
135
|
-
borderStartWidth={1}
|
|
136
|
-
borderStartColor="inputs-border-color"
|
|
137
|
-
paddingStart="xs"
|
|
138
|
-
>
|
|
139
|
-
<Text marginEnd="xs">
|
|
140
|
-
{getFlagEmoji(selectedCountry ?? 'US')}
|
|
141
|
-
</Text>
|
|
142
|
-
<Icon name="chevron-down" />
|
|
143
|
-
</Box>
|
|
144
|
-
</Pressable>
|
|
145
|
-
}
|
|
146
|
-
/>
|
|
89
|
+
<TextField multiline />
|
|
147
90
|
</Box>
|
|
148
91
|
<Box marginBottom="s">
|
|
149
92
|
<Box marginBottom="xs">
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {Box, Text} from '@shopify/shop-minis-platform-sdk'
|
|
2
|
+
import {useMemo} from 'react'
|
|
3
|
+
import {Image, SafeAreaView, ScrollView} from 'react-native'
|
|
4
|
+
|
|
5
|
+
import {useQuizContext} from '../components/quiz/QuizProvider'
|
|
6
|
+
import {
|
|
7
|
+
addNameToText,
|
|
8
|
+
getImageCarouselAnswerUrls,
|
|
9
|
+
getMultilpleChoiceAnswerLabels,
|
|
10
|
+
getQuestionById,
|
|
11
|
+
} from '../utils/quizUtils'
|
|
12
|
+
|
|
13
|
+
export const QuizResultScreen = () => {
|
|
14
|
+
const {quizResult, quizData, userName} = useQuizContext()
|
|
15
|
+
|
|
16
|
+
const formattedResults = useMemo(() => {
|
|
17
|
+
if (!quizData) return []
|
|
18
|
+
|
|
19
|
+
return Object.entries(quizResult!).map(([questionId, result]) => {
|
|
20
|
+
let answer = ''
|
|
21
|
+
// image carousel type will be an imageUrl
|
|
22
|
+
let type: 'imageUrl' | 'string' = 'string'
|
|
23
|
+
|
|
24
|
+
switch (result.slideType) {
|
|
25
|
+
case 'MultipleChoiceSlide':
|
|
26
|
+
answer = getMultilpleChoiceAnswerLabels(
|
|
27
|
+
quizData,
|
|
28
|
+
questionId,
|
|
29
|
+
result.answer as number[]
|
|
30
|
+
).join(', ')
|
|
31
|
+
break
|
|
32
|
+
case 'ImageCarouselSlide':
|
|
33
|
+
type = 'imageUrl'
|
|
34
|
+
answer = getImageCarouselAnswerUrls(
|
|
35
|
+
quizData,
|
|
36
|
+
questionId,
|
|
37
|
+
result.answer as number[]
|
|
38
|
+
)[0]
|
|
39
|
+
break
|
|
40
|
+
default:
|
|
41
|
+
answer = result.answer as string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const question = addNameToText(
|
|
45
|
+
getQuestionById(quizData, questionId),
|
|
46
|
+
userName
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
type,
|
|
51
|
+
question,
|
|
52
|
+
answer,
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
}, [quizData, quizResult, userName])
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<SafeAreaView>
|
|
59
|
+
<ScrollView>
|
|
60
|
+
<Box paddingHorizontal="gutter" paddingVertical="xs">
|
|
61
|
+
<Text variant="posterXS" textAlign="center" marginVertical="m">
|
|
62
|
+
Results
|
|
63
|
+
</Text>
|
|
64
|
+
{formattedResults.map(({question, answer, type}, index) => (
|
|
65
|
+
<Box key={question} marginBottom="s">
|
|
66
|
+
<Text variant="headerNormal" marginBottom="xs">
|
|
67
|
+
{index + 1}. {question}
|
|
68
|
+
</Text>
|
|
69
|
+
{type === 'imageUrl' ? (
|
|
70
|
+
<Image
|
|
71
|
+
style={{width: 160, height: 160}}
|
|
72
|
+
source={{uri: answer}}
|
|
73
|
+
/>
|
|
74
|
+
) : null}
|
|
75
|
+
{type === 'string' ? <Text>Answer: {answer}</Text> : null}
|
|
76
|
+
</Box>
|
|
77
|
+
))}
|
|
78
|
+
</Box>
|
|
79
|
+
</ScrollView>
|
|
80
|
+
</SafeAreaView>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {NavigationContainer} from '@react-navigation/native'
|
|
2
|
+
import {createNativeStackNavigator} from '@react-navigation/native-stack'
|
|
3
|
+
|
|
4
|
+
import {Header} from '../components/Header'
|
|
5
|
+
import {QuizContextProvider} from '../components/quiz/QuizProvider'
|
|
6
|
+
|
|
7
|
+
import {QuizResultScreen} from './QuizResultScreen'
|
|
8
|
+
import {QuizSlideScreen} from './QuizSlideScreen'
|
|
9
|
+
|
|
10
|
+
const Stack = createNativeStackNavigator()
|
|
11
|
+
|
|
12
|
+
export const QuizScreen = () => {
|
|
13
|
+
return (
|
|
14
|
+
<QuizContextProvider>
|
|
15
|
+
<>
|
|
16
|
+
<Header />
|
|
17
|
+
<NavigationContainer independent>
|
|
18
|
+
<Stack.Navigator>
|
|
19
|
+
<Stack.Screen
|
|
20
|
+
name="QuizScreen.QuizSlide"
|
|
21
|
+
component={QuizSlideScreen}
|
|
22
|
+
options={{
|
|
23
|
+
title: '__MINI_APP_NAME_PASCAL_CASE__ Quiz',
|
|
24
|
+
headerBackTitle: 'Previous',
|
|
25
|
+
}}
|
|
26
|
+
initialParams={{
|
|
27
|
+
slideIndex: 0,
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
30
|
+
<Stack.Screen
|
|
31
|
+
name="QuizScreen.QuizResult"
|
|
32
|
+
component={QuizResultScreen}
|
|
33
|
+
options={{headerShown: false}}
|
|
34
|
+
/>
|
|
35
|
+
</Stack.Navigator>
|
|
36
|
+
</NavigationContainer>
|
|
37
|
+
</>
|
|
38
|
+
</QuizContextProvider>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import {RouteProp, useNavigation, useRoute} from '@react-navigation/native'
|
|
2
|
+
import {NativeStackNavigationProp} from '@react-navigation/native-stack'
|
|
3
|
+
import {Box, Spinner, Text} from '@shopify/shop-minis-platform-sdk'
|
|
4
|
+
import {useCallback, useMemo, useState} from 'react'
|
|
5
|
+
import {SafeAreaView, ScrollView} from 'react-native'
|
|
6
|
+
|
|
7
|
+
import {useQuizContext} from '../components/quiz/QuizProvider'
|
|
8
|
+
import {
|
|
9
|
+
QuizSlideCommander,
|
|
10
|
+
QuizSlideCommanderProps,
|
|
11
|
+
} from '../components/quiz/QuizSlideCommander'
|
|
12
|
+
import {QuizAnswerType, QuizStackParamList} from '../components/quiz/types'
|
|
13
|
+
import {
|
|
14
|
+
addNameToText,
|
|
15
|
+
getQuizSlideDataByIndex,
|
|
16
|
+
getQuizSlideIndexById,
|
|
17
|
+
} from '../utils/quizUtils'
|
|
18
|
+
|
|
19
|
+
export const QuizSlideScreen = () => {
|
|
20
|
+
const navigation =
|
|
21
|
+
useNavigation<NativeStackNavigationProp<QuizStackParamList>>()
|
|
22
|
+
const route: RouteProp<{params: {slideIndex: number}}, 'params'> = useRoute()
|
|
23
|
+
|
|
24
|
+
const [currentSlideAnswer, setCurrentSlideAnswer] = useState<QuizAnswerType>()
|
|
25
|
+
|
|
26
|
+
const currentSlideIndex = route.params?.slideIndex ?? 0
|
|
27
|
+
|
|
28
|
+
const {recordQuestionResult, quizData, quizDataState, setUserName, userName} =
|
|
29
|
+
useQuizContext()
|
|
30
|
+
|
|
31
|
+
const slideData = useMemo(
|
|
32
|
+
() =>
|
|
33
|
+
quizData
|
|
34
|
+
? getQuizSlideDataByIndex(quizData, currentSlideIndex)
|
|
35
|
+
: undefined,
|
|
36
|
+
[currentSlideIndex, quizData]
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
const determineNextSlideIndex = useCallback(() => {
|
|
40
|
+
if (!quizData || !slideData) return 0
|
|
41
|
+
|
|
42
|
+
let determinedNextSlideId = ''
|
|
43
|
+
|
|
44
|
+
const {nextSlideId, determineNextSlide} = slideData.props
|
|
45
|
+
|
|
46
|
+
if (nextSlideId) {
|
|
47
|
+
determinedNextSlideId = nextSlideId
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (currentSlideAnswer && determineNextSlide) {
|
|
51
|
+
// the type of the parameter for determineNextSlide cannot be determined
|
|
52
|
+
// because it is generic but it will a QuizAnswerType
|
|
53
|
+
determinedNextSlideId = determineNextSlide(currentSlideAnswer as any)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (determinedNextSlideId === '') return currentSlideIndex + 1
|
|
57
|
+
|
|
58
|
+
return getQuizSlideIndexById(quizData, determinedNextSlideId)
|
|
59
|
+
}, [currentSlideAnswer, currentSlideIndex, quizData, slideData])
|
|
60
|
+
|
|
61
|
+
const handleNextCtaPress = useCallback(() => {
|
|
62
|
+
if (!quizData) return
|
|
63
|
+
|
|
64
|
+
if (currentSlideAnswer !== undefined) {
|
|
65
|
+
const {id, type: slideType} = getQuizSlideDataByIndex(
|
|
66
|
+
quizData,
|
|
67
|
+
currentSlideIndex
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
recordQuestionResult(id, {
|
|
71
|
+
answer: currentSlideAnswer,
|
|
72
|
+
slideType,
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (slideData?.id === 'enter-name' && currentSlideAnswer) {
|
|
77
|
+
setUserName(currentSlideAnswer as string)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (slideData?.props.nextSlideId === 'results') {
|
|
81
|
+
navigation.replace('QuizScreen.QuizResult')
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
navigation.push('QuizScreen.QuizSlide', {
|
|
86
|
+
slideIndex: determineNextSlideIndex(),
|
|
87
|
+
})
|
|
88
|
+
}, [
|
|
89
|
+
currentSlideAnswer,
|
|
90
|
+
currentSlideIndex,
|
|
91
|
+
determineNextSlideIndex,
|
|
92
|
+
navigation,
|
|
93
|
+
quizData,
|
|
94
|
+
recordQuestionResult,
|
|
95
|
+
setUserName,
|
|
96
|
+
slideData?.id,
|
|
97
|
+
slideData?.props.nextSlideId,
|
|
98
|
+
])
|
|
99
|
+
|
|
100
|
+
const handleAnswerSelection = useCallback((answer: QuizAnswerType) => {
|
|
101
|
+
setCurrentSlideAnswer(answer)
|
|
102
|
+
}, [])
|
|
103
|
+
|
|
104
|
+
if (quizDataState === 'Loading') {
|
|
105
|
+
return (
|
|
106
|
+
<SafeAreaView>
|
|
107
|
+
<ScrollView>
|
|
108
|
+
<Box paddingHorizontal="gutter" paddingVertical="xl">
|
|
109
|
+
<Text textAlign="center">Please wait, systems processing</Text>
|
|
110
|
+
<Box
|
|
111
|
+
height={180}
|
|
112
|
+
flex={1}
|
|
113
|
+
justifyContent="center"
|
|
114
|
+
alignItems="center"
|
|
115
|
+
>
|
|
116
|
+
<Spinner size="large" />
|
|
117
|
+
</Box>
|
|
118
|
+
</Box>
|
|
119
|
+
</ScrollView>
|
|
120
|
+
</SafeAreaView>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// if quizDataState is not Loading, then data is ready
|
|
125
|
+
const {type, props} = slideData!
|
|
126
|
+
|
|
127
|
+
const mainTextWithUserName = addNameToText(
|
|
128
|
+
props.quizSlideProps.mainText,
|
|
129
|
+
userName
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
const enrichedSlideProps: QuizSlideCommanderProps['props'] = {
|
|
133
|
+
...props,
|
|
134
|
+
quizSlideProps: {
|
|
135
|
+
...props.quizSlideProps,
|
|
136
|
+
mainText: mainTextWithUserName,
|
|
137
|
+
ctaOnPressHandler: handleNextCtaPress,
|
|
138
|
+
},
|
|
139
|
+
handleAnswerSelection,
|
|
140
|
+
}
|
|
141
|
+
return (
|
|
142
|
+
<SafeAreaView>
|
|
143
|
+
<ScrollView>
|
|
144
|
+
<Box paddingHorizontal="gutter" paddingVertical="xs">
|
|
145
|
+
<QuizSlideCommander type={type} props={enrichedSlideProps} />
|
|
146
|
+
</Box>
|
|
147
|
+
</ScrollView>
|
|
148
|
+
</SafeAreaView>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {useState} from 'react'
|
|
2
|
+
import {SafeAreaView, ScrollView} from 'react-native'
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
Button,
|
|
6
|
+
KeyboardAvoidingView,
|
|
7
|
+
Text,
|
|
8
|
+
TextField,
|
|
9
|
+
} from '@shopify/shop-minis-platform-sdk'
|
|
10
|
+
import {useShopActions} from '@shopify/shop-minis-platform-sdk/actions'
|
|
11
|
+
|
|
12
|
+
import {Header} from '../components/Header'
|
|
13
|
+
|
|
14
|
+
export const ShopActionsScreen = () => {
|
|
15
|
+
const [navigateToCheckoutUrl, setNavigateToCheckoutUrl] = useState('')
|
|
16
|
+
const {navigateToCheckout} = useShopActions()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<SafeAreaView style={{flex: 1}}>
|
|
20
|
+
<KeyboardAvoidingView>
|
|
21
|
+
<ScrollView style={{flex: 1}}>
|
|
22
|
+
<Header />
|
|
23
|
+
<Box px="gutter">
|
|
24
|
+
<Text variant="headerBold" mb="xs">
|
|
25
|
+
Shop Actions
|
|
26
|
+
</Text>
|
|
27
|
+
<Box marginBottom="m">
|
|
28
|
+
<Box marginBottom="xs">
|
|
29
|
+
<Text variant="bodyLargeBold">Checkout with URL</Text>
|
|
30
|
+
</Box>
|
|
31
|
+
<Box marginBottom="xs">
|
|
32
|
+
<TextField
|
|
33
|
+
placeholder="URL"
|
|
34
|
+
value={navigateToCheckoutUrl}
|
|
35
|
+
onChangeText={text => setNavigateToCheckoutUrl(text)}
|
|
36
|
+
/>
|
|
37
|
+
</Box>
|
|
38
|
+
<Button
|
|
39
|
+
text="Go to checkout"
|
|
40
|
+
onPress={() => navigateToCheckout({url: navigateToCheckoutUrl})}
|
|
41
|
+
/>
|
|
42
|
+
</Box>
|
|
43
|
+
</Box>
|
|
44
|
+
</ScrollView>
|
|
45
|
+
</KeyboardAvoidingView>
|
|
46
|
+
</SafeAreaView>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {useState} from 'react'
|
|
2
|
+
import {SafeAreaView, ScrollView} from 'react-native'
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
Text,
|
|
6
|
+
Button,
|
|
7
|
+
useMinisQuery,
|
|
8
|
+
useTheme,
|
|
9
|
+
VariantPicker,
|
|
10
|
+
Variant,
|
|
11
|
+
VariantOption,
|
|
12
|
+
} from '@shopify/shop-minis-platform-sdk'
|
|
13
|
+
|
|
14
|
+
import {Header} from '../components/Header'
|
|
15
|
+
import TestQuery from '../data/TestProducts.graphql'
|
|
16
|
+
import {
|
|
17
|
+
MOCKED_PRODUCT_1,
|
|
18
|
+
MOCKED_PRODUCT_1_DESCRIPTION,
|
|
19
|
+
MOCKED_PRODUCT_2,
|
|
20
|
+
MOCKED_PRODUCT_2_DESCRIPTION,
|
|
21
|
+
} from '../fixtures/mocked-products-with-variants'
|
|
22
|
+
|
|
23
|
+
const SHOP_GID = 'gid://shopify/Shop/62104633599'
|
|
24
|
+
const PRODUCT_GID = 'gid://shopify/Product/7632803594495'
|
|
25
|
+
|
|
26
|
+
const FETCH_PRODUCT_FROM_API = {
|
|
27
|
+
label: '1. Fetch product from API',
|
|
28
|
+
description: '',
|
|
29
|
+
}
|
|
30
|
+
const USE_MOCK_PRODUCT_1 = {
|
|
31
|
+
label: '2. Use mock product with 2 options',
|
|
32
|
+
description: MOCKED_PRODUCT_1_DESCRIPTION,
|
|
33
|
+
}
|
|
34
|
+
const USE_MOCK_PRODUCT_2 = {
|
|
35
|
+
label: '3. Use mock product with 3 options',
|
|
36
|
+
description: MOCKED_PRODUCT_2_DESCRIPTION,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const PRODUCT_SOURCES = [
|
|
40
|
+
FETCH_PRODUCT_FROM_API,
|
|
41
|
+
USE_MOCK_PRODUCT_1,
|
|
42
|
+
USE_MOCK_PRODUCT_2,
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
const EMPTY_LIST: any[] = []
|
|
46
|
+
|
|
47
|
+
function getProduct(productSource: any, data: any) {
|
|
48
|
+
if (productSource === FETCH_PRODUCT_FROM_API) {
|
|
49
|
+
return data?.shop?.productsByIds[0]
|
|
50
|
+
}
|
|
51
|
+
if (productSource === USE_MOCK_PRODUCT_1) {
|
|
52
|
+
return MOCKED_PRODUCT_1
|
|
53
|
+
}
|
|
54
|
+
return MOCKED_PRODUCT_2
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const VariantPickerScreen = () => {
|
|
58
|
+
const theme = useTheme()
|
|
59
|
+
const [options, setSelectedOptions] = useState<VariantOption[]>()
|
|
60
|
+
const [productSource, setProductSource] = useState(PRODUCT_SOURCES[0])
|
|
61
|
+
|
|
62
|
+
const {data} = useMinisQuery(TestQuery, {
|
|
63
|
+
variables: {
|
|
64
|
+
shopId: SHOP_GID,
|
|
65
|
+
productIds: [PRODUCT_GID],
|
|
66
|
+
},
|
|
67
|
+
fetchPolicy: 'cache-and-network',
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const product = getProduct(productSource, data)
|
|
71
|
+
|
|
72
|
+
if (!product) return null
|
|
73
|
+
|
|
74
|
+
const variants = product.variants.nodes
|
|
75
|
+
const selectedOptions = product.defaultVariant?.selectedOptions || []
|
|
76
|
+
|
|
77
|
+
const handleProductVariantUpdated = (variant: Variant | null) => {
|
|
78
|
+
setSelectedOptions(variant?.selectedOptions)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<SafeAreaView
|
|
83
|
+
style={{flex: 1, backgroundColor: theme.colors['backgrounds-regular']}}
|
|
84
|
+
>
|
|
85
|
+
<ScrollView
|
|
86
|
+
contentContainerStyle={{
|
|
87
|
+
flex: 1,
|
|
88
|
+
backgroundColor: theme.colors['backgrounds-regular'],
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
<Header />
|
|
92
|
+
<Box px="gutter">
|
|
93
|
+
<Text variant="heroBold">VariantPicker</Text>
|
|
94
|
+
{PRODUCT_SOURCES.map(source => (
|
|
95
|
+
<Button
|
|
96
|
+
text={source.label}
|
|
97
|
+
key={source.label}
|
|
98
|
+
onPress={() => {
|
|
99
|
+
setSelectedOptions(undefined)
|
|
100
|
+
setProductSource(source)
|
|
101
|
+
}}
|
|
102
|
+
style={{
|
|
103
|
+
opacity: productSource === source ? 1 : 0.5,
|
|
104
|
+
margin: 8,
|
|
105
|
+
}}
|
|
106
|
+
/>
|
|
107
|
+
))}
|
|
108
|
+
</Box>
|
|
109
|
+
{/* There's a known issue where <VariantPicker> cannot be put inside a <Box> */}
|
|
110
|
+
<VariantPicker
|
|
111
|
+
key={productSource.label}
|
|
112
|
+
variants={variants || EMPTY_LIST}
|
|
113
|
+
productOptions={product.options || EMPTY_LIST}
|
|
114
|
+
initialSelectedOptions={options?.length ? options : selectedOptions}
|
|
115
|
+
onProductVariantUpdated={handleProductVariantUpdated}
|
|
116
|
+
/>
|
|
117
|
+
</ScrollView>
|
|
118
|
+
</SafeAreaView>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
// @react-navigation/native-stack requires a `type` instead of an `interface`
|
|
2
2
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
3
3
|
export type StackParamList = {
|
|
4
|
-
'
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
4
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Home': undefined
|
|
5
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Modal': undefined
|
|
6
|
+
'__MINI_APP_NAME_PASCAL_CASE__.ProductCard': undefined
|
|
7
|
+
'__MINI_APP_NAME_PASCAL_CASE__.ProductCardGrid': undefined
|
|
8
|
+
'__MINI_APP_NAME_PASCAL_CASE__.ProductLink': undefined
|
|
9
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Typography': undefined
|
|
10
|
+
'__MINI_APP_NAME_PASCAL_CASE__.BottomSheet': undefined
|
|
11
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Buttons': undefined
|
|
12
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Icons': undefined
|
|
13
|
+
'__MINI_APP_NAME_PASCAL_CASE__.ImageMultipleChoice': undefined
|
|
14
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Inputs': undefined
|
|
15
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Media': undefined
|
|
16
|
+
'__MINI_APP_NAME_PASCAL_CASE__.MultipleChoice': undefined
|
|
17
|
+
'__MINI_APP_NAME_PASCAL_CASE__.QuantityPicker': undefined
|
|
18
|
+
'__MINI_APP_NAME_PASCAL_CASE__.VariantPicker': undefined
|
|
19
|
+
'__MINI_APP_NAME_PASCAL_CASE__.WebView': undefined
|
|
20
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Query': undefined
|
|
21
|
+
'__MINI_APP_NAME_PASCAL_CASE__.ShopActions': undefined
|
|
22
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Html': undefined
|
|
23
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Params': undefined
|
|
24
|
+
'__MINI_APP_NAME_PASCAL_CASE__.ProgressIndicator': undefined
|
|
25
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Spinner': undefined
|
|
26
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Grid': undefined
|
|
27
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Avatar': undefined
|
|
28
|
+
'__MINI_APP_NAME_PASCAL_CASE__.KeyboardAvoidingView': undefined
|
|
29
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Quiz': undefined
|
|
30
|
+
'__MINI_APP_NAME_PASCAL_CASE__.Accordion': undefined
|
|
28
31
|
}
|