├── README.md ├── mobile ├── .babelrc ├── .buckconfig ├── .editorconfig ├── .env.template ├── .eslintrc.js ├── .gitattributes ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── App.js ├── android │ ├── app │ │ ├── _BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── ecommapp │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── ecommapp │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── EcommApp-Bridging-Header.h │ ├── EcommApp.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── EcommApp.xcscheme │ ├── EcommApp.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── EcommApp │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m │ ├── EcommAppTests │ │ ├── EcommAppTests.m │ │ └── Info.plist │ ├── Fix.swift │ ├── Podfile │ └── Podfile.lock ├── metro.config.js ├── package.json ├── src │ ├── assets │ │ └── images │ │ │ ├── apps-outline.png │ │ │ ├── cart-outline.png │ │ │ ├── close-outline.png │ │ │ ├── home-outline.png │ │ │ └── person-circle-outline.png │ ├── components │ │ ├── Button.js │ │ ├── CartRow.js │ │ ├── Form.js │ │ ├── List.js │ │ ├── Loading.js │ │ ├── Navigation.js │ │ ├── QuantityCounter.js │ │ ├── Text.js │ │ └── __tests__ │ │ │ └── Button.test.js │ ├── constants │ │ └── colors.js │ ├── index.js │ ├── navigation │ │ └── Main.js │ ├── screens │ │ ├── Account.js │ │ ├── Cart.js │ │ ├── Explore.js │ │ ├── Home.js │ │ ├── ProductDetail.js │ │ ├── SignIn.js │ │ └── SignUp.js │ └── util │ │ ├── __tests__ │ │ └── auth.test.js │ │ ├── api.js │ │ ├── auth.js │ │ ├── cart.js │ │ └── format.js └── yarn.lock └── server ├── .eslintrc.js ├── .gitignore ├── .prettierrc.js ├── README.md ├── package.json ├── pages ├── _app.js ├── api │ ├── auth │ │ ├── login.js │ │ └── register.js │ ├── checkout.js │ ├── hello.js │ ├── product │ │ └── [id].js │ └── products │ │ ├── explore.js │ │ └── trending.js └── index.js ├── prisma ├── dev.db ├── migrations │ ├── 20210609203923_init │ │ └── migration.sql │ ├── 20210610212753_add_category │ │ └── migration.sql │ ├── 20210618165608_add_user_model │ │ └── migration.sql │ ├── 20210618175453_make_user_email_unique │ │ └── migration.sql │ ├── 20210621185425_add_stripe_customer_id_to_user │ │ └── migration.sql │ └── migration_lock.toml ├── schema.prisma └── seed.js ├── public ├── favicon.ico └── vercel.svg ├── styles ├── Home.module.css └── globals.css ├── util ├── auth.js └── prisma.js └── yarn.lock /README.md: -------------------------------------------------------------------------------- 1 | **STOP!** This repo is out of date and won't be updated. Please look at the [updated version](https://github.com/ReactNativeSchool/ecommerce-course-app). 2 | -------------------------------------------------------------------------------- /mobile/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [["module:react-native-dotenv"]] 3 | } 4 | -------------------------------------------------------------------------------- /mobile/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /mobile/.editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf 4 | -------------------------------------------------------------------------------- /mobile/.env.template: -------------------------------------------------------------------------------- 1 | STRIPE_PUBLIC=pk_test_123 2 | API_URL=http://localhost:3000/api 3 | -------------------------------------------------------------------------------- /mobile/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['handlebarlabs', 'plugin:prettier/recommended'], 4 | rules: { 5 | 'no-use-before-define': 0, 6 | 'react/style-prop-object': 0, 7 | }, 8 | globals: { 9 | __DEV__: 'readonly', 10 | }, 11 | plugins: [], 12 | }; 13 | -------------------------------------------------------------------------------- /mobile/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /mobile/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | 61 | # Custom 62 | .env 63 | -------------------------------------------------------------------------------- /mobile/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | jsxBracketSameLine: false, 3 | singleQuote: true, 4 | trailingComma: 'all', 5 | arrowParens: 'avoid', 6 | }; 7 | -------------------------------------------------------------------------------- /mobile/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /mobile/App.js: -------------------------------------------------------------------------------- 1 | import App from './src'; 2 | 3 | export default App; 4 | -------------------------------------------------------------------------------- /mobile/android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.ecommapp", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.ecommapp", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /mobile/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation. If none specified and 19 | * // "index.android.js" exists, it will be used. Otherwise "index.js" is 20 | * // default. Can be overridden with ENTRY_FILE environment variable. 21 | * entryFile: "index.android.js", 22 | * 23 | * // https://reactnative.dev/docs/performance#enable-the-ram-format 24 | * bundleCommand: "ram-bundle", 25 | * 26 | * // whether to bundle JS and assets in debug mode 27 | * bundleInDebug: false, 28 | * 29 | * // whether to bundle JS and assets in release mode 30 | * bundleInRelease: true, 31 | * 32 | * // whether to bundle JS and assets in another build variant (if configured). 33 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 34 | * // The configuration property can be in the following formats 35 | * // 'bundleIn${productFlavor}${buildType}' 36 | * // 'bundleIn${buildType}' 37 | * // bundleInFreeDebug: true, 38 | * // bundleInPaidRelease: true, 39 | * // bundleInBeta: true, 40 | * 41 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 42 | * // for example: to disable dev mode in the staging build type (if configured) 43 | * devDisabledInStaging: true, 44 | * // The configuration property can be in the following formats 45 | * // 'devDisabledIn${productFlavor}${buildType}' 46 | * // 'devDisabledIn${buildType}' 47 | * 48 | * // the root of your project, i.e. where "package.json" lives 49 | * root: "../../", 50 | * 51 | * // where to put the JS bundle asset in debug mode 52 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 53 | * 54 | * // where to put the JS bundle asset in release mode 55 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 56 | * 57 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 58 | * // require('./image.png')), in debug mode 59 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 60 | * 61 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 62 | * // require('./image.png')), in release mode 63 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 64 | * 65 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 66 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 67 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 68 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 69 | * // for example, you might want to remove it from here. 70 | * inputExcludes: ["android/**", "ios/**"], 71 | * 72 | * // override which node gets called and with what additional arguments 73 | * nodeExecutableAndArgs: ["node"], 74 | * 75 | * // supply additional arguments to the packager 76 | * extraPackagerArgs: [] 77 | * ] 78 | */ 79 | 80 | project.ext.react = [ 81 | enableHermes: false, // clean and rebuild if changing 82 | ] 83 | 84 | apply from: "../../node_modules/react-native/react.gradle" 85 | 86 | /** 87 | * Set this to true to create two separate APKs instead of one: 88 | * - An APK that only works on ARM devices 89 | * - An APK that only works on x86 devices 90 | * The advantage is the size of the APK is reduced by about 4MB. 91 | * Upload all the APKs to the Play Store and people will download 92 | * the correct one based on the CPU architecture of their device. 93 | */ 94 | def enableSeparateBuildPerCPUArchitecture = false 95 | 96 | /** 97 | * Run Proguard to shrink the Java bytecode in release builds. 98 | */ 99 | def enableProguardInReleaseBuilds = false 100 | 101 | /** 102 | * The preferred build flavor of JavaScriptCore. 103 | * 104 | * For example, to use the international variant, you can use: 105 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 106 | * 107 | * The international variant includes ICU i18n library and necessary data 108 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 109 | * give correct results when using with locales other than en-US. Note that 110 | * this variant is about 6MiB larger per architecture than default. 111 | */ 112 | def jscFlavor = 'org.webkit:android-jsc:+' 113 | 114 | /** 115 | * Whether to enable the Hermes VM. 116 | * 117 | * This should be set on project.ext.react and mirrored here. If it is not set 118 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 119 | * and the benefits of using Hermes will therefore be sharply reduced. 120 | */ 121 | def enableHermes = project.ext.react.get("enableHermes", false); 122 | 123 | android { 124 | ndkVersion rootProject.ext.ndkVersion 125 | 126 | compileSdkVersion rootProject.ext.compileSdkVersion 127 | 128 | compileOptions { 129 | sourceCompatibility JavaVersion.VERSION_1_8 130 | targetCompatibility JavaVersion.VERSION_1_8 131 | } 132 | 133 | defaultConfig { 134 | applicationId "com.ecommapp" 135 | minSdkVersion rootProject.ext.minSdkVersion 136 | targetSdkVersion rootProject.ext.targetSdkVersion 137 | versionCode 1 138 | versionName "1.0" 139 | } 140 | splits { 141 | abi { 142 | reset() 143 | enable enableSeparateBuildPerCPUArchitecture 144 | universalApk false // If true, also generate a universal APK 145 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 146 | } 147 | } 148 | signingConfigs { 149 | debug { 150 | storeFile file('debug.keystore') 151 | storePassword 'android' 152 | keyAlias 'androiddebugkey' 153 | keyPassword 'android' 154 | } 155 | } 156 | buildTypes { 157 | debug { 158 | signingConfig signingConfigs.debug 159 | } 160 | release { 161 | // Caution! In production, you need to generate your own keystore file. 162 | // see https://reactnative.dev/docs/signed-apk-android. 163 | signingConfig signingConfigs.debug 164 | minifyEnabled enableProguardInReleaseBuilds 165 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 166 | } 167 | } 168 | 169 | // applicationVariants are e.g. debug, release 170 | applicationVariants.all { variant -> 171 | variant.outputs.each { output -> 172 | // For each separate APK per architecture, set a unique version code as described here: 173 | // https://developer.android.com/studio/build/configure-apk-splits.html 174 | // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. 175 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 176 | def abi = output.getFilter(OutputFile.ABI) 177 | if (abi != null) { // null for the universal-debug, universal-release variants 178 | output.versionCodeOverride = 179 | defaultConfig.versionCode * 1000 + versionCodes.get(abi) 180 | } 181 | 182 | } 183 | } 184 | } 185 | 186 | dependencies { 187 | implementation fileTree(dir: "libs", include: ["*.jar"]) 188 | //noinspection GradleDynamicVersion 189 | implementation "com.facebook.react:react-native:+" // From node_modules 190 | 191 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" 192 | 193 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { 194 | exclude group:'com.facebook.fbjni' 195 | } 196 | 197 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 198 | exclude group:'com.facebook.flipper' 199 | exclude group:'com.squareup.okhttp3', module:'okhttp' 200 | } 201 | 202 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { 203 | exclude group:'com.facebook.flipper' 204 | } 205 | 206 | if (enableHermes) { 207 | def hermesPath = "../../node_modules/hermes-engine/android/"; 208 | debugImplementation files(hermesPath + "hermes-debug.aar") 209 | releaseImplementation files(hermesPath + "hermes-release.aar") 210 | } else { 211 | implementation jscFlavor 212 | } 213 | } 214 | 215 | // Run this once to be able to run the application with BUCK 216 | // puts all compile dependencies into folder libs for BUCK to use 217 | task copyDownloadableDepsToLibs(type: Copy) { 218 | from configurations.compile 219 | into 'libs' 220 | } 221 | 222 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 223 | -------------------------------------------------------------------------------- /mobile/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /mobile/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/debug.keystore -------------------------------------------------------------------------------- /mobile/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /mobile/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /mobile/android/app/src/debug/java/com/ecommapp/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.ecommapp; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | 32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 33 | client.addPlugin(new ReactFlipperPlugin()); 34 | client.addPlugin(new DatabasesFlipperPlugin(context)); 35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 36 | client.addPlugin(CrashReporterPlugin.getInstance()); 37 | 38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 39 | NetworkingModule.setCustomClientBuilder( 40 | new NetworkingModule.CustomClientBuilder() { 41 | @Override 42 | public void apply(OkHttpClient.Builder builder) { 43 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 44 | } 45 | }); 46 | client.addPlugin(networkFlipperPlugin); 47 | client.start(); 48 | 49 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 50 | // Hence we run if after all native modules have been initialized 51 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 52 | if (reactContext == null) { 53 | reactInstanceManager.addReactInstanceEventListener( 54 | new ReactInstanceManager.ReactInstanceEventListener() { 55 | @Override 56 | public void onReactContextInitialized(ReactContext reactContext) { 57 | reactInstanceManager.removeReactInstanceEventListener(this); 58 | reactContext.runOnNativeModulesQueueThread( 59 | new Runnable() { 60 | @Override 61 | public void run() { 62 | client.addPlugin(new FrescoFlipperPlugin()); 63 | } 64 | }); 65 | } 66 | }); 67 | } else { 68 | client.addPlugin(new FrescoFlipperPlugin()); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /mobile/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /mobile/android/app/src/main/java/com/ecommapp/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.ecommapp; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "EcommApp"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /mobile/android/app/src/main/java/com/ecommapp/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.ecommapp; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.soloader.SoLoader; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = 17 | new ReactNativeHost(this) { 18 | @Override 19 | public boolean getUseDeveloperSupport() { 20 | return BuildConfig.DEBUG; 21 | } 22 | 23 | @Override 24 | protected List getPackages() { 25 | @SuppressWarnings("UnnecessaryLocalVariable") 26 | List packages = new PackageList(this).getPackages(); 27 | // Packages that cannot be autolinked yet can be added manually here, for example: 28 | // packages.add(new MyReactNativePackage()); 29 | return packages; 30 | } 31 | 32 | @Override 33 | protected String getJSMainModuleName() { 34 | return "index"; 35 | } 36 | }; 37 | 38 | @Override 39 | public ReactNativeHost getReactNativeHost() { 40 | return mReactNativeHost; 41 | } 42 | 43 | @Override 44 | public void onCreate() { 45 | super.onCreate(); 46 | SoLoader.init(this, /* native exopackage */ false); 47 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 48 | } 49 | 50 | /** 51 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like 52 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 53 | * 54 | * @param context 55 | * @param reactInstanceManager 56 | */ 57 | private static void initializeFlipper( 58 | Context context, ReactInstanceManager reactInstanceManager) { 59 | if (BuildConfig.DEBUG) { 60 | try { 61 | /* 62 | We use reflection here to pick up the class that initializes Flipper, 63 | since Flipper library is not available in release mode 64 | */ 65 | Class aClass = Class.forName("com.ecommapp.ReactNativeFlipper"); 66 | aClass 67 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 68 | .invoke(null, context, reactInstanceManager); 69 | } catch (ClassNotFoundException e) { 70 | e.printStackTrace(); 71 | } catch (NoSuchMethodException e) { 72 | e.printStackTrace(); 73 | } catch (IllegalAccessException e) { 74 | e.printStackTrace(); 75 | } catch (InvocationTargetException e) { 76 | e.printStackTrace(); 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | EcommApp 3 | 4 | -------------------------------------------------------------------------------- /mobile/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "29.0.3" 6 | minSdkVersion = 21 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | ndkVersion = "20.1.5948944" 10 | } 11 | repositories { 12 | google() 13 | jcenter() 14 | } 15 | dependencies { 16 | classpath("com.android.tools.build:gradle:4.1.0") 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | mavenLocal() 25 | maven { 26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 27 | url("$rootDir/../node_modules/react-native/android") 28 | } 29 | maven { 30 | // Android JSC is installed from npm 31 | url("$rootDir/../node_modules/jsc-android/dist") 32 | } 33 | 34 | google() 35 | jcenter() 36 | maven { url 'https://www.jitpack.io' } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mobile/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.75.1 29 | -------------------------------------------------------------------------------- /mobile/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /mobile/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /mobile/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /mobile/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /mobile/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'EcommApp' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /mobile/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "EcommApp", 3 | "displayName": "EcommApp" 4 | } -------------------------------------------------------------------------------- /mobile/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /mobile/index.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | import App from './src'; 3 | import { name as appName } from './app.json'; 4 | 5 | AppRegistry.registerComponent(appName, () => App); 6 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 54; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 00E356F31AD99517003FC87E /* EcommAppTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* EcommAppTests.m */; }; 11 | 09B8B813267BEE69006CEC2D /* Fix.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B8B812267BEE69006CEC2D /* Fix.swift */; }; 12 | 0E7FAD836BB2A8F7D275F67E /* libPods-EcommApp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DD9A3D088D0D0DC960495E9E /* libPods-EcommApp.a */; }; 13 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; 14 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 15 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 16 | 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; 17 | 903A41DE398D3E1CE0A2A647 /* libPods-EcommApp-EcommAppTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA50C8E9277F81A620188254 /* libPods-EcommApp-EcommAppTests.a */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 13B07F861A680F5B00A75B9A; 26 | remoteInfo = EcommApp; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 00E356EE1AD99517003FC87E /* EcommAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = EcommAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 00E356F21AD99517003FC87E /* EcommAppTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EcommAppTests.m; sourceTree = ""; }; 34 | 09B8B811267BEE68006CEC2D /* EcommApp-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "EcommApp-Bridging-Header.h"; sourceTree = ""; }; 35 | 09B8B812267BEE69006CEC2D /* Fix.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fix.swift; sourceTree = ""; }; 36 | 13B07F961A680F5B00A75B9A /* EcommApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EcommApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = EcommApp/AppDelegate.h; sourceTree = ""; }; 38 | 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = EcommApp/AppDelegate.m; sourceTree = ""; }; 39 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = EcommApp/Images.xcassets; sourceTree = ""; }; 40 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = EcommApp/Info.plist; sourceTree = ""; }; 41 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = EcommApp/main.m; sourceTree = ""; }; 42 | 48E14C5BFC7DB0F5F90A0A61 /* Pods-EcommApp-EcommAppTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EcommApp-EcommAppTests.debug.xcconfig"; path = "Target Support Files/Pods-EcommApp-EcommAppTests/Pods-EcommApp-EcommAppTests.debug.xcconfig"; sourceTree = ""; }; 43 | 4DF6D5EAE34B4D4A1E145B15 /* Pods-EcommApp-EcommAppTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EcommApp-EcommAppTests.release.xcconfig"; path = "Target Support Files/Pods-EcommApp-EcommAppTests/Pods-EcommApp-EcommAppTests.release.xcconfig"; sourceTree = ""; }; 44 | 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = EcommApp/LaunchScreen.storyboard; sourceTree = ""; }; 45 | 9B8F396B3AD72BCDCFC367D1 /* Pods-EcommApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EcommApp.debug.xcconfig"; path = "Target Support Files/Pods-EcommApp/Pods-EcommApp.debug.xcconfig"; sourceTree = ""; }; 46 | 9CEE5A620FB48493B59A544B /* Pods-EcommApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EcommApp.release.xcconfig"; path = "Target Support Files/Pods-EcommApp/Pods-EcommApp.release.xcconfig"; sourceTree = ""; }; 47 | DD9A3D088D0D0DC960495E9E /* libPods-EcommApp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-EcommApp.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; 49 | FA50C8E9277F81A620188254 /* libPods-EcommApp-EcommAppTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-EcommApp-EcommAppTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 00E356EB1AD99517003FC87E /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | 903A41DE398D3E1CE0A2A647 /* libPods-EcommApp-EcommAppTests.a in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { 62 | isa = PBXFrameworksBuildPhase; 63 | buildActionMask = 2147483647; 64 | files = ( 65 | 0E7FAD836BB2A8F7D275F67E /* libPods-EcommApp.a in Frameworks */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXFrameworksBuildPhase section */ 70 | 71 | /* Begin PBXGroup section */ 72 | 00E356EF1AD99517003FC87E /* EcommAppTests */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 00E356F21AD99517003FC87E /* EcommAppTests.m */, 76 | 00E356F01AD99517003FC87E /* Supporting Files */, 77 | ); 78 | path = EcommAppTests; 79 | sourceTree = ""; 80 | }; 81 | 00E356F01AD99517003FC87E /* Supporting Files */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 00E356F11AD99517003FC87E /* Info.plist */, 85 | ); 86 | name = "Supporting Files"; 87 | sourceTree = ""; 88 | }; 89 | 13B07FAE1A68108700A75B9A /* EcommApp */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 93 | 13B07FB01A68108700A75B9A /* AppDelegate.m */, 94 | 13B07FB51A68108700A75B9A /* Images.xcassets */, 95 | 13B07FB61A68108700A75B9A /* Info.plist */, 96 | 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, 97 | 13B07FB71A68108700A75B9A /* main.m */, 98 | ); 99 | name = EcommApp; 100 | sourceTree = ""; 101 | }; 102 | 2D16E6871FA4F8E400B85C8A /* Frameworks */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */, 106 | DD9A3D088D0D0DC960495E9E /* libPods-EcommApp.a */, 107 | FA50C8E9277F81A620188254 /* libPods-EcommApp-EcommAppTests.a */, 108 | ); 109 | name = Frameworks; 110 | sourceTree = ""; 111 | }; 112 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | ); 116 | name = Libraries; 117 | sourceTree = ""; 118 | }; 119 | 83CBB9F61A601CBA00E9B192 = { 120 | isa = PBXGroup; 121 | children = ( 122 | 09B8B812267BEE69006CEC2D /* Fix.swift */, 123 | 13B07FAE1A68108700A75B9A /* EcommApp */, 124 | 832341AE1AAA6A7D00B99B32 /* Libraries */, 125 | 00E356EF1AD99517003FC87E /* EcommAppTests */, 126 | 83CBBA001A601CBA00E9B192 /* Products */, 127 | 2D16E6871FA4F8E400B85C8A /* Frameworks */, 128 | EC1D74A55078DFF59E9BF82E /* Pods */, 129 | 09B8B811267BEE68006CEC2D /* EcommApp-Bridging-Header.h */, 130 | ); 131 | indentWidth = 2; 132 | sourceTree = ""; 133 | tabWidth = 2; 134 | usesTabs = 0; 135 | }; 136 | 83CBBA001A601CBA00E9B192 /* Products */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 13B07F961A680F5B00A75B9A /* EcommApp.app */, 140 | 00E356EE1AD99517003FC87E /* EcommAppTests.xctest */, 141 | ); 142 | name = Products; 143 | sourceTree = ""; 144 | }; 145 | EC1D74A55078DFF59E9BF82E /* Pods */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | 9B8F396B3AD72BCDCFC367D1 /* Pods-EcommApp.debug.xcconfig */, 149 | 9CEE5A620FB48493B59A544B /* Pods-EcommApp.release.xcconfig */, 150 | 48E14C5BFC7DB0F5F90A0A61 /* Pods-EcommApp-EcommAppTests.debug.xcconfig */, 151 | 4DF6D5EAE34B4D4A1E145B15 /* Pods-EcommApp-EcommAppTests.release.xcconfig */, 152 | ); 153 | path = Pods; 154 | sourceTree = ""; 155 | }; 156 | /* End PBXGroup section */ 157 | 158 | /* Begin PBXNativeTarget section */ 159 | 00E356ED1AD99517003FC87E /* EcommAppTests */ = { 160 | isa = PBXNativeTarget; 161 | buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "EcommAppTests" */; 162 | buildPhases = ( 163 | 4D33926C7E2900A5A0EB7F68 /* [CP] Check Pods Manifest.lock */, 164 | 00E356EA1AD99517003FC87E /* Sources */, 165 | 00E356EB1AD99517003FC87E /* Frameworks */, 166 | 00E356EC1AD99517003FC87E /* Resources */, 167 | 32AB845A4DB702BC01E0A932 /* [CP] Embed Pods Frameworks */, 168 | 125CCD00EAC1C7D6BE12C3BC /* [CP] Copy Pods Resources */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | 00E356F51AD99517003FC87E /* PBXTargetDependency */, 174 | ); 175 | name = EcommAppTests; 176 | productName = EcommAppTests; 177 | productReference = 00E356EE1AD99517003FC87E /* EcommAppTests.xctest */; 178 | productType = "com.apple.product-type.bundle.unit-test"; 179 | }; 180 | 13B07F861A680F5B00A75B9A /* EcommApp */ = { 181 | isa = PBXNativeTarget; 182 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "EcommApp" */; 183 | buildPhases = ( 184 | 37A65E46EEC4191AC8949E9E /* [CP] Check Pods Manifest.lock */, 185 | FD10A7F022414F080027D42C /* Start Packager */, 186 | 13B07F871A680F5B00A75B9A /* Sources */, 187 | 13B07F8C1A680F5B00A75B9A /* Frameworks */, 188 | 13B07F8E1A680F5B00A75B9A /* Resources */, 189 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 190 | 4E29FE9C1B200F1BF10BC556 /* [CP] Embed Pods Frameworks */, 191 | 8B9C797EAF30DD1C9A8AA237 /* [CP] Copy Pods Resources */, 192 | ); 193 | buildRules = ( 194 | ); 195 | dependencies = ( 196 | ); 197 | name = EcommApp; 198 | productName = EcommApp; 199 | productReference = 13B07F961A680F5B00A75B9A /* EcommApp.app */; 200 | productType = "com.apple.product-type.application"; 201 | }; 202 | /* End PBXNativeTarget section */ 203 | 204 | /* Begin PBXProject section */ 205 | 83CBB9F71A601CBA00E9B192 /* Project object */ = { 206 | isa = PBXProject; 207 | attributes = { 208 | LastUpgradeCheck = 1210; 209 | TargetAttributes = { 210 | 00E356ED1AD99517003FC87E = { 211 | CreatedOnToolsVersion = 6.2; 212 | TestTargetID = 13B07F861A680F5B00A75B9A; 213 | }; 214 | 13B07F861A680F5B00A75B9A = { 215 | LastSwiftMigration = 1250; 216 | }; 217 | }; 218 | }; 219 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "EcommApp" */; 220 | compatibilityVersion = "Xcode 12.0"; 221 | developmentRegion = en; 222 | hasScannedForEncodings = 0; 223 | knownRegions = ( 224 | en, 225 | Base, 226 | ); 227 | mainGroup = 83CBB9F61A601CBA00E9B192; 228 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; 229 | projectDirPath = ""; 230 | projectRoot = ""; 231 | targets = ( 232 | 13B07F861A680F5B00A75B9A /* EcommApp */, 233 | 00E356ED1AD99517003FC87E /* EcommAppTests */, 234 | ); 235 | }; 236 | /* End PBXProject section */ 237 | 238 | /* Begin PBXResourcesBuildPhase section */ 239 | 00E356EC1AD99517003FC87E /* Resources */ = { 240 | isa = PBXResourcesBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | ); 244 | runOnlyForDeploymentPostprocessing = 0; 245 | }; 246 | 13B07F8E1A680F5B00A75B9A /* Resources */ = { 247 | isa = PBXResourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 251 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | /* End PBXResourcesBuildPhase section */ 256 | 257 | /* Begin PBXShellScriptBuildPhase section */ 258 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { 259 | isa = PBXShellScriptBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | ); 263 | inputPaths = ( 264 | ); 265 | name = "Bundle React Native code and images"; 266 | outputPaths = ( 267 | ); 268 | runOnlyForDeploymentPostprocessing = 0; 269 | shellPath = /bin/sh; 270 | shellScript = "set -e\n\nexport NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; 271 | }; 272 | 125CCD00EAC1C7D6BE12C3BC /* [CP] Copy Pods Resources */ = { 273 | isa = PBXShellScriptBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | inputFileListPaths = ( 278 | "${PODS_ROOT}/Target Support Files/Pods-EcommApp-EcommAppTests/Pods-EcommApp-EcommAppTests-resources-${CONFIGURATION}-input-files.xcfilelist", 279 | ); 280 | name = "[CP] Copy Pods Resources"; 281 | outputFileListPaths = ( 282 | "${PODS_ROOT}/Target Support Files/Pods-EcommApp-EcommAppTests/Pods-EcommApp-EcommAppTests-resources-${CONFIGURATION}-output-files.xcfilelist", 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | shellPath = /bin/sh; 286 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-EcommApp-EcommAppTests/Pods-EcommApp-EcommAppTests-resources.sh\"\n"; 287 | showEnvVarsInLog = 0; 288 | }; 289 | 32AB845A4DB702BC01E0A932 /* [CP] Embed Pods Frameworks */ = { 290 | isa = PBXShellScriptBuildPhase; 291 | buildActionMask = 2147483647; 292 | files = ( 293 | ); 294 | inputFileListPaths = ( 295 | "${PODS_ROOT}/Target Support Files/Pods-EcommApp-EcommAppTests/Pods-EcommApp-EcommAppTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", 296 | ); 297 | name = "[CP] Embed Pods Frameworks"; 298 | outputFileListPaths = ( 299 | "${PODS_ROOT}/Target Support Files/Pods-EcommApp-EcommAppTests/Pods-EcommApp-EcommAppTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | shellPath = /bin/sh; 303 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-EcommApp-EcommAppTests/Pods-EcommApp-EcommAppTests-frameworks.sh\"\n"; 304 | showEnvVarsInLog = 0; 305 | }; 306 | 37A65E46EEC4191AC8949E9E /* [CP] Check Pods Manifest.lock */ = { 307 | isa = PBXShellScriptBuildPhase; 308 | buildActionMask = 2147483647; 309 | files = ( 310 | ); 311 | inputFileListPaths = ( 312 | ); 313 | inputPaths = ( 314 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 315 | "${PODS_ROOT}/Manifest.lock", 316 | ); 317 | name = "[CP] Check Pods Manifest.lock"; 318 | outputFileListPaths = ( 319 | ); 320 | outputPaths = ( 321 | "$(DERIVED_FILE_DIR)/Pods-EcommApp-checkManifestLockResult.txt", 322 | ); 323 | runOnlyForDeploymentPostprocessing = 0; 324 | shellPath = /bin/sh; 325 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 326 | showEnvVarsInLog = 0; 327 | }; 328 | 4D33926C7E2900A5A0EB7F68 /* [CP] Check Pods Manifest.lock */ = { 329 | isa = PBXShellScriptBuildPhase; 330 | buildActionMask = 2147483647; 331 | files = ( 332 | ); 333 | inputFileListPaths = ( 334 | ); 335 | inputPaths = ( 336 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 337 | "${PODS_ROOT}/Manifest.lock", 338 | ); 339 | name = "[CP] Check Pods Manifest.lock"; 340 | outputFileListPaths = ( 341 | ); 342 | outputPaths = ( 343 | "$(DERIVED_FILE_DIR)/Pods-EcommApp-EcommAppTests-checkManifestLockResult.txt", 344 | ); 345 | runOnlyForDeploymentPostprocessing = 0; 346 | shellPath = /bin/sh; 347 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 348 | showEnvVarsInLog = 0; 349 | }; 350 | 4E29FE9C1B200F1BF10BC556 /* [CP] Embed Pods Frameworks */ = { 351 | isa = PBXShellScriptBuildPhase; 352 | buildActionMask = 2147483647; 353 | files = ( 354 | ); 355 | inputFileListPaths = ( 356 | "${PODS_ROOT}/Target Support Files/Pods-EcommApp/Pods-EcommApp-frameworks-${CONFIGURATION}-input-files.xcfilelist", 357 | ); 358 | name = "[CP] Embed Pods Frameworks"; 359 | outputFileListPaths = ( 360 | "${PODS_ROOT}/Target Support Files/Pods-EcommApp/Pods-EcommApp-frameworks-${CONFIGURATION}-output-files.xcfilelist", 361 | ); 362 | runOnlyForDeploymentPostprocessing = 0; 363 | shellPath = /bin/sh; 364 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-EcommApp/Pods-EcommApp-frameworks.sh\"\n"; 365 | showEnvVarsInLog = 0; 366 | }; 367 | 8B9C797EAF30DD1C9A8AA237 /* [CP] Copy Pods Resources */ = { 368 | isa = PBXShellScriptBuildPhase; 369 | buildActionMask = 2147483647; 370 | files = ( 371 | ); 372 | inputFileListPaths = ( 373 | "${PODS_ROOT}/Target Support Files/Pods-EcommApp/Pods-EcommApp-resources-${CONFIGURATION}-input-files.xcfilelist", 374 | ); 375 | name = "[CP] Copy Pods Resources"; 376 | outputFileListPaths = ( 377 | "${PODS_ROOT}/Target Support Files/Pods-EcommApp/Pods-EcommApp-resources-${CONFIGURATION}-output-files.xcfilelist", 378 | ); 379 | runOnlyForDeploymentPostprocessing = 0; 380 | shellPath = /bin/sh; 381 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-EcommApp/Pods-EcommApp-resources.sh\"\n"; 382 | showEnvVarsInLog = 0; 383 | }; 384 | FD10A7F022414F080027D42C /* Start Packager */ = { 385 | isa = PBXShellScriptBuildPhase; 386 | buildActionMask = 2147483647; 387 | files = ( 388 | ); 389 | inputFileListPaths = ( 390 | ); 391 | inputPaths = ( 392 | ); 393 | name = "Start Packager"; 394 | outputFileListPaths = ( 395 | ); 396 | outputPaths = ( 397 | ); 398 | runOnlyForDeploymentPostprocessing = 0; 399 | shellPath = /bin/sh; 400 | shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n"; 401 | showEnvVarsInLog = 0; 402 | }; 403 | /* End PBXShellScriptBuildPhase section */ 404 | 405 | /* Begin PBXSourcesBuildPhase section */ 406 | 00E356EA1AD99517003FC87E /* Sources */ = { 407 | isa = PBXSourcesBuildPhase; 408 | buildActionMask = 2147483647; 409 | files = ( 410 | 00E356F31AD99517003FC87E /* EcommAppTests.m in Sources */, 411 | ); 412 | runOnlyForDeploymentPostprocessing = 0; 413 | }; 414 | 13B07F871A680F5B00A75B9A /* Sources */ = { 415 | isa = PBXSourcesBuildPhase; 416 | buildActionMask = 2147483647; 417 | files = ( 418 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, 419 | 09B8B813267BEE69006CEC2D /* Fix.swift in Sources */, 420 | 13B07FC11A68108700A75B9A /* main.m in Sources */, 421 | ); 422 | runOnlyForDeploymentPostprocessing = 0; 423 | }; 424 | /* End PBXSourcesBuildPhase section */ 425 | 426 | /* Begin PBXTargetDependency section */ 427 | 00E356F51AD99517003FC87E /* PBXTargetDependency */ = { 428 | isa = PBXTargetDependency; 429 | target = 13B07F861A680F5B00A75B9A /* EcommApp */; 430 | targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; 431 | }; 432 | /* End PBXTargetDependency section */ 433 | 434 | /* Begin XCBuildConfiguration section */ 435 | 00E356F61AD99517003FC87E /* Debug */ = { 436 | isa = XCBuildConfiguration; 437 | baseConfigurationReference = 48E14C5BFC7DB0F5F90A0A61 /* Pods-EcommApp-EcommAppTests.debug.xcconfig */; 438 | buildSettings = { 439 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 440 | BUNDLE_LOADER = "$(TEST_HOST)"; 441 | GCC_PREPROCESSOR_DEFINITIONS = ( 442 | "DEBUG=1", 443 | "$(inherited)", 444 | ); 445 | INFOPLIST_FILE = EcommAppTests/Info.plist; 446 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 447 | LD_RUNPATH_SEARCH_PATHS = ( 448 | "$(inherited)", 449 | "@executable_path/Frameworks", 450 | "@loader_path/Frameworks", 451 | ); 452 | OTHER_LDFLAGS = ( 453 | "-ObjC", 454 | "-lc++", 455 | "$(inherited)", 456 | ); 457 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 458 | PRODUCT_NAME = "$(TARGET_NAME)"; 459 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/EcommApp.app/EcommApp"; 460 | }; 461 | name = Debug; 462 | }; 463 | 00E356F71AD99517003FC87E /* Release */ = { 464 | isa = XCBuildConfiguration; 465 | baseConfigurationReference = 4DF6D5EAE34B4D4A1E145B15 /* Pods-EcommApp-EcommAppTests.release.xcconfig */; 466 | buildSettings = { 467 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 468 | BUNDLE_LOADER = "$(TEST_HOST)"; 469 | COPY_PHASE_STRIP = NO; 470 | INFOPLIST_FILE = EcommAppTests/Info.plist; 471 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 472 | LD_RUNPATH_SEARCH_PATHS = ( 473 | "$(inherited)", 474 | "@executable_path/Frameworks", 475 | "@loader_path/Frameworks", 476 | ); 477 | OTHER_LDFLAGS = ( 478 | "-ObjC", 479 | "-lc++", 480 | "$(inherited)", 481 | ); 482 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/EcommApp.app/EcommApp"; 485 | }; 486 | name = Release; 487 | }; 488 | 13B07F941A680F5B00A75B9A /* Debug */ = { 489 | isa = XCBuildConfiguration; 490 | baseConfigurationReference = 9B8F396B3AD72BCDCFC367D1 /* Pods-EcommApp.debug.xcconfig */; 491 | buildSettings = { 492 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 493 | CLANG_ENABLE_MODULES = YES; 494 | CURRENT_PROJECT_VERSION = 1; 495 | ENABLE_BITCODE = NO; 496 | INFOPLIST_FILE = EcommApp/Info.plist; 497 | LD_RUNPATH_SEARCH_PATHS = ( 498 | "$(inherited)", 499 | "@executable_path/Frameworks", 500 | ); 501 | OTHER_LDFLAGS = ( 502 | "$(inherited)", 503 | "-ObjC", 504 | "-lc++", 505 | ); 506 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 507 | PRODUCT_NAME = EcommApp; 508 | SWIFT_OBJC_BRIDGING_HEADER = "EcommApp-Bridging-Header.h"; 509 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 510 | SWIFT_VERSION = 5.0; 511 | VERSIONING_SYSTEM = "apple-generic"; 512 | }; 513 | name = Debug; 514 | }; 515 | 13B07F951A680F5B00A75B9A /* Release */ = { 516 | isa = XCBuildConfiguration; 517 | baseConfigurationReference = 9CEE5A620FB48493B59A544B /* Pods-EcommApp.release.xcconfig */; 518 | buildSettings = { 519 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 520 | CLANG_ENABLE_MODULES = YES; 521 | CURRENT_PROJECT_VERSION = 1; 522 | INFOPLIST_FILE = EcommApp/Info.plist; 523 | LD_RUNPATH_SEARCH_PATHS = ( 524 | "$(inherited)", 525 | "@executable_path/Frameworks", 526 | ); 527 | OTHER_LDFLAGS = ( 528 | "$(inherited)", 529 | "-ObjC", 530 | "-lc++", 531 | ); 532 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 533 | PRODUCT_NAME = EcommApp; 534 | SWIFT_OBJC_BRIDGING_HEADER = "EcommApp-Bridging-Header.h"; 535 | SWIFT_VERSION = 5.0; 536 | VERSIONING_SYSTEM = "apple-generic"; 537 | }; 538 | name = Release; 539 | }; 540 | 83CBBA201A601CBA00E9B192 /* Debug */ = { 541 | isa = XCBuildConfiguration; 542 | buildSettings = { 543 | ALWAYS_SEARCH_USER_PATHS = NO; 544 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 545 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 546 | CLANG_CXX_LIBRARY = "libc++"; 547 | CLANG_ENABLE_MODULES = YES; 548 | CLANG_ENABLE_OBJC_ARC = YES; 549 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 550 | CLANG_WARN_BOOL_CONVERSION = YES; 551 | CLANG_WARN_COMMA = YES; 552 | CLANG_WARN_CONSTANT_CONVERSION = YES; 553 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 554 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 555 | CLANG_WARN_EMPTY_BODY = YES; 556 | CLANG_WARN_ENUM_CONVERSION = YES; 557 | CLANG_WARN_INFINITE_RECURSION = YES; 558 | CLANG_WARN_INT_CONVERSION = YES; 559 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 560 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 561 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 562 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 563 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 564 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 565 | CLANG_WARN_STRICT_PROTOTYPES = YES; 566 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 567 | CLANG_WARN_UNREACHABLE_CODE = YES; 568 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 569 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 570 | COPY_PHASE_STRIP = NO; 571 | ENABLE_STRICT_OBJC_MSGSEND = YES; 572 | ENABLE_TESTABILITY = YES; 573 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 "; 574 | GCC_C_LANGUAGE_STANDARD = gnu99; 575 | GCC_DYNAMIC_NO_PIC = NO; 576 | GCC_NO_COMMON_BLOCKS = YES; 577 | GCC_OPTIMIZATION_LEVEL = 0; 578 | GCC_PREPROCESSOR_DEFINITIONS = ( 579 | "DEBUG=1", 580 | "$(inherited)", 581 | ); 582 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 583 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 584 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 585 | GCC_WARN_UNDECLARED_SELECTOR = YES; 586 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 587 | GCC_WARN_UNUSED_FUNCTION = YES; 588 | GCC_WARN_UNUSED_VARIABLE = YES; 589 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 590 | LD_RUNPATH_SEARCH_PATHS = ( 591 | /usr/lib/swift, 592 | "$(inherited)", 593 | ); 594 | LIBRARY_SEARCH_PATHS = ( 595 | "\"$(inherited)\"", 596 | ); 597 | MTL_ENABLE_DEBUG_INFO = YES; 598 | ONLY_ACTIVE_ARCH = YES; 599 | SDKROOT = iphoneos; 600 | }; 601 | name = Debug; 602 | }; 603 | 83CBBA211A601CBA00E9B192 /* Release */ = { 604 | isa = XCBuildConfiguration; 605 | buildSettings = { 606 | ALWAYS_SEARCH_USER_PATHS = NO; 607 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 608 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 609 | CLANG_CXX_LIBRARY = "libc++"; 610 | CLANG_ENABLE_MODULES = YES; 611 | CLANG_ENABLE_OBJC_ARC = YES; 612 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 613 | CLANG_WARN_BOOL_CONVERSION = YES; 614 | CLANG_WARN_COMMA = YES; 615 | CLANG_WARN_CONSTANT_CONVERSION = YES; 616 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 617 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 618 | CLANG_WARN_EMPTY_BODY = YES; 619 | CLANG_WARN_ENUM_CONVERSION = YES; 620 | CLANG_WARN_INFINITE_RECURSION = YES; 621 | CLANG_WARN_INT_CONVERSION = YES; 622 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 623 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 624 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 625 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 626 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 627 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 628 | CLANG_WARN_STRICT_PROTOTYPES = YES; 629 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 630 | CLANG_WARN_UNREACHABLE_CODE = YES; 631 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 632 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 633 | COPY_PHASE_STRIP = YES; 634 | ENABLE_NS_ASSERTIONS = NO; 635 | ENABLE_STRICT_OBJC_MSGSEND = YES; 636 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 "; 637 | GCC_C_LANGUAGE_STANDARD = gnu99; 638 | GCC_NO_COMMON_BLOCKS = YES; 639 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 640 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 641 | GCC_WARN_UNDECLARED_SELECTOR = YES; 642 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 643 | GCC_WARN_UNUSED_FUNCTION = YES; 644 | GCC_WARN_UNUSED_VARIABLE = YES; 645 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 646 | LD_RUNPATH_SEARCH_PATHS = ( 647 | /usr/lib/swift, 648 | "$(inherited)", 649 | ); 650 | LIBRARY_SEARCH_PATHS = ( 651 | "\"$(inherited)\"", 652 | ); 653 | MTL_ENABLE_DEBUG_INFO = NO; 654 | SDKROOT = iphoneos; 655 | VALIDATE_PRODUCT = YES; 656 | }; 657 | name = Release; 658 | }; 659 | /* End XCBuildConfiguration section */ 660 | 661 | /* Begin XCConfigurationList section */ 662 | 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "EcommAppTests" */ = { 663 | isa = XCConfigurationList; 664 | buildConfigurations = ( 665 | 00E356F61AD99517003FC87E /* Debug */, 666 | 00E356F71AD99517003FC87E /* Release */, 667 | ); 668 | defaultConfigurationIsVisible = 0; 669 | defaultConfigurationName = Release; 670 | }; 671 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "EcommApp" */ = { 672 | isa = XCConfigurationList; 673 | buildConfigurations = ( 674 | 13B07F941A680F5B00A75B9A /* Debug */, 675 | 13B07F951A680F5B00A75B9A /* Release */, 676 | ); 677 | defaultConfigurationIsVisible = 0; 678 | defaultConfigurationName = Release; 679 | }; 680 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "EcommApp" */ = { 681 | isa = XCConfigurationList; 682 | buildConfigurations = ( 683 | 83CBBA201A601CBA00E9B192 /* Debug */, 684 | 83CBBA211A601CBA00E9B192 /* Release */, 685 | ); 686 | defaultConfigurationIsVisible = 0; 687 | defaultConfigurationName = Release; 688 | }; 689 | /* End XCConfigurationList section */ 690 | }; 691 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; 692 | } 693 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp.xcodeproj/xcshareddata/xcschemes/EcommApp.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | #ifdef FB_SONARKIT_ENABLED 8 | #import 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | static void InitializeFlipper(UIApplication *application) { 16 | FlipperClient *client = [FlipperClient sharedClient]; 17 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 18 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 19 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 20 | [client addPlugin:[FlipperKitReactPlugin new]]; 21 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 22 | [client start]; 23 | } 24 | #endif 25 | 26 | @implementation AppDelegate 27 | 28 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 29 | { 30 | #ifdef FB_SONARKIT_ENABLED 31 | InitializeFlipper(application); 32 | #endif 33 | 34 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 35 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 36 | moduleName:@"EcommApp" 37 | initialProperties:nil]; 38 | 39 | if (@available(iOS 13.0, *)) { 40 | rootView.backgroundColor = [UIColor systemBackgroundColor]; 41 | } else { 42 | rootView.backgroundColor = [UIColor whiteColor]; 43 | } 44 | 45 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 46 | UIViewController *rootViewController = [UIViewController new]; 47 | rootViewController.view = rootView; 48 | self.window.rootViewController = rootViewController; 49 | [self.window makeKeyAndVisible]; 50 | return YES; 51 | } 52 | 53 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 54 | { 55 | #if DEBUG 56 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 57 | #else 58 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 59 | #endif 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /mobile/ios/EcommApp/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | EcommApp 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSExceptionDomains 30 | 31 | localhost 32 | 33 | NSExceptionAllowsInsecureHTTPLoads 34 | 35 | 36 | 37 | 38 | NSLocationWhenInUseUsageDescription 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UIViewControllerBasedStatusBarAppearance 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /mobile/ios/EcommApp/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /mobile/ios/EcommAppTests/EcommAppTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface EcommAppTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation EcommAppTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 38 | if (level >= RCTLogLevelError) { 39 | redboxError = message; 40 | } 41 | }); 42 | #endif 43 | 44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | 48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 50 | return YES; 51 | } 52 | return NO; 53 | }]; 54 | } 55 | 56 | #ifdef DEBUG 57 | RCTSetLogFunction(RCTDefaultLogFunction); 58 | #endif 59 | 60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 62 | } 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /mobile/ios/EcommAppTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /mobile/ios/Fix.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Fix.swift 3 | // EcommApp 4 | // 5 | // Created by Spencer Carli on 6/17/21. 6 | // 7 | 8 | import Foundation 9 | -------------------------------------------------------------------------------- /mobile/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '11.0' 5 | 6 | target 'EcommApp' do 7 | config = use_native_modules! 8 | 9 | use_react_native!( 10 | :path => config[:reactNativePath], 11 | # to enable hermes on iOS, change `false` to `true` and then install pods 12 | :hermes_enabled => false 13 | ) 14 | 15 | target 'EcommAppTests' do 16 | inherit! :complete 17 | # Pods for testing 18 | end 19 | 20 | # Enables Flipper. 21 | # 22 | # Note that if you have use_frameworks! enabled, Flipper will not work and 23 | # you should disable the next line. 24 | use_flipper!() 25 | 26 | post_install do |installer| 27 | react_native_post_install(installer) 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /mobile/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - boost-for-react-native (1.63.0) 3 | - CocoaAsyncSocket (7.6.5) 4 | - DoubleConversion (1.1.6) 5 | - FBLazyVector (0.64.1) 6 | - FBReactNativeSpec (0.64.1): 7 | - RCT-Folly (= 2020.01.13.00) 8 | - RCTRequired (= 0.64.1) 9 | - RCTTypeSafety (= 0.64.1) 10 | - React-Core (= 0.64.1) 11 | - React-jsi (= 0.64.1) 12 | - ReactCommon/turbomodule/core (= 0.64.1) 13 | - Flipper (0.75.1): 14 | - Flipper-Folly (~> 2.5) 15 | - Flipper-RSocket (~> 1.3) 16 | - Flipper-DoubleConversion (1.1.7) 17 | - Flipper-Folly (2.5.3): 18 | - boost-for-react-native 19 | - Flipper-DoubleConversion 20 | - Flipper-Glog 21 | - libevent (~> 2.1.12) 22 | - OpenSSL-Universal (= 1.1.180) 23 | - Flipper-Glog (0.3.6) 24 | - Flipper-PeerTalk (0.0.4) 25 | - Flipper-RSocket (1.3.1): 26 | - Flipper-Folly (~> 2.5) 27 | - FlipperKit (0.75.1): 28 | - FlipperKit/Core (= 0.75.1) 29 | - FlipperKit/Core (0.75.1): 30 | - Flipper (~> 0.75.1) 31 | - FlipperKit/CppBridge 32 | - FlipperKit/FBCxxFollyDynamicConvert 33 | - FlipperKit/FBDefines 34 | - FlipperKit/FKPortForwarding 35 | - FlipperKit/CppBridge (0.75.1): 36 | - Flipper (~> 0.75.1) 37 | - FlipperKit/FBCxxFollyDynamicConvert (0.75.1): 38 | - Flipper-Folly (~> 2.5) 39 | - FlipperKit/FBDefines (0.75.1) 40 | - FlipperKit/FKPortForwarding (0.75.1): 41 | - CocoaAsyncSocket (~> 7.6) 42 | - Flipper-PeerTalk (~> 0.0.4) 43 | - FlipperKit/FlipperKitHighlightOverlay (0.75.1) 44 | - FlipperKit/FlipperKitLayoutPlugin (0.75.1): 45 | - FlipperKit/Core 46 | - FlipperKit/FlipperKitHighlightOverlay 47 | - FlipperKit/FlipperKitLayoutTextSearchable 48 | - YogaKit (~> 1.18) 49 | - FlipperKit/FlipperKitLayoutTextSearchable (0.75.1) 50 | - FlipperKit/FlipperKitNetworkPlugin (0.75.1): 51 | - FlipperKit/Core 52 | - FlipperKit/FlipperKitReactPlugin (0.75.1): 53 | - FlipperKit/Core 54 | - FlipperKit/FlipperKitUserDefaultsPlugin (0.75.1): 55 | - FlipperKit/Core 56 | - FlipperKit/SKIOSNetworkPlugin (0.75.1): 57 | - FlipperKit/Core 58 | - FlipperKit/FlipperKitNetworkPlugin 59 | - glog (0.3.5) 60 | - libevent (2.1.12) 61 | - OpenSSL-Universal (1.1.180) 62 | - RCT-Folly (2020.01.13.00): 63 | - boost-for-react-native 64 | - DoubleConversion 65 | - glog 66 | - RCT-Folly/Default (= 2020.01.13.00) 67 | - RCT-Folly/Default (2020.01.13.00): 68 | - boost-for-react-native 69 | - DoubleConversion 70 | - glog 71 | - RCTRequired (0.64.1) 72 | - RCTTypeSafety (0.64.1): 73 | - FBLazyVector (= 0.64.1) 74 | - RCT-Folly (= 2020.01.13.00) 75 | - RCTRequired (= 0.64.1) 76 | - React-Core (= 0.64.1) 77 | - React (0.64.1): 78 | - React-Core (= 0.64.1) 79 | - React-Core/DevSupport (= 0.64.1) 80 | - React-Core/RCTWebSocket (= 0.64.1) 81 | - React-RCTActionSheet (= 0.64.1) 82 | - React-RCTAnimation (= 0.64.1) 83 | - React-RCTBlob (= 0.64.1) 84 | - React-RCTImage (= 0.64.1) 85 | - React-RCTLinking (= 0.64.1) 86 | - React-RCTNetwork (= 0.64.1) 87 | - React-RCTSettings (= 0.64.1) 88 | - React-RCTText (= 0.64.1) 89 | - React-RCTVibration (= 0.64.1) 90 | - React-callinvoker (0.64.1) 91 | - React-Core (0.64.1): 92 | - glog 93 | - RCT-Folly (= 2020.01.13.00) 94 | - React-Core/Default (= 0.64.1) 95 | - React-cxxreact (= 0.64.1) 96 | - React-jsi (= 0.64.1) 97 | - React-jsiexecutor (= 0.64.1) 98 | - React-perflogger (= 0.64.1) 99 | - Yoga 100 | - React-Core/CoreModulesHeaders (0.64.1): 101 | - glog 102 | - RCT-Folly (= 2020.01.13.00) 103 | - React-Core/Default 104 | - React-cxxreact (= 0.64.1) 105 | - React-jsi (= 0.64.1) 106 | - React-jsiexecutor (= 0.64.1) 107 | - React-perflogger (= 0.64.1) 108 | - Yoga 109 | - React-Core/Default (0.64.1): 110 | - glog 111 | - RCT-Folly (= 2020.01.13.00) 112 | - React-cxxreact (= 0.64.1) 113 | - React-jsi (= 0.64.1) 114 | - React-jsiexecutor (= 0.64.1) 115 | - React-perflogger (= 0.64.1) 116 | - Yoga 117 | - React-Core/DevSupport (0.64.1): 118 | - glog 119 | - RCT-Folly (= 2020.01.13.00) 120 | - React-Core/Default (= 0.64.1) 121 | - React-Core/RCTWebSocket (= 0.64.1) 122 | - React-cxxreact (= 0.64.1) 123 | - React-jsi (= 0.64.1) 124 | - React-jsiexecutor (= 0.64.1) 125 | - React-jsinspector (= 0.64.1) 126 | - React-perflogger (= 0.64.1) 127 | - Yoga 128 | - React-Core/RCTActionSheetHeaders (0.64.1): 129 | - glog 130 | - RCT-Folly (= 2020.01.13.00) 131 | - React-Core/Default 132 | - React-cxxreact (= 0.64.1) 133 | - React-jsi (= 0.64.1) 134 | - React-jsiexecutor (= 0.64.1) 135 | - React-perflogger (= 0.64.1) 136 | - Yoga 137 | - React-Core/RCTAnimationHeaders (0.64.1): 138 | - glog 139 | - RCT-Folly (= 2020.01.13.00) 140 | - React-Core/Default 141 | - React-cxxreact (= 0.64.1) 142 | - React-jsi (= 0.64.1) 143 | - React-jsiexecutor (= 0.64.1) 144 | - React-perflogger (= 0.64.1) 145 | - Yoga 146 | - React-Core/RCTBlobHeaders (0.64.1): 147 | - glog 148 | - RCT-Folly (= 2020.01.13.00) 149 | - React-Core/Default 150 | - React-cxxreact (= 0.64.1) 151 | - React-jsi (= 0.64.1) 152 | - React-jsiexecutor (= 0.64.1) 153 | - React-perflogger (= 0.64.1) 154 | - Yoga 155 | - React-Core/RCTImageHeaders (0.64.1): 156 | - glog 157 | - RCT-Folly (= 2020.01.13.00) 158 | - React-Core/Default 159 | - React-cxxreact (= 0.64.1) 160 | - React-jsi (= 0.64.1) 161 | - React-jsiexecutor (= 0.64.1) 162 | - React-perflogger (= 0.64.1) 163 | - Yoga 164 | - React-Core/RCTLinkingHeaders (0.64.1): 165 | - glog 166 | - RCT-Folly (= 2020.01.13.00) 167 | - React-Core/Default 168 | - React-cxxreact (= 0.64.1) 169 | - React-jsi (= 0.64.1) 170 | - React-jsiexecutor (= 0.64.1) 171 | - React-perflogger (= 0.64.1) 172 | - Yoga 173 | - React-Core/RCTNetworkHeaders (0.64.1): 174 | - glog 175 | - RCT-Folly (= 2020.01.13.00) 176 | - React-Core/Default 177 | - React-cxxreact (= 0.64.1) 178 | - React-jsi (= 0.64.1) 179 | - React-jsiexecutor (= 0.64.1) 180 | - React-perflogger (= 0.64.1) 181 | - Yoga 182 | - React-Core/RCTSettingsHeaders (0.64.1): 183 | - glog 184 | - RCT-Folly (= 2020.01.13.00) 185 | - React-Core/Default 186 | - React-cxxreact (= 0.64.1) 187 | - React-jsi (= 0.64.1) 188 | - React-jsiexecutor (= 0.64.1) 189 | - React-perflogger (= 0.64.1) 190 | - Yoga 191 | - React-Core/RCTTextHeaders (0.64.1): 192 | - glog 193 | - RCT-Folly (= 2020.01.13.00) 194 | - React-Core/Default 195 | - React-cxxreact (= 0.64.1) 196 | - React-jsi (= 0.64.1) 197 | - React-jsiexecutor (= 0.64.1) 198 | - React-perflogger (= 0.64.1) 199 | - Yoga 200 | - React-Core/RCTVibrationHeaders (0.64.1): 201 | - glog 202 | - RCT-Folly (= 2020.01.13.00) 203 | - React-Core/Default 204 | - React-cxxreact (= 0.64.1) 205 | - React-jsi (= 0.64.1) 206 | - React-jsiexecutor (= 0.64.1) 207 | - React-perflogger (= 0.64.1) 208 | - Yoga 209 | - React-Core/RCTWebSocket (0.64.1): 210 | - glog 211 | - RCT-Folly (= 2020.01.13.00) 212 | - React-Core/Default (= 0.64.1) 213 | - React-cxxreact (= 0.64.1) 214 | - React-jsi (= 0.64.1) 215 | - React-jsiexecutor (= 0.64.1) 216 | - React-perflogger (= 0.64.1) 217 | - Yoga 218 | - React-CoreModules (0.64.1): 219 | - FBReactNativeSpec (= 0.64.1) 220 | - RCT-Folly (= 2020.01.13.00) 221 | - RCTTypeSafety (= 0.64.1) 222 | - React-Core/CoreModulesHeaders (= 0.64.1) 223 | - React-jsi (= 0.64.1) 224 | - React-RCTImage (= 0.64.1) 225 | - ReactCommon/turbomodule/core (= 0.64.1) 226 | - React-cxxreact (0.64.1): 227 | - boost-for-react-native (= 1.63.0) 228 | - DoubleConversion 229 | - glog 230 | - RCT-Folly (= 2020.01.13.00) 231 | - React-callinvoker (= 0.64.1) 232 | - React-jsi (= 0.64.1) 233 | - React-jsinspector (= 0.64.1) 234 | - React-perflogger (= 0.64.1) 235 | - React-runtimeexecutor (= 0.64.1) 236 | - React-jsi (0.64.1): 237 | - boost-for-react-native (= 1.63.0) 238 | - DoubleConversion 239 | - glog 240 | - RCT-Folly (= 2020.01.13.00) 241 | - React-jsi/Default (= 0.64.1) 242 | - React-jsi/Default (0.64.1): 243 | - boost-for-react-native (= 1.63.0) 244 | - DoubleConversion 245 | - glog 246 | - RCT-Folly (= 2020.01.13.00) 247 | - React-jsiexecutor (0.64.1): 248 | - DoubleConversion 249 | - glog 250 | - RCT-Folly (= 2020.01.13.00) 251 | - React-cxxreact (= 0.64.1) 252 | - React-jsi (= 0.64.1) 253 | - React-perflogger (= 0.64.1) 254 | - React-jsinspector (0.64.1) 255 | - react-native-safe-area-context (3.2.0): 256 | - React-Core 257 | - React-perflogger (0.64.1) 258 | - React-RCTActionSheet (0.64.1): 259 | - React-Core/RCTActionSheetHeaders (= 0.64.1) 260 | - React-RCTAnimation (0.64.1): 261 | - FBReactNativeSpec (= 0.64.1) 262 | - RCT-Folly (= 2020.01.13.00) 263 | - RCTTypeSafety (= 0.64.1) 264 | - React-Core/RCTAnimationHeaders (= 0.64.1) 265 | - React-jsi (= 0.64.1) 266 | - ReactCommon/turbomodule/core (= 0.64.1) 267 | - React-RCTBlob (0.64.1): 268 | - FBReactNativeSpec (= 0.64.1) 269 | - RCT-Folly (= 2020.01.13.00) 270 | - React-Core/RCTBlobHeaders (= 0.64.1) 271 | - React-Core/RCTWebSocket (= 0.64.1) 272 | - React-jsi (= 0.64.1) 273 | - React-RCTNetwork (= 0.64.1) 274 | - ReactCommon/turbomodule/core (= 0.64.1) 275 | - React-RCTImage (0.64.1): 276 | - FBReactNativeSpec (= 0.64.1) 277 | - RCT-Folly (= 2020.01.13.00) 278 | - RCTTypeSafety (= 0.64.1) 279 | - React-Core/RCTImageHeaders (= 0.64.1) 280 | - React-jsi (= 0.64.1) 281 | - React-RCTNetwork (= 0.64.1) 282 | - ReactCommon/turbomodule/core (= 0.64.1) 283 | - React-RCTLinking (0.64.1): 284 | - FBReactNativeSpec (= 0.64.1) 285 | - React-Core/RCTLinkingHeaders (= 0.64.1) 286 | - React-jsi (= 0.64.1) 287 | - ReactCommon/turbomodule/core (= 0.64.1) 288 | - React-RCTNetwork (0.64.1): 289 | - FBReactNativeSpec (= 0.64.1) 290 | - RCT-Folly (= 2020.01.13.00) 291 | - RCTTypeSafety (= 0.64.1) 292 | - React-Core/RCTNetworkHeaders (= 0.64.1) 293 | - React-jsi (= 0.64.1) 294 | - ReactCommon/turbomodule/core (= 0.64.1) 295 | - React-RCTSettings (0.64.1): 296 | - FBReactNativeSpec (= 0.64.1) 297 | - RCT-Folly (= 2020.01.13.00) 298 | - RCTTypeSafety (= 0.64.1) 299 | - React-Core/RCTSettingsHeaders (= 0.64.1) 300 | - React-jsi (= 0.64.1) 301 | - ReactCommon/turbomodule/core (= 0.64.1) 302 | - React-RCTText (0.64.1): 303 | - React-Core/RCTTextHeaders (= 0.64.1) 304 | - React-RCTVibration (0.64.1): 305 | - FBReactNativeSpec (= 0.64.1) 306 | - RCT-Folly (= 2020.01.13.00) 307 | - React-Core/RCTVibrationHeaders (= 0.64.1) 308 | - React-jsi (= 0.64.1) 309 | - ReactCommon/turbomodule/core (= 0.64.1) 310 | - React-runtimeexecutor (0.64.1): 311 | - React-jsi (= 0.64.1) 312 | - ReactCommon/turbomodule/core (0.64.1): 313 | - DoubleConversion 314 | - glog 315 | - RCT-Folly (= 2020.01.13.00) 316 | - React-callinvoker (= 0.64.1) 317 | - React-Core (= 0.64.1) 318 | - React-cxxreact (= 0.64.1) 319 | - React-jsi (= 0.64.1) 320 | - React-perflogger (= 0.64.1) 321 | - RNCAsyncStorage (1.15.5): 322 | - React-Core 323 | - RNCMaskedView (0.1.11): 324 | - React 325 | - RNGestureHandler (1.10.3): 326 | - React-Core 327 | - RNReanimated (2.1.0): 328 | - DoubleConversion 329 | - FBLazyVector 330 | - FBReactNativeSpec 331 | - glog 332 | - RCT-Folly 333 | - RCTRequired 334 | - RCTTypeSafety 335 | - React 336 | - React-callinvoker 337 | - React-Core 338 | - React-Core/DevSupport 339 | - React-Core/RCTWebSocket 340 | - React-CoreModules 341 | - React-cxxreact 342 | - React-jsi 343 | - React-jsiexecutor 344 | - React-jsinspector 345 | - React-RCTActionSheet 346 | - React-RCTAnimation 347 | - React-RCTBlob 348 | - React-RCTImage 349 | - React-RCTLinking 350 | - React-RCTNetwork 351 | - React-RCTSettings 352 | - React-RCTText 353 | - React-RCTVibration 354 | - ReactCommon/turbomodule/core 355 | - Yoga 356 | - RNScreens (3.2.0): 357 | - React-Core 358 | - Stripe (21.6.0): 359 | - Stripe/Stripe3DS2 (= 21.6.0) 360 | - stripe-react-native (0.1.4): 361 | - React 362 | - Stripe (~> 21.6.0) 363 | - Stripe/Stripe3DS2 (21.6.0) 364 | - Yoga (1.14.0) 365 | - YogaKit (1.18.1): 366 | - Yoga (~> 1.14) 367 | 368 | DEPENDENCIES: 369 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) 370 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) 371 | - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) 372 | - Flipper (~> 0.75.1) 373 | - Flipper-DoubleConversion (= 1.1.7) 374 | - Flipper-Folly (~> 2.5.3) 375 | - Flipper-Glog (= 0.3.6) 376 | - Flipper-PeerTalk (~> 0.0.4) 377 | - Flipper-RSocket (~> 1.3) 378 | - FlipperKit (~> 0.75.1) 379 | - FlipperKit/Core (~> 0.75.1) 380 | - FlipperKit/CppBridge (~> 0.75.1) 381 | - FlipperKit/FBCxxFollyDynamicConvert (~> 0.75.1) 382 | - FlipperKit/FBDefines (~> 0.75.1) 383 | - FlipperKit/FKPortForwarding (~> 0.75.1) 384 | - FlipperKit/FlipperKitHighlightOverlay (~> 0.75.1) 385 | - FlipperKit/FlipperKitLayoutPlugin (~> 0.75.1) 386 | - FlipperKit/FlipperKitLayoutTextSearchable (~> 0.75.1) 387 | - FlipperKit/FlipperKitNetworkPlugin (~> 0.75.1) 388 | - FlipperKit/FlipperKitReactPlugin (~> 0.75.1) 389 | - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.75.1) 390 | - FlipperKit/SKIOSNetworkPlugin (~> 0.75.1) 391 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) 392 | - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) 393 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) 394 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) 395 | - React (from `../node_modules/react-native/`) 396 | - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) 397 | - React-Core (from `../node_modules/react-native/`) 398 | - React-Core/DevSupport (from `../node_modules/react-native/`) 399 | - React-Core/RCTWebSocket (from `../node_modules/react-native/`) 400 | - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) 401 | - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) 402 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) 403 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) 404 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) 405 | - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) 406 | - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) 407 | - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) 408 | - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) 409 | - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) 410 | - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) 411 | - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) 412 | - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) 413 | - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) 414 | - React-RCTText (from `../node_modules/react-native/Libraries/Text`) 415 | - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) 416 | - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) 417 | - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) 418 | - "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)" 419 | - "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)" 420 | - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) 421 | - RNReanimated (from `../node_modules/react-native-reanimated`) 422 | - RNScreens (from `../node_modules/react-native-screens`) 423 | - "stripe-react-native (from `../node_modules/@stripe/stripe-react-native`)" 424 | - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) 425 | 426 | SPEC REPOS: 427 | trunk: 428 | - boost-for-react-native 429 | - CocoaAsyncSocket 430 | - Flipper 431 | - Flipper-DoubleConversion 432 | - Flipper-Folly 433 | - Flipper-Glog 434 | - Flipper-PeerTalk 435 | - Flipper-RSocket 436 | - FlipperKit 437 | - libevent 438 | - OpenSSL-Universal 439 | - Stripe 440 | - YogaKit 441 | 442 | EXTERNAL SOURCES: 443 | DoubleConversion: 444 | :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" 445 | FBLazyVector: 446 | :path: "../node_modules/react-native/Libraries/FBLazyVector" 447 | FBReactNativeSpec: 448 | :path: "../node_modules/react-native/React/FBReactNativeSpec" 449 | glog: 450 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" 451 | RCT-Folly: 452 | :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" 453 | RCTRequired: 454 | :path: "../node_modules/react-native/Libraries/RCTRequired" 455 | RCTTypeSafety: 456 | :path: "../node_modules/react-native/Libraries/TypeSafety" 457 | React: 458 | :path: "../node_modules/react-native/" 459 | React-callinvoker: 460 | :path: "../node_modules/react-native/ReactCommon/callinvoker" 461 | React-Core: 462 | :path: "../node_modules/react-native/" 463 | React-CoreModules: 464 | :path: "../node_modules/react-native/React/CoreModules" 465 | React-cxxreact: 466 | :path: "../node_modules/react-native/ReactCommon/cxxreact" 467 | React-jsi: 468 | :path: "../node_modules/react-native/ReactCommon/jsi" 469 | React-jsiexecutor: 470 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" 471 | React-jsinspector: 472 | :path: "../node_modules/react-native/ReactCommon/jsinspector" 473 | react-native-safe-area-context: 474 | :path: "../node_modules/react-native-safe-area-context" 475 | React-perflogger: 476 | :path: "../node_modules/react-native/ReactCommon/reactperflogger" 477 | React-RCTActionSheet: 478 | :path: "../node_modules/react-native/Libraries/ActionSheetIOS" 479 | React-RCTAnimation: 480 | :path: "../node_modules/react-native/Libraries/NativeAnimation" 481 | React-RCTBlob: 482 | :path: "../node_modules/react-native/Libraries/Blob" 483 | React-RCTImage: 484 | :path: "../node_modules/react-native/Libraries/Image" 485 | React-RCTLinking: 486 | :path: "../node_modules/react-native/Libraries/LinkingIOS" 487 | React-RCTNetwork: 488 | :path: "../node_modules/react-native/Libraries/Network" 489 | React-RCTSettings: 490 | :path: "../node_modules/react-native/Libraries/Settings" 491 | React-RCTText: 492 | :path: "../node_modules/react-native/Libraries/Text" 493 | React-RCTVibration: 494 | :path: "../node_modules/react-native/Libraries/Vibration" 495 | React-runtimeexecutor: 496 | :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" 497 | ReactCommon: 498 | :path: "../node_modules/react-native/ReactCommon" 499 | RNCAsyncStorage: 500 | :path: "../node_modules/@react-native-async-storage/async-storage" 501 | RNCMaskedView: 502 | :path: "../node_modules/@react-native-community/masked-view" 503 | RNGestureHandler: 504 | :path: "../node_modules/react-native-gesture-handler" 505 | RNReanimated: 506 | :path: "../node_modules/react-native-reanimated" 507 | RNScreens: 508 | :path: "../node_modules/react-native-screens" 509 | stripe-react-native: 510 | :path: "../node_modules/@stripe/stripe-react-native" 511 | Yoga: 512 | :path: "../node_modules/react-native/ReactCommon/yoga" 513 | 514 | SPEC CHECKSUMS: 515 | boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c 516 | CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 517 | DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de 518 | FBLazyVector: 7b423f9e248eae65987838148c36eec1dbfe0b53 519 | FBReactNativeSpec: be6b8df64a75913e6019955da441a82de696cc3a 520 | Flipper: d3da1aa199aad94455ae725e9f3aa43f3ec17021 521 | Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 522 | Flipper-Folly: 755929a4f851b2fb2c347d533a23f191b008554c 523 | Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6 524 | Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 525 | Flipper-RSocket: 127954abe8b162fcaf68d2134d34dc2bd7076154 526 | FlipperKit: 8a20b5c5fcf9436cac58551dc049867247f64b00 527 | glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62 528 | libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 529 | OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b 530 | RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c 531 | RCTRequired: ec2ebc96b7bfba3ca5c32740f5a0c6a014a274d2 532 | RCTTypeSafety: 22567f31e67c3e088c7ac23ea46ab6d4779c0ea5 533 | React: a241e3dbb1e91d06332f1dbd2b3ab26e1a4c4b9d 534 | React-callinvoker: da4d1c6141696a00163960906bc8a55b985e4ce4 535 | React-Core: 46ba164c437d7dac607b470c83c8308b05799748 536 | React-CoreModules: 217bd14904491c7b9940ff8b34a3fe08013c2f14 537 | React-cxxreact: 0090588ae6660c4615d3629fdd5c768d0983add4 538 | React-jsi: 5de8204706bd872b78ea646aee5d2561ca1214b6 539 | React-jsiexecutor: 124e8f99992490d0d13e0649d950d3e1aae06fe9 540 | React-jsinspector: 500a59626037be5b3b3d89c5151bc3baa9abf1a9 541 | react-native-safe-area-context: f0906bf8bc9835ac9a9d3f97e8bde2a997d8da79 542 | React-perflogger: aad6d4b4a267936b3667260d1f649b6f6069a675 543 | React-RCTActionSheet: fc376be462c9c8d6ad82c0905442fd77f82a9d2a 544 | React-RCTAnimation: ba0a1c3a2738be224a08092fa7f1b444ab77d309 545 | React-RCTBlob: f758d4403fc5828a326dc69e27b41e1a92f34947 546 | React-RCTImage: ce57088705f4a8d03f6594b066a59c29143ba73e 547 | React-RCTLinking: 852a3a95c65fa63f657a4b4e2d3d83a815e00a7c 548 | React-RCTNetwork: 9d7ccb8a08d522d71700b4fb677d9fa28cccd118 549 | React-RCTSettings: d8aaf4389ff06114dee8c42ef5f0f2915946011e 550 | React-RCTText: 809c12ed6b261796ba056c04fcd20d8b90bcc81d 551 | React-RCTVibration: 4b99a7f5c6c0abbc5256410cc5425fb8531986e1 552 | React-runtimeexecutor: ff951a0c241bfaefc4940a3f1f1a229e7cb32fa6 553 | ReactCommon: bedc99ed4dae329c4fcf128d0c31b9115e5365ca 554 | RNCAsyncStorage: 56a3355a10b5d660c48c6e37325ac85ebfd09885 555 | RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489 556 | RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211 557 | RNReanimated: b8c8004b43446e3c2709fe64b2b41072f87428ad 558 | RNScreens: c277bfc4b5bb7c2fe977d19635df6f974f95dfd6 559 | Stripe: 6cc7bb348f4b1fad111129f6ee40eb6682deaefb 560 | stripe-react-native: 86469904cad7d2a2e07f38f5d10c003048d5d6fc 561 | Yoga: a7de31c64fe738607e7a3803e3f591a4b1df7393 562 | YogaKit: f782866e155069a2cca2517aafea43200b01fd5a 563 | 564 | PODFILE CHECKSUM: 2d3e60306fb5171faae330217f5c3d8d302d69c3 565 | 566 | COCOAPODS: 1.10.1 567 | -------------------------------------------------------------------------------- /mobile/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | module.exports = { 9 | transformer: { 10 | getTransformOptions: async () => ({ 11 | transform: { 12 | experimentalImportSupport: false, 13 | inlineRequires: true, 14 | }, 15 | }), 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /mobile/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ecommapp", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test": "jest", 10 | "lint": "eslint .", 11 | "format": "prettier --write '**/*.js'" 12 | }, 13 | "dependencies": { 14 | "@react-native-async-storage/async-storage": "^1.15.5", 15 | "@react-native-community/masked-view": "^0.1.11", 16 | "@react-navigation/bottom-tabs": "^5.11.11", 17 | "@react-navigation/material-top-tabs": "^5.3.15", 18 | "@react-navigation/native": "^5.9.4", 19 | "@react-navigation/stack": "^5.14.5", 20 | "@stripe/stripe-react-native": "^0.1.4", 21 | "react": "17.0.1", 22 | "react-native": "0.64.1", 23 | "react-native-dotenv": "^2.5.5", 24 | "react-native-gesture-handler": "^1.10.3", 25 | "react-native-reanimated": "^2.1.0", 26 | "react-native-safe-area-context": "^3.2.0", 27 | "react-native-screens": "^3.2.0", 28 | "react-native-tab-view": "^2.16.0", 29 | "react-query": "^3.16.1", 30 | "yup": "^0.32.9", 31 | "zustand": "^3.5.2" 32 | }, 33 | "devDependencies": { 34 | "@babel/core": "^7.12.9", 35 | "@babel/runtime": "^7.12.5", 36 | "@testing-library/jest-native": "^4.0.1", 37 | "@testing-library/react-hooks": "^5.1.2", 38 | "@testing-library/react-native": "^7.2.0", 39 | "babel-jest": "^26.6.3", 40 | "eslint": "^7.26.0", 41 | "eslint-config-handlebarlabs": "^0.0.6", 42 | "eslint-config-prettier": "^8.3.0", 43 | "eslint-plugin-prettier": "^3.4.0", 44 | "jest": "^26.6.3", 45 | "metro-react-native-babel-preset": "^0.64.0", 46 | "prettier": "^2.3.0", 47 | "react-test-renderer": "17.0.1" 48 | }, 49 | "jest": { 50 | "preset": "react-native", 51 | "transformIgnorePatterns": [ 52 | "node_modules/(?!(jest-)?@react-native|react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|@sentry/.*)" 53 | ], 54 | "setupFilesAfterEnv": [ 55 | "@testing-library/jest-native/extend-expect" 56 | ] 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /mobile/src/assets/images/apps-outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/src/assets/images/apps-outline.png -------------------------------------------------------------------------------- /mobile/src/assets/images/cart-outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/src/assets/images/cart-outline.png -------------------------------------------------------------------------------- /mobile/src/assets/images/close-outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/src/assets/images/close-outline.png -------------------------------------------------------------------------------- /mobile/src/assets/images/home-outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/src/assets/images/home-outline.png -------------------------------------------------------------------------------- /mobile/src/assets/images/person-circle-outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/mobile/src/assets/images/person-circle-outline.png -------------------------------------------------------------------------------- /mobile/src/components/Button.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | TouchableOpacity, 4 | Text, 5 | StyleSheet, 6 | ActivityIndicator, 7 | } from 'react-native'; 8 | 9 | import colors from '../constants/colors'; 10 | 11 | const styles = StyleSheet.create({ 12 | container: { 13 | backgroundColor: colors.brand, 14 | paddingVertical: 14, 15 | borderRadius: 6, 16 | borderWidth: 1, 17 | borderColor: colors.brand, 18 | marginVertical: 7, 19 | }, 20 | containerLoading: { 21 | flexDirection: 'row', 22 | justifyContent: 'center', 23 | backgroundColor: colors.disabled, 24 | borderColor: colors.disabled, 25 | }, 26 | containerOutline: { 27 | backgroundColor: 'transparent', 28 | borderColor: colors.border, 29 | }, 30 | text: { 31 | color: colors.white, 32 | alignSelf: 'center', 33 | fontSize: 18, 34 | fontWeight: '500', 35 | }, 36 | textOutline: { 37 | color: colors.brand, 38 | }, 39 | textLoading: { 40 | marginRight: 12, 41 | }, 42 | }); 43 | 44 | export const Button = ({ 45 | onPress = () => {}, 46 | children = '', 47 | type, 48 | isLoading = false, 49 | }) => { 50 | const containerStyles = [styles.container]; 51 | const textStyles = [styles.text]; 52 | 53 | const isOutline = type === 'outline'; 54 | if (isOutline) { 55 | containerStyles.push(styles.containerOutline); 56 | textStyles.push(styles.textOutline); 57 | } 58 | 59 | if (isLoading) { 60 | containerStyles.push(styles.containerLoading); 61 | textStyles.push(styles.textLoading); 62 | } 63 | return ( 64 | 69 | {children} 70 | {isLoading && ( 71 | 75 | )} 76 | 77 | ); 78 | }; 79 | -------------------------------------------------------------------------------- /mobile/src/components/CartRow.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View, StyleSheet } from 'react-native'; 3 | 4 | import { Text } from './Text'; 5 | import { money } from '../util/format'; 6 | import { Counter } from './QuantityCounter'; 7 | import { useCart, useItem } from '../util/cart'; 8 | 9 | const styles = StyleSheet.create({ 10 | row: { 11 | flexDirection: 'row', 12 | paddingHorizontal: 10, 13 | paddingVertical: 10, 14 | alignItems: 'center', 15 | justifyContent: 'space-between', 16 | }, 17 | }); 18 | 19 | export const CartRow = ({ id }) => { 20 | const { addItem, removeItem } = useCart(state => ({ 21 | addItem: state.addItem, 22 | removeItem: state.removeItem, 23 | })); 24 | const item = useItem(id); 25 | 26 | return ( 27 | 28 | 29 | {item.name} 30 | {money(item.price)} 31 | 32 | addItem(item)} 36 | onDecrement={() => removeItem({ id: item.id })} 37 | /> 38 | 39 | ); 40 | }; 41 | -------------------------------------------------------------------------------- /mobile/src/components/Form.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { TextInput as RNTextInput, StyleSheet, View } from 'react-native'; 3 | 4 | import { Text } from './Text'; 5 | import colors from '../constants/colors'; 6 | 7 | const styles = StyleSheet.create({ 8 | inputContainer: { 9 | marginBottom: 20, 10 | }, 11 | labelText: { 12 | color: colors.gray, 13 | fontSize: 18, 14 | marginBottom: 10, 15 | }, 16 | textInput: { 17 | fontSize: 14, 18 | fontWeight: '500', 19 | paddingBottom: 10, 20 | }, 21 | border: { 22 | height: 1, 23 | backgroundColor: colors.border, 24 | }, 25 | borderError: { 26 | backgroundColor: colors.error, 27 | }, 28 | errorText: { 29 | marginTop: 5, 30 | color: colors.error, 31 | }, 32 | }); 33 | 34 | export const TextInput = ({ label, errorText, ...rest }) => { 35 | const borderStyles = [styles.border]; 36 | 37 | if (errorText && errorText.length > 0) { 38 | borderStyles.push(styles.borderError); 39 | } 40 | 41 | return ( 42 | 43 | {label} 44 | 45 | 46 | {errorText} 47 | 48 | ); 49 | }; 50 | -------------------------------------------------------------------------------- /mobile/src/components/List.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | View, 4 | StyleSheet, 5 | TouchableOpacity, 6 | Image, 7 | Dimensions, 8 | SectionList, 9 | } from 'react-native'; 10 | import { useNavigation } from '@react-navigation/native'; 11 | 12 | import { Text } from './Text'; 13 | import colors from '../constants/colors'; 14 | import { money } from '../util/format'; 15 | 16 | const screen = Dimensions.get('screen'); 17 | 18 | const styles = StyleSheet.create({ 19 | sectionHeader: { 20 | marginTop: 20, 21 | paddingTop: 10, 22 | paddingHorizontal: 10, 23 | backgroundColor: '#fff', 24 | borderTopColor: colors.border, 25 | borderTopWidth: StyleSheet.hairlineWidth, 26 | }, 27 | itemImage: { 28 | width: screen.width * 0.4, 29 | height: screen.width * 0.4, 30 | }, 31 | itemCard: { flex: 1, padding: 10 }, 32 | cardTitle: { fontWeight: 'bold', marginVertical: 5 }, 33 | sectionList: { 34 | backgroundColor: colors.background, 35 | }, 36 | content: { 37 | paddingBottom: 100, 38 | }, 39 | }); 40 | 41 | export const SectionHeader = ({ children }) => ( 42 | 43 | {children} 44 | 45 | ); 46 | 47 | export const SectionFooter = () => ( 48 | 55 | ); 56 | 57 | export const ItemCard = ({ name, price, image, onPress }) => ( 58 | 59 | 64 | {name} 65 | {money(price)} 66 | 67 | ); 68 | 69 | export const ProductList = ({ sections = [] }) => { 70 | const navigation = useNavigation(); 71 | 72 | return ( 73 | { 78 | // We do this to simulate numColumns in FlatList. This will only work for 2 column layout. 79 | 80 | // We only want to do this on odd columns so we don't duplicate items. 81 | if (index % 2 !== 0) return null; 82 | 83 | const item = section.data[index]; 84 | const nextItem = section.data[index + 1]; 85 | 86 | const onPress = itemToSend => { 87 | navigation.push('Details', { 88 | id: itemToSend.id, 89 | name: itemToSend.name, 90 | price: itemToSend.price, 91 | image: itemToSend.image, 92 | }); 93 | }; 94 | 95 | return ( 96 | 103 | onPress(item)} /> 104 | {nextItem ? ( 105 | onPress(nextItem)} /> 106 | ) : ( 107 | 108 | )} 109 | 110 | ); 111 | }} 112 | renderSectionHeader={({ section }) => ( 113 | {section.title} 114 | )} 115 | renderSectionFooter={() => } 116 | stickySectionHeadersEnabled={false} 117 | /> 118 | ); 119 | }; 120 | -------------------------------------------------------------------------------- /mobile/src/components/Loading.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View, ActivityIndicator } from 'react-native'; 3 | import colors from '../constants/colors'; 4 | 5 | export const Loading = () => ( 6 | 7 | 8 | 9 | ); 10 | -------------------------------------------------------------------------------- /mobile/src/components/Navigation.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Image, TouchableOpacity, View, StyleSheet } from 'react-native'; 3 | import { useNavigation } from '@react-navigation/native'; 4 | 5 | import { Text } from './Text'; 6 | import colors from '../constants/colors'; 7 | import { useCart, cartQuantity } from '../util/cart'; 8 | 9 | const styles = StyleSheet.create({ 10 | headerIconEmbellishment: { 11 | position: 'absolute', 12 | top: -8, 13 | right: 3, 14 | backgroundColor: colors.brand, 15 | width: 15, 16 | height: 15, 17 | borderRadius: 10, 18 | justifyContent: 'center', 19 | alignItems: 'center', 20 | }, 21 | }); 22 | 23 | export const TabBarIcon = ({ routeName, color, size }) => { 24 | let src = require('../assets/images/home-outline.png'); 25 | 26 | if (routeName === 'Explore') { 27 | src = require('../assets/images/apps-outline.png'); 28 | } 29 | 30 | if (routeName === 'Account') { 31 | src = require('../assets/images/person-circle-outline.png'); 32 | } 33 | 34 | return ( 35 | 43 | ); 44 | }; 45 | 46 | export const HeaderIcon = ({ name, onPress, style = {} }) => { 47 | let src; 48 | 49 | switch (name) { 50 | case 'cart': 51 | src = require('../assets/images/cart-outline.png'); 52 | break; 53 | case 'close': 54 | default: 55 | src = require('../assets/images/close-outline.png'); 56 | break; 57 | } 58 | 59 | return ( 60 | 61 | 62 | 63 | ); 64 | }; 65 | 66 | export const CartIcon = () => { 67 | const navigation = useNavigation(); 68 | const { cart } = useCart(state => ({ cart: state.cart })); 69 | const quantity = cartQuantity(cart); 70 | 71 | return ( 72 | 73 | navigation.push('Cart')} /> 74 | {quantity > 0 && ( 75 | 76 | 79 | {quantity} 80 | 81 | 82 | )} 83 | 84 | ); 85 | }; 86 | -------------------------------------------------------------------------------- /mobile/src/components/QuantityCounter.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View, StyleSheet, TouchableOpacity } from 'react-native'; 3 | 4 | import colors from '../constants/colors'; 5 | import { Text } from './Text'; 6 | import { money } from '../util/format'; 7 | 8 | const styles = StyleSheet.create({ 9 | container: { 10 | backgroundColor: colors.white, 11 | alignItems: 'center', 12 | borderTopWidth: StyleSheet.hairlineWidth, 13 | borderTopColor: colors.border, 14 | flexDirection: 'row', 15 | justifyContent: 'space-between', 16 | paddingHorizontal: 20, 17 | }, 18 | counter: { 19 | flexDirection: 'row', 20 | backgroundColor: '#E0E0E0', 21 | marginVertical: 10, 22 | alignItems: 'center', 23 | }, 24 | quantityText: { 25 | fontWeight: 'bold', 26 | fontSize: 20, 27 | }, 28 | btn: { 29 | alignItems: 'center', 30 | justifyContent: 'center', 31 | }, 32 | btnText: { 33 | fontSize: 20, 34 | paddingVertical: 15, 35 | paddingHorizontal: 25, 36 | color: '#707070', 37 | }, 38 | btnTextSmall: { 39 | paddingVertical: 8, 40 | paddingHorizontal: 18, 41 | }, 42 | priceText: { 43 | fontWeight: 'bold', 44 | }, 45 | }); 46 | 47 | export const Counter = ({ quantity, onDecrement, onIncrement, type }) => { 48 | const btnTextStyles = [styles.btnText]; 49 | if (type === 'small') { 50 | btnTextStyles.push(styles.btnTextSmall); 51 | } 52 | 53 | return ( 54 | 55 | 56 | - 57 | 58 | {quantity} 59 | 60 | + 61 | 62 | 63 | ); 64 | }; 65 | 66 | export const QuantityCounter = ({ 67 | price, 68 | quantity = 0, 69 | onDecrement, 70 | onIncrement, 71 | }) => { 72 | return ( 73 | 74 | 79 | {money(price)} 80 | 81 | ); 82 | }; 83 | -------------------------------------------------------------------------------- /mobile/src/components/Text.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, Text as RNText } from 'react-native'; 3 | 4 | import colors from '../constants/colors'; 5 | 6 | const styles = StyleSheet.create({ 7 | text: { 8 | color: colors.primary, 9 | fontSize: 16, 10 | }, 11 | headerText: { 12 | fontWeight: '700', 13 | fontSize: 26, 14 | marginBottom: 6, 15 | }, 16 | subHeaderText: { 17 | color: colors.gray, 18 | fontSize: 20, 19 | marginBottom: 12, 20 | marginTop: -12, // assum this shows up under a headerText 21 | }, 22 | }); 23 | 24 | export const Text = ({ type, children, style = {} }) => { 25 | let textStyles = [styles.text]; 26 | 27 | if (type === 'header') { 28 | textStyles.push(styles.headerText); 29 | } else if (type === 'subheader') { 30 | textStyles.push(styles.subHeaderText); 31 | } 32 | 33 | if (Array.isArray(style)) { 34 | textStyles = [...textStyles, ...style]; 35 | } else { 36 | textStyles.push(style); 37 | } 38 | 39 | return {children}; 40 | }; 41 | -------------------------------------------------------------------------------- /mobile/src/components/__tests__/Button.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render, fireEvent } from '@testing-library/react-native'; 3 | 4 | import { Button } from '../Button'; 5 | 6 | it('functions as a button', () => { 7 | const onPress = jest.fn(); 8 | const out = render(); 9 | 10 | fireEvent.press(out.getByText('Press Me')); 11 | 12 | expect(onPress).toBeCalled(); 13 | }); 14 | -------------------------------------------------------------------------------- /mobile/src/constants/colors.js: -------------------------------------------------------------------------------- 1 | export default { 2 | primary: '#202c41', 3 | disabled: '#af7d7b', 4 | border: '#c6c6c6', 5 | white: '#fff', 6 | gray: '#9ca5ab', 7 | background: '#eef0f3', 8 | error: '#b55464', 9 | brand: '#f04037', 10 | icon: '#5f5f61', 11 | }; 12 | -------------------------------------------------------------------------------- /mobile/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { NavigationContainer } from '@react-navigation/native'; 3 | import 'react-native-gesture-handler'; 4 | import { QueryClient, QueryClientProvider } from 'react-query'; 5 | import { StripeProvider } from '@stripe/stripe-react-native'; 6 | import { STRIPE_PUBLIC } from '@env'; 7 | 8 | import { Main } from './navigation/Main'; 9 | 10 | const queryClient = new QueryClient(); 11 | 12 | export default function App() { 13 | return ( 14 | 15 | 16 | 17 |

18 | 19 | 20 | 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /mobile/src/navigation/Main.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | createStackNavigator, 4 | HeaderBackButton, 5 | } from '@react-navigation/stack'; 6 | import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; 7 | import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; 8 | 9 | import { Home } from '../screens/Home'; 10 | import { Explore } from '../screens/Explore'; 11 | import { Account } from '../screens/Account'; 12 | import { Cart } from '../screens/Cart'; 13 | import { ProductDetail } from '../screens/ProductDetail'; 14 | import { SignIn } from '../screens/SignIn'; 15 | import { SignUp } from '../screens/SignUp'; 16 | 17 | import { TabBarIcon, HeaderIcon, CartIcon } from '../components/Navigation'; 18 | import colors from '../constants/colors'; 19 | 20 | const tabStackScreenOptions = { 21 | headerRight: () => , 22 | headerBackTitleVisible: false, 23 | headerLeft: props => { 24 | if (!props.canGoBack) { 25 | return null; 26 | } 27 | return ; 28 | }, 29 | }; 30 | 31 | const HomeStack = createStackNavigator(); 32 | const HomeStackNav = () => ( 33 | 34 | 35 | 36 | 37 | ); 38 | 39 | const ExploreStack = createStackNavigator(); 40 | const ExploreStackNav = () => ( 41 | 42 | 43 | 44 | 45 | ); 46 | 47 | const AccountStack = createStackNavigator(); 48 | const AccountStackNav = () => ( 49 | 50 | 51 | 52 | ); 53 | 54 | const MainTabs = createBottomTabNavigator(); 55 | const Tabs = () => ( 56 | ({ 62 | tabBarIcon: props => , 63 | })} 64 | > 65 | 66 | 67 | 68 | 69 | ); 70 | 71 | const Auth = createMaterialTopTabNavigator(); 72 | const AuthTabs = () => ( 73 | 74 | 75 | 76 | 77 | ); 78 | 79 | const MainStack = createStackNavigator(); 80 | export const Main = () => ( 81 | 82 | 89 | ({ 93 | headerLeft: () => ( 94 | navigation.pop()} 98 | /> 99 | ), 100 | })} 101 | /> 102 | ({ 106 | headerLeft: () => ( 107 | navigation.pop()} 111 | /> 112 | ), 113 | })} 114 | /> 115 | 116 | ); 117 | -------------------------------------------------------------------------------- /mobile/src/screens/Account.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View } from 'react-native'; 3 | 4 | import { Button } from '../components/Button'; 5 | import { useAuth } from '../util/auth'; 6 | 7 | export const Account = ({ navigation }) => { 8 | const { token, removeToken } = useAuth(state => ({ 9 | token: state.token, 10 | removeToken: state.removeToken, 11 | })); 12 | const isLoggedIn = token !== null; 13 | 14 | return ( 15 | 16 | {isLoggedIn ? ( 17 | 18 | ) : ( 19 | 20 | )} 21 | 22 | ); 23 | }; 24 | -------------------------------------------------------------------------------- /mobile/src/screens/Cart.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View, StyleSheet, ScrollView, Alert } from 'react-native'; 3 | 4 | import { Text } from '../components/Text'; 5 | import colors from '../constants/colors'; 6 | import { useCart, cartTotal } from '../util/cart'; 7 | import { CartRow } from '../components/CartRow'; 8 | import { money } from '../util/format'; 9 | import { usePayment } from '../util/api'; 10 | import { Button } from '../components/Button'; 11 | import { useAuth } from '../util/auth'; 12 | 13 | const styles = StyleSheet.create({ 14 | emptyContainer: { 15 | backgroundColor: colors.white, 16 | flex: 1, 17 | paddingTop: 60, 18 | alignItems: 'center', 19 | }, 20 | container: { 21 | backgroundColor: colors.white, 22 | }, 23 | summaryContainer: { 24 | paddingHorizontal: 10, 25 | paddingVertical: 20, 26 | borderTopColor: colors.border, 27 | borderTopWidth: StyleSheet.hairlineWidth, 28 | }, 29 | }); 30 | 31 | export const Cart = ({ navigation }) => { 32 | const { token } = useAuth(state => ({ 33 | token: state.token, 34 | })); 35 | const isLoggedIn = token !== null; 36 | 37 | const { cart, clearCart } = useCart(state => ({ 38 | cart: state.cart, 39 | clearCart: state.clearCart, 40 | })); 41 | const { checkout } = usePayment(cart); 42 | 43 | const onCheckout = async () => { 44 | try { 45 | const { error } = await checkout(); 46 | if (!error) { 47 | Alert.alert('Success', 'Your order is confirmed!'); 48 | clearCart(); 49 | navigation.popToTop(); 50 | navigation.goBack(null); 51 | } else { 52 | console.log('error', error); 53 | } 54 | } catch (error) { 55 | Alert.alert('Sorry', 'Something went wrong.'); 56 | console.log(error); 57 | } 58 | }; 59 | 60 | const isEmpty = Object.keys(cart).length === 0; 61 | if (isEmpty) { 62 | return ( 63 | 64 | 65 | YOUR CART IS EMPTY 66 | 67 | 68 | ); 69 | } 70 | 71 | return ( 72 | 73 | {Object.keys(cart).map(id => { 74 | return ; 75 | })} 76 | 77 | 78 | Total: 79 | {money(cartTotal(cart))} 80 | 81 | 82 | 83 | {isLoggedIn ? ( 84 | 85 | ) : ( 86 | 89 | )} 90 | 91 | 92 | 93 | ); 94 | }; 95 | -------------------------------------------------------------------------------- /mobile/src/screens/Explore.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { Loading } from '../components/Loading'; 4 | import { useExploreData } from '../util/api'; 5 | import { ProductList } from '../components/List'; 6 | 7 | export const Explore = () => { 8 | const res = useExploreData(); 9 | const { isLoading, data } = res; 10 | 11 | if (isLoading) { 12 | return ; 13 | } 14 | 15 | const sections = data.categories.map(category => ({ 16 | title: category.name, 17 | data: category.products, 18 | items: undefined, 19 | })); 20 | 21 | return ; 22 | }; 23 | -------------------------------------------------------------------------------- /mobile/src/screens/Home.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { ProductList } from '../components/List'; 4 | import { Loading } from '../components/Loading'; 5 | import { useHomeData } from '../util/api'; 6 | 7 | export const Home = () => { 8 | const res = useHomeData(); 9 | const { isLoading, data } = res; 10 | 11 | if (isLoading) { 12 | return ; 13 | } 14 | 15 | const sections = data?.data?.map(d => ({ 16 | ...d, 17 | data: d.items, 18 | items: undefined, 19 | })); 20 | 21 | return ; 22 | }; 23 | -------------------------------------------------------------------------------- /mobile/src/screens/ProductDetail.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react'; 2 | import { ScrollView, View, Image, StyleSheet } from 'react-native'; 3 | 4 | import { Text } from '../components/Text'; 5 | import colors from '../constants/colors'; 6 | import { money } from '../util/format'; 7 | import { useDetailData } from '../util/api'; 8 | import { Loading } from '../components/Loading'; 9 | import { QuantityCounter } from '../components/QuantityCounter'; 10 | import { useCart } from '../util/cart'; 11 | 12 | const styles = StyleSheet.create({ 13 | section: { 14 | backgroundColor: colors.white, 15 | paddingHorizontal: 10, 16 | paddingVertical: 15, 17 | marginVertical: 15, 18 | flexDirection: 'row', 19 | borderTopWidth: StyleSheet.hairlineWidth, 20 | borderBottomWidth: StyleSheet.hairlineWidth, 21 | borderColor: colors.border, 22 | }, 23 | image: { 24 | width: 150, 25 | height: 150, 26 | marginRight: 15, 27 | }, 28 | }); 29 | 30 | export const ProductDetail = ({ route }) => { 31 | const cart = useCart(state => ({ 32 | quantity: state.cart[route.params.id]?.quantity || 0, 33 | addItem: state.addItem, 34 | removeItem: state.removeItem, 35 | })); 36 | 37 | const [data, setData] = React.useState(route.params); 38 | 39 | const res = useDetailData({ id: route.params.id }); 40 | 41 | useEffect(() => { 42 | if (res.isSuccess && res?.data?.data) { 43 | setData(res.data.data); 44 | } 45 | }, [res.isFetching]); 46 | 47 | return ( 48 | <> 49 | 50 | 51 | 56 | 57 | {data.name} 58 | 59 | {money(data.price)} 60 | 61 | 62 | 63 | 64 | 65 | Description 66 | {data.isLoading ? : {data.description}} 67 | 68 | 69 | cart.removeItem({ id: data.id })} 73 | onIncrement={() => 74 | cart.addItem({ id: data.id, price: data.price, name: data.name }) 75 | } 76 | /> 77 | 78 | ); 79 | }; 80 | -------------------------------------------------------------------------------- /mobile/src/screens/SignIn.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { ScrollView, StyleSheet } from 'react-native'; 3 | 4 | import { TextInput } from '../components/Form'; 5 | import { Button } from '../components/Button'; 6 | import colors from '../constants/colors'; 7 | import { validateCredentials } from '../util/auth'; 8 | import { useSignIn } from '../util/api'; 9 | 10 | const styles = StyleSheet.create({ 11 | container: { 12 | backgroundColor: colors.white, 13 | padding: 20, 14 | }, 15 | }); 16 | 17 | export const SignIn = ({ navigation }) => { 18 | const [form, setForm] = React.useState({}); 19 | const [errors, setError] = React.useState({}); 20 | const signin = useSignIn(); 21 | 22 | const setValue = (field, value) => { 23 | setForm(f => { 24 | const next = { ...f }; 25 | next[field] = value; 26 | return next; 27 | }); 28 | }; 29 | 30 | const submit = async () => { 31 | try { 32 | await validateCredentials(form, false); 33 | } catch (error) { 34 | const nextErrors = {}; 35 | error.inner.forEach(e => { 36 | nextErrors[e.path] = e.message; 37 | }); 38 | setError(nextErrors); 39 | return; 40 | } 41 | 42 | signin.mutate(form, { 43 | onSuccess: () => { 44 | navigation.pop(); 45 | }, 46 | }); 47 | }; 48 | 49 | return ( 50 | 51 | setValue('email', text)} 54 | errorText={errors.email} 55 | keyboardType="email-address" 56 | autoCapitalize="none" 57 | /> 58 | setValue('password', text)} 61 | errorText={errors.password || signin?.error?.message} 62 | secureTextEntry 63 | /> 64 | 67 | 68 | ); 69 | }; 70 | -------------------------------------------------------------------------------- /mobile/src/screens/SignUp.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { ScrollView, StyleSheet } from 'react-native'; 3 | 4 | import { TextInput } from '../components/Form'; 5 | import { Button } from '../components/Button'; 6 | import colors from '../constants/colors'; 7 | import { validateCredentials } from '../util/auth'; 8 | import { useSignUp } from '../util/api'; 9 | 10 | const styles = StyleSheet.create({ 11 | container: { 12 | backgroundColor: colors.white, 13 | padding: 20, 14 | }, 15 | }); 16 | 17 | export const SignUp = ({ navigation }) => { 18 | const [form, setForm] = React.useState({}); 19 | const [errors, setError] = React.useState({}); 20 | const signup = useSignUp(); 21 | 22 | const setValue = (field, value) => { 23 | setForm(f => { 24 | const next = { ...f }; 25 | next[field] = value; 26 | return next; 27 | }); 28 | }; 29 | 30 | const submit = async () => { 31 | try { 32 | await validateCredentials(form); 33 | } catch (error) { 34 | const nextErrors = {}; 35 | error.inner.forEach(e => { 36 | nextErrors[e.path] = e.message; 37 | }); 38 | setError(nextErrors); 39 | return; 40 | } 41 | 42 | signup.mutate(form, { 43 | onSuccess: () => { 44 | navigation.pop(); 45 | }, 46 | }); 47 | }; 48 | 49 | return ( 50 | 51 | setValue('email', text)} 54 | errorText={errors.email} 55 | keyboardType="email-address" 56 | autoCapitalize="none" 57 | /> 58 | setValue('password', text)} 61 | errorText={errors.password} 62 | secureTextEntry 63 | /> 64 | setValue('confirmPassword', text)} 67 | errorText={errors.confirmPassword || signup?.error?.message} 68 | secureTextEntry 69 | /> 70 | 73 | 74 | ); 75 | }; 76 | -------------------------------------------------------------------------------- /mobile/src/util/__tests__/auth.test.js: -------------------------------------------------------------------------------- 1 | import { Alert } from 'react-native'; 2 | import { renderHook, act } from '@testing-library/react-hooks'; 3 | 4 | import { useLogin } from '../auth'; 5 | 6 | describe('useLogin', () => { 7 | it('returns errors if no values provided at submit', () => { 8 | const alertSpy = jest.spyOn(Alert, 'alert'); 9 | 10 | const { result } = renderHook(() => useLogin()); 11 | 12 | act(() => { 13 | result.current.submit(); 14 | }); 15 | 16 | expect(result.current.errors).toEqual({ 17 | email: 'This field is required.', 18 | password: 'This field is required.', 19 | }); 20 | 21 | expect(alertSpy).not.toBeCalled(); 22 | }); 23 | 24 | it('calls alert with valid input', () => { 25 | const alertSpy = jest.spyOn(Alert, 'alert'); 26 | const { result } = renderHook(() => useLogin()); 27 | 28 | act(() => { 29 | result.current.setEmail('test@example.com'); 30 | result.current.setPassword('password'); 31 | }); 32 | 33 | act(() => { 34 | result.current.submit(); 35 | }); 36 | 37 | expect(alertSpy).toBeCalled(); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /mobile/src/util/api.js: -------------------------------------------------------------------------------- 1 | import { useQuery, useMutation } from 'react-query'; 2 | import { useStripe } from '@stripe/stripe-react-native'; 3 | import { API_URL } from '@env'; 4 | 5 | import { useAuth } from './auth'; 6 | 7 | const appFetch = (path, options = {}) => 8 | fetch(`${API_URL}${path}`, options).then(res => res.json()); 9 | 10 | export const useSignIn = () => { 11 | const setToken = useAuth(state => state.setToken); 12 | 13 | return useMutation( 14 | ({ email, password }) => { 15 | return appFetch('/auth/login', { 16 | method: 'POST', 17 | headers: { 18 | 'Content-Type': 'application/json', 19 | }, 20 | body: JSON.stringify({ email, password }), 21 | }); 22 | }, 23 | { 24 | onSuccess: data => { 25 | if (!data.token) { 26 | throw new Error(data.message); 27 | } 28 | 29 | setToken(data.token); 30 | }, 31 | }, 32 | ); 33 | }; 34 | 35 | export const useSignUp = () => { 36 | const setToken = useAuth(state => state.setToken); 37 | 38 | return useMutation( 39 | ({ email, password }) => { 40 | return appFetch('/auth/register', { 41 | method: 'POST', 42 | headers: { 43 | 'Content-Type': 'application/json', 44 | }, 45 | body: JSON.stringify({ email, password }), 46 | }); 47 | }, 48 | { 49 | onSuccess: data => { 50 | if (!data.token) { 51 | throw new Error(data.message); 52 | } 53 | 54 | setToken(data.token); 55 | }, 56 | }, 57 | ); 58 | }; 59 | 60 | export const useHomeData = () => { 61 | return useQuery('home', () => appFetch('/products/trending')); 62 | }; 63 | 64 | export const useExploreData = () => { 65 | return useQuery('explore', () => appFetch('/products/explore')); 66 | }; 67 | 68 | export const useDetailData = ({ id }) => { 69 | return useQuery(`details-${id}`, () => appFetch(`/product/${id}`)); 70 | }; 71 | 72 | export const usePayment = (cart = {}) => { 73 | const { initPaymentSheet, presentPaymentSheet } = useStripe(); 74 | const authToken = useAuth(state => state.token); 75 | 76 | const fetchPaymentSheetParams = async () => { 77 | const response = await fetch(`${API_URL}/checkout`, { 78 | method: 'POST', 79 | headers: { 80 | 'Content-Type': 'application/json', 81 | Authorization: `Bearer ${authToken}`, 82 | }, 83 | body: JSON.stringify({ 84 | cart, 85 | }), 86 | }); 87 | const { paymentIntent, customer, ephemeralKey } = await response.json(); 88 | 89 | return { 90 | paymentIntent, 91 | customer, 92 | ephemeralKey, 93 | }; 94 | }; 95 | 96 | const checkout = async () => { 97 | const { paymentIntent, customer, ephemeralKey } = 98 | await fetchPaymentSheetParams(); 99 | 100 | const { error } = await initPaymentSheet({ 101 | paymentIntentClientSecret: paymentIntent, 102 | customerEphemeralKeySecret: ephemeralKey, 103 | customerId: customer, 104 | }); 105 | 106 | if (!error) { 107 | return presentPaymentSheet({ clientSecret: paymentIntent }); 108 | } 109 | 110 | return null; 111 | }; 112 | 113 | return { checkout }; 114 | }; 115 | -------------------------------------------------------------------------------- /mobile/src/util/auth.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Alert } from 'react-native'; 3 | import * as yup from 'yup'; 4 | import create from 'zustand'; 5 | import { persist } from 'zustand/middleware'; 6 | import AsyncStorage from '@react-native-async-storage/async-storage'; 7 | 8 | export const useAuth = create( 9 | persist( 10 | set => ({ 11 | token: null, 12 | setToken: token => set({ token }), 13 | removeToken: () => set({ token: null }), 14 | }), 15 | { 16 | name: 'auth', 17 | getStorage: () => AsyncStorage, 18 | }, 19 | ), 20 | ); 21 | 22 | export const useLogin = () => { 23 | const [email, setEmail] = React.useState(''); 24 | const [password, setPassword] = React.useState(''); 25 | const [errors, setErrors] = React.useState({}); 26 | 27 | const submit = () => { 28 | const nextErrors = {}; 29 | if (email.length === 0) { 30 | nextErrors.email = 'This field is required.'; 31 | } 32 | if (password.length === 0) { 33 | nextErrors.password = 'This field is required.'; 34 | } 35 | setErrors(nextErrors); 36 | 37 | if (Object.keys(nextErrors).length > 0) { 38 | return null; 39 | } 40 | 41 | Alert.alert('Success!', `Email: ${email} \n Password: ${password}`); 42 | return null; 43 | }; 44 | 45 | return { 46 | submit, 47 | errors, 48 | email, 49 | setEmail, 50 | password, 51 | setPassword, 52 | }; 53 | }; 54 | 55 | export const validateCredentials = ( 56 | credentials = {}, 57 | useConfirmPassword = true, 58 | ) => { 59 | const extraValidation = {}; 60 | 61 | if (useConfirmPassword) { 62 | extraValidation.confirmPassword = yup 63 | .string() 64 | .test('passwords-match', 'Passwords must match', function (value) { 65 | return this.parent.password === value; 66 | }); 67 | } 68 | 69 | const schema = yup.object().shape({ 70 | email: yup.string().email().required().label('Email'), 71 | password: yup.string().required().label('Password'), 72 | ...extraValidation, 73 | }); 74 | 75 | return schema.validate(credentials, { abortEarly: false }); 76 | }; 77 | -------------------------------------------------------------------------------- /mobile/src/util/cart.js: -------------------------------------------------------------------------------- 1 | import create from 'zustand'; 2 | import { persist } from 'zustand/middleware'; 3 | import AsyncStorage from '@react-native-async-storage/async-storage'; 4 | 5 | export const cartTotal = cart => { 6 | let total = 0; 7 | 8 | Object.keys(cart).forEach(id => { 9 | const item = cart[id]; 10 | total += item.price * item.quantity; 11 | }); 12 | 13 | return total; 14 | }; 15 | 16 | export const cartQuantity = cart => { 17 | let quantity = 0; 18 | 19 | Object.keys(cart).forEach(id => { 20 | const item = cart[id]; 21 | quantity += item.quantity; 22 | }); 23 | 24 | return quantity; 25 | }; 26 | 27 | export const useCart = create( 28 | persist( 29 | set => ({ 30 | cart: {}, 31 | addItem: ({ id, name, price }) => 32 | set(state => { 33 | const cart = { ...state.cart }; 34 | if (!cart[id]) { 35 | cart[id] = { 36 | id, 37 | name, 38 | price, 39 | quantity: 0, 40 | }; 41 | } 42 | 43 | cart[id].quantity += 1; 44 | 45 | return { cart }; 46 | }), 47 | removeItem: ({ id }) => 48 | set(state => { 49 | const cart = { ...state.cart }; 50 | 51 | if (!cart[id]) { 52 | return { cart }; 53 | } 54 | 55 | const quantity = cart[id].quantity - 1; 56 | 57 | if (quantity <= 0) { 58 | delete cart[id]; 59 | } else { 60 | cart[id].quantity = quantity; 61 | } 62 | 63 | return { cart }; 64 | }), 65 | clearCart: () => set(() => ({ cart: {} })), 66 | }), 67 | { 68 | name: 'cart', 69 | getStorage: () => AsyncStorage, 70 | }, 71 | ), 72 | ); 73 | 74 | export const useItem = id => { 75 | return useCart(state => state.cart[id] || {}); 76 | }; 77 | -------------------------------------------------------------------------------- /mobile/src/util/format.js: -------------------------------------------------------------------------------- 1 | export const money = num => { 2 | return `$${(Math.round(num * 0.01 * 100) / 100).toFixed(2)}`; 3 | }; 4 | -------------------------------------------------------------------------------- /server/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['handlebarlabs', 'plugin:prettier/recommended'], 4 | rules: { 5 | 'react/react-in-jsx-scope': 0, 6 | }, 7 | globals: {}, 8 | plugins: [], 9 | }; 10 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env.local 29 | .env.development.local 30 | .env.test.local 31 | .env.production.local 32 | .env 33 | 34 | # vercel 35 | .vercel 36 | -------------------------------------------------------------------------------- /server/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: true, 3 | jsxBracketSameLine: false, 4 | singleQuote: true, 5 | trailingComma: "all", 6 | arrowParens: "avoid", 7 | }; 8 | -------------------------------------------------------------------------------- /server/README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). 2 | 3 | ## Getting Started 4 | 5 | First, run the development server: 6 | 7 | ```bash 8 | npm run dev 9 | # or 10 | yarn dev 11 | ``` 12 | 13 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 14 | 15 | You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file. 16 | 17 | [API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`. 18 | 19 | The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. 20 | 21 | ## Learn More 22 | 23 | To learn more about Next.js, take a look at the following resources: 24 | 25 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 26 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 27 | 28 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 29 | 30 | ## Deploy on Vercel 31 | 32 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 33 | 34 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 35 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "eslint ." 10 | }, 11 | "dependencies": { 12 | "@prisma/client": "^2.25.0", 13 | "bcryptjs": "^2.4.3", 14 | "jsonwebtoken": "^8.5.1", 15 | "next": "^11.0.0", 16 | "react": "^17.0.2", 17 | "react-dom": "^17.0.2", 18 | "stripe": "^8.156.0" 19 | }, 20 | "devDependencies": { 21 | "eslint": "^7.29.0", 22 | "eslint-config-handlebarlabs": "^0.0.6", 23 | "eslint-config-prettier": "^8.3.0", 24 | "eslint-plugin-prettier": "^3.4.0", 25 | "prettier": "^2.3.1", 26 | "prisma": "^2.25.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /server/pages/_app.js: -------------------------------------------------------------------------------- 1 | import '../styles/globals.css'; 2 | 3 | function MyApp({ Component, pageProps }) { 4 | return ; 5 | } 6 | 7 | export default MyApp; 8 | -------------------------------------------------------------------------------- /server/pages/api/auth/login.js: -------------------------------------------------------------------------------- 1 | import prisma from '../../../util/prisma'; 2 | import { comparePassword, generateJWT } from '../../../util/auth'; 3 | 4 | export default async (req, res) => { 5 | if (req.method !== 'POST') { 6 | return res.status(405).json({ message: 'Method not allowed' }); 7 | } 8 | 9 | try { 10 | const { email, password } = req?.body || {}; 11 | 12 | const user = await prisma.user.findFirst({ 13 | where: { 14 | email, 15 | }, 16 | }); 17 | 18 | if (!user) { 19 | throw new Error('No user found.'); 20 | } 21 | 22 | const isValidPassword = await comparePassword(password, user.password); 23 | if (!isValidPassword) { 24 | throw new Error('Invalid password.'); 25 | } 26 | 27 | // return JWT 28 | const token = await generateJWT(user.id); 29 | 30 | return res.status(200).json({ 31 | token, 32 | userId: user.id, 33 | }); 34 | } catch (error) { 35 | return res 36 | .status(400) 37 | .json({ message: error.message || 'Something went wrong.' }); 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /server/pages/api/auth/register.js: -------------------------------------------------------------------------------- 1 | import prisma from '../../../util/prisma'; 2 | import { hashPassword, generateJWT } from '../../../util/auth'; 3 | 4 | export default async (req, res) => { 5 | if (req.method !== 'POST') { 6 | return res.status(405).json({ message: 'Method not allowed' }); 7 | } 8 | 9 | try { 10 | // hash password 11 | const user = req?.body || {}; 12 | user.password = await hashPassword(user.password); 13 | 14 | // save to db 15 | const createdUser = await prisma.user.create({ data: user }); 16 | 17 | // return JWT 18 | const token = await generateJWT(createdUser.id); 19 | 20 | return res.status(200).json({ 21 | token, 22 | userId: createdUser.id, 23 | }); 24 | } catch (error) { 25 | if (error.code === 'P2002') { 26 | return res.status(200).json({ message: 'Account already exists.' }); 27 | } 28 | 29 | console.log(error); 30 | return res.status(400).json({ message: 'Something went wrong.' }); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /server/pages/api/checkout.js: -------------------------------------------------------------------------------- 1 | import Stripe from 'stripe'; 2 | 3 | import { getUserFromHeader } from '../../util/auth'; 4 | import prisma from '../../util/prisma'; 5 | 6 | const stripe = new Stripe(process.env.STRIPE_SECRET); 7 | 8 | const createStripeUser = async ({ id, email }) => { 9 | const customer = await stripe.customers.create({ email }); 10 | 11 | return prisma.user.update({ 12 | where: { 13 | id, 14 | }, 15 | data: { 16 | stripe_customer_id: customer.id, 17 | }, 18 | }); 19 | }; 20 | 21 | const getProductsFromCart = cart => { 22 | const productIds = Object.keys(cart); 23 | return prisma.product.findMany({ 24 | where: { 25 | id: { 26 | in: productIds, 27 | }, 28 | }, 29 | select: { 30 | id: true, 31 | price: true, 32 | }, 33 | }); 34 | }; 35 | 36 | const getTotalPrice = (products, cart) => { 37 | let total = 0; 38 | products.forEach(product => { 39 | total += product.price * cart[product.id].quantity; 40 | }); 41 | 42 | return total; 43 | }; 44 | 45 | const createStripePaymentIntent = async (customerId, total) => { 46 | // Create an ephemeral key for the Customer; this allows the app to display saved payment methods and save new ones 47 | const ephemeralKey = await stripe.ephemeralKeys.create( 48 | { customer: customerId }, 49 | { apiVersion: '2020-08-27' }, 50 | ); 51 | 52 | // Create payment intent 53 | const paymentIntent = await stripe.paymentIntents.create({ 54 | amount: total, 55 | currency: 'usd', 56 | customer: customerId, 57 | }); 58 | 59 | return { ephemeralKey, paymentIntent }; 60 | }; 61 | 62 | export default async (req, res) => { 63 | if (req.method !== 'POST') { 64 | return res.status(405).json({ message: 'Method not allowed' }); 65 | } 66 | 67 | let user = await getUserFromHeader(req, res); 68 | if (!user) { 69 | return res 70 | .status(401) 71 | .json({ message: 'You must be signed in to do that.' }); 72 | } 73 | 74 | // Ensure that we've registered them with stripe. This will happen on their first checkout 75 | if (!user.stripe_customer_id) { 76 | user = await createStripeUser(user); 77 | } 78 | 79 | const cart = req.body.cart || {}; 80 | 81 | // get products 82 | const products = await getProductsFromCart(cart); 83 | 84 | // calculate total 85 | const total = getTotalPrice(products, cart); 86 | 87 | // Connect with stripe and create a payment intent 88 | const { ephemeralKey, paymentIntent } = createStripePaymentIntent( 89 | user.stripe_customer_id, 90 | total, 91 | ); 92 | 93 | return res.status(200).json({ 94 | paymentIntent: paymentIntent.client_secret, 95 | customer: user.stripe_customer_id, 96 | ephemeralKey: ephemeralKey.secret, 97 | cart, 98 | }); 99 | }; 100 | -------------------------------------------------------------------------------- /server/pages/api/hello.js: -------------------------------------------------------------------------------- 1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction 2 | 3 | export default (req, res) => { 4 | res.status(200).json({ name: 'John Doe' }); 5 | }; 6 | -------------------------------------------------------------------------------- /server/pages/api/product/[id].js: -------------------------------------------------------------------------------- 1 | import prisma from '../../../util/prisma'; 2 | 3 | export default async (req, res) => { 4 | if (req.method !== 'GET') { 5 | return res.status(405).json({ message: 'Method not allowed' }); 6 | } 7 | 8 | const id = req?.query?.id; 9 | if (!id) { 10 | return res.status(400).json({ message: 'Missing product id.' }); 11 | } 12 | 13 | const selectFields = { 14 | id: true, 15 | name: true, 16 | image: true, 17 | price: true, 18 | description: true, 19 | }; 20 | 21 | const data = await prisma.product.findUnique({ 22 | where: { 23 | id, 24 | }, 25 | select: selectFields, // only return certain fields 26 | }); 27 | 28 | if (!data) { 29 | return res.status(400).json({ message: 'Invalid product id.' }); 30 | } 31 | 32 | return res.status(200).json({ data }); 33 | }; 34 | -------------------------------------------------------------------------------- /server/pages/api/products/explore.js: -------------------------------------------------------------------------------- 1 | import prisma from '../../../util/prisma'; 2 | 3 | export default async (req, res) => { 4 | if (req.method !== 'GET') { 5 | return res.status(405).json({ message: 'Method not allowed' }); 6 | } 7 | 8 | const categories = await prisma.category.findMany({ 9 | // Only get categories that have at least one product in them 10 | where: { 11 | products: { some: {} }, 12 | }, 13 | orderBy: { 14 | name: 'asc', 15 | }, 16 | select: { 17 | id: true, 18 | name: true, 19 | // we also want to grab the child products 20 | products: { 21 | select: { 22 | id: true, 23 | name: true, 24 | image: true, 25 | price: true, 26 | }, 27 | }, 28 | }, 29 | }); 30 | 31 | return res.status(200).json({ categories }); 32 | }; 33 | -------------------------------------------------------------------------------- /server/pages/api/products/trending.js: -------------------------------------------------------------------------------- 1 | import prisma from '../../../util/prisma'; 2 | 3 | export default async (req, res) => { 4 | if (req.method !== 'GET') { 5 | return res.status(405).json({ message: 'Method not allowed' }); 6 | } 7 | 8 | const selectFields = { 9 | id: true, 10 | name: true, 11 | image: true, 12 | price: true, 13 | }; 14 | 15 | const bestSellers = await prisma.product.findMany({ 16 | where: { 17 | soldCount: { 18 | gt: 0, // only get items that have been sold 19 | }, 20 | }, 21 | orderBy: { 22 | soldCount: 'desc', // sort the results 23 | }, 24 | take: 3, // limit results to 3 25 | select: selectFields, // only return certain fields 26 | }); 27 | 28 | const newItems = await prisma.product.findMany({ 29 | orderBy: { 30 | createdAt: 'desc', 31 | }, 32 | take: 3, 33 | select: selectFields, 34 | }); 35 | 36 | const data = [ 37 | { 38 | title: 'Best Sellers', 39 | items: bestSellers, 40 | }, 41 | { 42 | title: 'New Items', 43 | items: newItems, 44 | }, 45 | ]; 46 | 47 | return res.status(200).json({ data }); 48 | }; 49 | -------------------------------------------------------------------------------- /server/pages/index.js: -------------------------------------------------------------------------------- 1 | import Head from 'next/head'; 2 | import Image from 'next/image'; 3 | import styles from '../styles/Home.module.css'; 4 | 5 | export default function Home() { 6 | return ( 7 | 68 | ); 69 | } 70 | -------------------------------------------------------------------------------- /server/prisma/dev.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/server/prisma/dev.db -------------------------------------------------------------------------------- /server/prisma/migrations/20210609203923_init/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "Product" ( 3 | "id" TEXT NOT NULL PRIMARY KEY, 4 | "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 5 | "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 6 | "name" TEXT NOT NULL, 7 | "price" INTEGER NOT NULL, 8 | "description" TEXT NOT NULL, 9 | "image" TEXT NOT NULL, 10 | "soldCount" INTEGER NOT NULL DEFAULT 0 11 | ); 12 | -------------------------------------------------------------------------------- /server/prisma/migrations/20210610212753_add_category/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "Category" ( 3 | "id" TEXT NOT NULL PRIMARY KEY, 4 | "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 5 | "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 6 | "name" TEXT NOT NULL 7 | ); 8 | 9 | -- RedefineTables 10 | PRAGMA foreign_keys=OFF; 11 | CREATE TABLE "new_Product" ( 12 | "id" TEXT NOT NULL PRIMARY KEY, 13 | "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 14 | "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 15 | "name" TEXT NOT NULL, 16 | "price" INTEGER NOT NULL, 17 | "description" TEXT NOT NULL, 18 | "image" TEXT NOT NULL, 19 | "soldCount" INTEGER NOT NULL DEFAULT 0, 20 | "categoryId" TEXT, 21 | FOREIGN KEY ("categoryId") REFERENCES "Category" ("id") ON DELETE SET NULL ON UPDATE CASCADE 22 | ); 23 | INSERT INTO "new_Product" ("createdAt", "description", "id", "image", "name", "price", "soldCount", "updatedAt") SELECT "createdAt", "description", "id", "image", "name", "price", "soldCount", "updatedAt" FROM "Product"; 24 | DROP TABLE "Product"; 25 | ALTER TABLE "new_Product" RENAME TO "Product"; 26 | PRAGMA foreign_key_check; 27 | PRAGMA foreign_keys=ON; 28 | -------------------------------------------------------------------------------- /server/prisma/migrations/20210618165608_add_user_model/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "User" ( 3 | "id" TEXT NOT NULL PRIMARY KEY, 4 | "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 5 | "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 6 | "email" TEXT NOT NULL, 7 | "password" TEXT NOT NULL 8 | ); 9 | -------------------------------------------------------------------------------- /server/prisma/migrations/20210618175453_make_user_email_unique/migration.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Warnings: 3 | 4 | - A unique constraint covering the columns `[email]` on the table `User` will be added. If there are existing duplicate values, this will fail. 5 | 6 | */ 7 | -- CreateIndex 8 | CREATE UNIQUE INDEX "User.email_unique" ON "User"("email"); 9 | -------------------------------------------------------------------------------- /server/prisma/migrations/20210621185425_add_stripe_customer_id_to_user/migration.sql: -------------------------------------------------------------------------------- 1 | -- AlterTable 2 | ALTER TABLE "User" ADD COLUMN "stripe_customer_id" TEXT; 3 | -------------------------------------------------------------------------------- /server/prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (i.e. Git) 3 | provider = "sqlite" -------------------------------------------------------------------------------- /server/prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | // This is your Prisma schema file, 2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema 3 | 4 | datasource db { 5 | // provider = "postgresql" 6 | // url = env("DATABASE_URL") 7 | provider = "sqlite" 8 | url = env("DATABASE_URL") 9 | } 10 | 11 | generator client { 12 | provider = "prisma-client-js" 13 | } 14 | 15 | model Product { 16 | id String @id @default(cuid()) // collision resistant unique id 17 | createdAt DateTime @default(now()) 18 | updatedAt DateTime @default(now()) @updatedAt 19 | name String 20 | price Int 21 | description String 22 | image String 23 | soldCount Int @default(0) 24 | category Category? @relation(fields: [categoryId], references: [id]) 25 | categoryId String? 26 | } 27 | 28 | model Category { 29 | id String @id @default(cuid()) 30 | createdAt DateTime @default(now()) 31 | updatedAt DateTime @default(now()) @updatedAt 32 | name String 33 | products Product[] 34 | } 35 | 36 | model User { 37 | id String @id @default(cuid()) 38 | createdAt DateTime @default(now()) 39 | updatedAt DateTime @default(now()) @updatedAt 40 | email String @unique 41 | password String 42 | stripe_customer_id String? 43 | } 44 | -------------------------------------------------------------------------------- /server/prisma/seed.js: -------------------------------------------------------------------------------- 1 | const { PrismaClient } = require('@prisma/client'); 2 | 3 | const prisma = new PrismaClient(); 4 | 5 | const categories = [ 6 | { 7 | name: 'Cakes', 8 | products: { 9 | create: [ 10 | { 11 | name: 'Chocolate Cake', 12 | price: 4999, 13 | image: 14 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/55/Chocolate_fudge_cake.jpg/440px-Chocolate_fudge_cake.jpg', 15 | description: 16 | 'Chocolate cake or chocolate gâteau (from French: gâteau au chocolat) is a cake flavored with melted chocolate, cocoa powder, or both.', 17 | }, 18 | { 19 | name: 'Coffee Cake', 20 | price: 3999, 21 | image: 22 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Vegan_Cranberry_Coffee_Cake_%284162820643%29.jpg/440px-Vegan_Cranberry_Coffee_Cake_%284162820643%29.jpg', 23 | description: 24 | 'Coffee cake is any cake intended to be eaten with coffee,[1] however British coffee cake is typically a sponge cake flavored with coffee,[2] typically baked in a circular shape with two layers separated by coffee butter icing,[3] which also covers the top of the cake. Walnuts are a common addition, to make coffee and walnut cake.[4] In the United States, coffee cake generally refers to a sweet cake intended to be eaten with coffee or tea (like tea cake).[5][6] The American variety is presented in a single layer, flavoured with either fruit or cinnamon, and leavened with either baking soda (or baking powder), which results in a more cake-like texture, or yeast, which results in a more bread-like texture. They may be loaf-shaped, for easy slicing or baked in a Bundt or tube pan.', 25 | }, 26 | { 27 | name: 'Swiss Roll', 28 | price: 1280, 29 | image: 30 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Sri_Lankan_Swiss_roll.jpg/1280px-Sri_Lankan_Swiss_roll.jpg', 31 | description: 32 | 'A Swiss roll, jelly roll, roll cake, cream roll, roulade or Swiss log is a type of rolled sponge cake filled with whipped cream, jam, or icing. It appears to have been invented in the nineteenth century, along with Battenberg cake, doughnuts, and Victoria sponge.[2] In the U.S., commercial versions of the cake are widely known under brand names like Ho Hos, Yodels, and Swiss Cake Rolls.', 33 | }, 34 | { 35 | name: 'Sponge Cake', 36 | price: 4450, 37 | image: 38 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Cake_competition_%2814287027130%29.jpg/1280px-Cake_competition_%2814287027130%29.jpg', 39 | description: 40 | 'Sponge cake is a light cake made with egg whites, flour and sugar,[1] sometimes leavened with baking powder.[2] Sponge cakes, leavened with beaten eggs, originated during the Renaissance, possibly in Spain.[3] The sponge cake is thought to be one of the first of the non-yeasted cakes, and the earliest attested sponge cake recipe in English is found in a book by the English poet Gervase Markham, The English Huswife, Containing the Inward and Outward Virtues Which Ought to Be in a Complete Woman (1615).[4]', 41 | }, 42 | { 43 | name: 'Layer Cake', 44 | price: 1799, 45 | image: 46 | 'https://upload.wikimedia.org/wikipedia/commons/3/3f/Dobos_cake_%28Gerbeaud_Confectionery_Budapest_Hungary%29.jpg', 47 | description: 48 | 'A layer cake (US English) or sandwich cake (UK English)[1] is a cake consisting of multiple stacked sheets of cake, held together by frosting or another type of filling, such as jam or other preserves. Popular flavor combinations include the German chocolate cake, red velvet cake, Black Forest cake, and carrot cake with cream cheese icing. Many wedding cakes are decorated layer cakes.', 49 | }, 50 | ], 51 | }, 52 | }, 53 | { 54 | name: 'Cookies', 55 | products: { 56 | create: [ 57 | { 58 | name: 'Chocolate Chip Cookies', 59 | price: 1999, 60 | image: 61 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f1/2ChocolateChipCookies.jpg/440px-2ChocolateChipCookies.jpg', 62 | description: 63 | 'A chocolate chip cookie is a drop cookie that features chocolate chips or chocolate morsels as its distinguishing ingredient. Chocolate chip cookies originated in the United States around 1938, when Ruth Graves Wakefield chopped up a Nestlé semi-sweet chocolate bar and added the chopped chocolate to a cookie recipe. Generally, the recipe starts with a dough composed of flour, butter, both brown and white sugar, semi-sweet chocolate chips, eggs, and vanilla. Variations on the recipe may add other types of chocolate, as well as additional ingredients such as nuts or oatmeal. There are also vegan versions with the necessary ingredient substitutions, such as vegan chocolate chips, vegan margarine, and egg substitutes. A chocolate chocolate chip cookie uses a dough flavored with chocolate or cocoa powder, before chocolate chips are mixed in. These variations of the recipe are also referred to as ‘double’ or ‘triple’ chocolate chip cookies, depending on the combination of dough and chocolate types.', 64 | }, 65 | { 66 | name: 'Macaron Cookies', 67 | price: 2500, 68 | image: 69 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/VanillaMacaron.jpg/1280px-VanillaMacaron.jpg', 70 | description: 71 | 'A macaron [1][2] French: [ma.ka.ʁɔ̃]) or French macaroon (/ˌmækəˈruːn/ mak-ə-ROON[3][4]) is a sweet meringue-based confection made with egg white, icing sugar, granulated sugar, almond meal, and food colouring. Since the 19th century, a typical Parisian-style macaron is presented with a ganache, buttercream or jam filling sandwiched between two such cookies, akin to a sandwich cookie. The confection is characterized by a smooth squared top, a ruffled circumference—referred to as the "crown" or "foot" (or "pied")—and a flat base.', 72 | }, 73 | { 74 | name: 'Ginger Snap Cookies', 75 | price: 1599, 76 | image: 77 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Arnott%27s_Ginger_Nut_04.jpg/1280px-Arnott%27s_Ginger_Nut_04.jpg', 78 | description: 79 | 'A gingersnap,[1] ginger snap, ginger nut,[2] or ginger biscuit is a globally popular biscuit flavoured with ginger. Ginger snaps are flavoured with powdered ginger and a variety of other spices, most commonly cinnamon, molasses[3] and clove.[4] There are many recipes.[5] The brittle ginger nut style is a commercial version of the traditional fairings once made for market fairs now represented only by the Cornish fairing.', 80 | }, 81 | { 82 | name: 'Oatmeal Raisin Cookies', 83 | price: 1325, 84 | image: 85 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/09/Oatmeal_Cookies_with_orange_zest%2C_golden_raisins%2C_and_chocolate_chips.jpg/1280px-Oatmeal_Cookies_with_orange_zest%2C_golden_raisins%2C_and_chocolate_chips.jpg', 86 | description: 87 | 'An oatmeal raisin cookie is a type of drop cookie made from an oatmeal-based dough with raisins. Its ingredients also typically include flour, sugar, eggs, salt, and spices.[1] When the cookies were becoming prominent in the United States in the early 1900s, they came to be known as a health food[3] because of the fiber and vitamins from the oatmeal and raisins. Nonetheless, the nutritional value of an oatmeal raisin cookie is essentially the same as a chocolate chip cookie in sugar, fat, calorie and fiber content.[4][5]', 88 | }, 89 | { 90 | name: 'Peanut Butter Biscuits', 91 | price: 1450, 92 | image: 93 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Peanut_butter_cookies%2C_September_2009.jpg/1280px-Peanut_butter_cookies%2C_September_2009.jpg', 94 | description: 95 | 'A peanut butter cookie is a type of cookie that is distinguished for having peanut butter as a principal ingredient. The cookie originated in the United States, its development dating back to the 1910s.[1] If crunchy peanut butter is used, the resulting cookie may contain peanut fragments.', 96 | }, 97 | ], 98 | }, 99 | }, 100 | { 101 | name: 'Frozen', 102 | products: { 103 | create: [ 104 | { 105 | name: 'Ice Cream', 106 | price: 550, 107 | image: 108 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/Ice_cream_with_whipped_cream%2C_chocolate_syrup%2C_and_a_wafer_%28cropped%29.jpg/1024px-Ice_cream_with_whipped_cream%2C_chocolate_syrup%2C_and_a_wafer_%28cropped%29.jpg', 109 | description: 110 | 'Ice cream (derived from earlier cream ice)[1] is a sweetened frozen food typically eaten as a snack or dessert. It may be made from dairy milk or cream and is flavoured with a sweetener, either sugar or an alternative, and a spice, such as cocoa or vanilla, or with fruit such as strawberries or peaches. It can also be made by whisking a flavored cream base and liquid nitrogen together. Colorings are sometimes added, in addition to stabilizers.', 111 | }, 112 | { 113 | name: 'Sorbet', 114 | price: 799, 115 | image: 116 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/RaspberrySherbet.jpg/1024px-RaspberrySherbet.jpg', 117 | description: 118 | 'Sorbet, also called "Italian ice" or "water ice"[1] is a frozen dessert made from sugar-sweetened water with flavoring – typically fruit juice, fruit purée, wine, liqueur or honey. Generally sorbets do not contain dairy ingredients, while sherbets do.', 119 | }, 120 | { 121 | name: 'Fried Ice Cream', 122 | price: 1055, 123 | image: 124 | 'https://upload.wikimedia.org/wikipedia/commons/3/38/FriedIceCream.jpg', 125 | description: 126 | 'Fried ice cream is a dessert made of a scoop of ice cream that is frozen hard, breaded or coated in a batter, and quickly deep-fried, creating a warm, crispy shell around the still-cold ice cream.', 127 | }, 128 | { 129 | name: 'Semifreddo', 130 | price: 999, 131 | image: 132 | 'https://upload.wikimedia.org/wikipedia/commons/c/c3/Semifreddo_dessert.jpg', 133 | description: 134 | "Semifreddo (pronounced [ˌsemiˈfreddo], Italian: half cold) is a class of frozen desserts. The main ingredients are egg yolks, sugar, and cream. It has the texture of frozen mousse. Such a dessert's Spanish counterpart is called semifrío.[1][2] It was created around the 19th century. However, it did not gain popularity until the early 20th century.[3]", 135 | }, 136 | ], 137 | }, 138 | }, 139 | { 140 | name: 'Pies', 141 | products: { 142 | create: [ 143 | { 144 | name: 'Cream Pie', 145 | price: 4500, 146 | image: 147 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/84/Coconut_cream_pie.jpg/1280px-Coconut_cream_pie.jpg', 148 | description: 149 | 'A cream pie is a type of pie filled with a rich custard or pudding that is made from milk, cream, sugar, wheat flour, and eggs.[1] It comes in many forms, including vanilla, lemon, lime, peanut butter, banana, coconut, and chocolate.[1] One feature of most cream pies is a whipped cream topping. The custard filling is related to crème patissière, a key component of French cakes and tarts. It is a one-crust pie, where the crust covers the bottoms and sides but not the top.', 150 | }, 151 | { 152 | name: 'Apple Pie', 153 | price: 3899, 154 | image: 155 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Apple_pie.jpg/1280px-Apple_pie.jpg', 156 | description: 157 | 'An apple pie is a pie in which the principal filling ingredient is apple, originated in England. It is often served with whipped cream, ice cream ("apple pie à la mode"), or cheddar cheese.[3] It is generally double-crusted, with pastry both above and below the filling; the upper crust may be solid or latticed (woven of crosswise strips). The bottom crust may be baked separately ("blind") to prevent it from getting soggy.', 158 | }, 159 | { 160 | name: 'Pecan Pie', 161 | price: 1599, 162 | image: 163 | 'https://upload.wikimedia.org/wikipedia/commons/b/be/Pecan_pie%2C_November_2010.jpg', 164 | description: 165 | 'Pecan pie is a pie of pecan nuts mixed with a filling of eggs, butter, and sugar (typically corn syrup).[1] Variations may include white or brown sugar, cane syrup, sugar syrup, molasses, maple syrup, or honey.[1] It is popularly served at holiday meals in the United States and is considered a specialty of Southern U.S. origin.[2][3] Most pecan pie recipes include salt and vanilla as flavorings. Chocolate and bourbon whiskey are other popular additions to the recipe.[4]', 166 | }, 167 | { 168 | name: 'Lemon Pie', 169 | price: 1855, 170 | image: 171 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/34/Theres_always_room_for_pie_%287859650026%29.jpg/1280px-Theres_always_room_for_pie_%287859650026%29.jpg', 172 | description: 173 | 'Lemon meringue pie is a type of dessert pie, consisting of a shortened pastry base filled with lemon curd and topped with meringue.', 174 | }, 175 | { 176 | name: 'Sweet Potato Pie', 177 | price: 2299, 178 | image: 179 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/49/SweetPotatoPie.jpg/1280px-SweetPotatoPie.jpg', 180 | description: 181 | 'Sweet potato pie (also:"sweet potato casserole") is a traditional dessert, originating in the Southern United States. It is often served during the American holiday season, especially at Thanksgiving and Christmas in place of pumpkin pie, which is more traditional in other regions of the United States. It is made in an open pie shell without a top crust. The filling consists of mashed sweet potatoes, evaporated milk, sugar, spices such as nutmeg, and eggs.', 182 | }, 183 | ], 184 | }, 185 | }, 186 | { 187 | name: 'Puddings', 188 | products: { 189 | create: [ 190 | { 191 | name: 'Mousse', 192 | price: 2099, 193 | image: 194 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/cb/Chocolate_coffee_mousse.jpg/1024px-Chocolate_coffee_mousse.jpg', 195 | description: 196 | 'A mousse (/ˈmuːs/; French: [mus]; "foam") is a soft prepared food that incorporates air bubbles to give it a light and airy texture. It can range from light and fluffy to creamy and thick, depending on preparation techniques. A mousse may be sweet or savory.[1] Sweet mousses are typically made with whipped egg whites, whipped cream,[2] or both, and flavored with one or more of chocolate, coffee, caramel,[3] puréed fruits, or various herbs and spices, such as mint or vanilla.[4]', 197 | }, 198 | { 199 | name: 'Gelatin', 200 | price: 4700, 201 | image: 202 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Rainbow-Jello-Cut-2004-Jul-30.jpg/1280px-Rainbow-Jello-Cut-2004-Jul-30.jpg', 203 | description: 204 | 'Gelatin desserts are desserts made with a sweetened and flavored processed collagen product (gelatin). This kind of dessert was first recorded as jelly by Hannah Glasse in her 18th century book The Art of Cookery, appearing in a layer of trifle. Jelly is also featured in the best selling cookbooks of English food writers Eliza Acton and Isabella Beeton in the 19th century. They can be made by combining plain gelatin with other ingredients or by using a premixed blend of gelatin with additives.', 205 | }, 206 | { 207 | name: 'Rice Pudding', 208 | price: 3550, 209 | image: 210 | 'https://upload.wikimedia.org/wikipedia/commons/1/19/Risalamande.jpg', 211 | description: 212 | 'Rice pudding is a dish made from rice mixed with water or milk and other ingredients such as cinnamon, vanilla and raisins. Variants are used for either desserts or dinners. When used as a dessert, it is commonly combined with a sweetener such as sugar. Such desserts are found on many continents, especially Asia where rice is a staple. Some variants are thickened only with the rice starch; others include eggs, making them a kind of custard.[1]', 213 | }, 214 | { 215 | name: 'Blancmange', 216 | price: 899, 217 | image: 218 | 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/Blanc-manger_on_glass_platter.jpg/1280px-Blanc-manger_on_glass_platter.jpg', 219 | description: 220 | 'Blancmange (/bləˈmɒ̃ʒ/, from French: blanc-manger is a sweet dessert commonly made with milk or cream and sugar thickened with rice flour, gelatin, corn starch or Irish moss[1] (a source of carrageenan), and often flavoured with almonds. It is usually set in a mould and served cold. Although traditionally white (hence the name, in English literally "white eating"), blancmanges are frequently given alternative colours.', 221 | }, 222 | { 223 | name: 'Sticky Toffee Pudding', 224 | price: 1595, 225 | image: 226 | 'https://upload.wikimedia.org/wikipedia/commons/7/7e/StickyToffeePudding_%28cropped%29.jpg', 227 | description: 228 | 'Sticky toffee pudding, also known as STP[1] or as sticky date pudding in Australia and New Zealand, is a British/English dessert consisting of a very moist sponge cake, made with finely chopped dates, covered in a toffee sauce and often served with a vanilla custard or vanilla ice-cream.[2] It is considered a British classic by various culinary experts,[3][4] alongside bread and butter pudding, jam roly-poly and spotted dick puddings.', 229 | }, 230 | ], 231 | }, 232 | }, 233 | ]; 234 | 235 | const seed = async () => { 236 | const inserts = categories.map(category => 237 | prisma.category.create({ 238 | data: category, 239 | }), 240 | ); 241 | 242 | await Promise.all(inserts); 243 | }; 244 | 245 | seed() 246 | .catch(e => { 247 | console.error(e); 248 | process.exit(1); 249 | }) 250 | .finally(async () => { 251 | await prisma.$disconnect(); 252 | }); 253 | -------------------------------------------------------------------------------- /server/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReactNativeSchool/react-native-ecommerce-app/45514174c6a624ccc3c7f17eea8a99fe8514a5b3/server/public/favicon.ico -------------------------------------------------------------------------------- /server/public/vercel.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /server/styles/Home.module.css: -------------------------------------------------------------------------------- 1 | .container { 2 | min-height: 100vh; 3 | padding: 0 0.5rem; 4 | display: flex; 5 | flex-direction: column; 6 | justify-content: center; 7 | align-items: center; 8 | height: 100vh; 9 | } 10 | 11 | .main { 12 | padding: 5rem 0; 13 | flex: 1; 14 | display: flex; 15 | flex-direction: column; 16 | justify-content: center; 17 | align-items: center; 18 | } 19 | 20 | .footer { 21 | width: 100%; 22 | height: 100px; 23 | border-top: 1px solid #eaeaea; 24 | display: flex; 25 | justify-content: center; 26 | align-items: center; 27 | } 28 | 29 | .footer a { 30 | display: flex; 31 | justify-content: center; 32 | align-items: center; 33 | flex-grow: 1; 34 | } 35 | 36 | .title a { 37 | color: #0070f3; 38 | text-decoration: none; 39 | } 40 | 41 | .title a:hover, 42 | .title a:focus, 43 | .title a:active { 44 | text-decoration: underline; 45 | } 46 | 47 | .title { 48 | margin: 0; 49 | line-height: 1.15; 50 | font-size: 4rem; 51 | } 52 | 53 | .title, 54 | .description { 55 | text-align: center; 56 | } 57 | 58 | .description { 59 | line-height: 1.5; 60 | font-size: 1.5rem; 61 | } 62 | 63 | .code { 64 | background: #fafafa; 65 | border-radius: 5px; 66 | padding: 0.75rem; 67 | font-size: 1.1rem; 68 | font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, 69 | Bitstream Vera Sans Mono, Courier New, monospace; 70 | } 71 | 72 | .grid { 73 | display: flex; 74 | align-items: center; 75 | justify-content: center; 76 | flex-wrap: wrap; 77 | max-width: 800px; 78 | margin-top: 3rem; 79 | } 80 | 81 | .card { 82 | margin: 1rem; 83 | padding: 1.5rem; 84 | text-align: left; 85 | color: inherit; 86 | text-decoration: none; 87 | border: 1px solid #eaeaea; 88 | border-radius: 10px; 89 | transition: color 0.15s ease, border-color 0.15s ease; 90 | width: 45%; 91 | } 92 | 93 | .card:hover, 94 | .card:focus, 95 | .card:active { 96 | color: #0070f3; 97 | border-color: #0070f3; 98 | } 99 | 100 | .card h2 { 101 | margin: 0 0 1rem 0; 102 | font-size: 1.5rem; 103 | } 104 | 105 | .card p { 106 | margin: 0; 107 | font-size: 1.25rem; 108 | line-height: 1.5; 109 | } 110 | 111 | .logo { 112 | height: 1em; 113 | margin-left: 0.5rem; 114 | } 115 | 116 | @media (max-width: 600px) { 117 | .grid { 118 | width: 100%; 119 | flex-direction: column; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /server/styles/globals.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | padding: 0; 4 | margin: 0; 5 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 6 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 7 | } 8 | 9 | a { 10 | color: inherit; 11 | text-decoration: none; 12 | } 13 | 14 | * { 15 | box-sizing: border-box; 16 | } 17 | -------------------------------------------------------------------------------- /server/util/auth.js: -------------------------------------------------------------------------------- 1 | import bcrypt from 'bcryptjs'; 2 | import jwt from 'jsonwebtoken'; 3 | 4 | import prisma from './prisma'; 5 | 6 | export const hashPassword = async password => { 7 | const salt = await bcrypt.genSalt(10); 8 | const hash = await bcrypt.hash(password, salt); 9 | return hash; 10 | }; 11 | 12 | export const generateJWT = async userId => { 13 | const token = await jwt.sign({ id: userId }, process.env.JWT_SECRET); 14 | 15 | return token; 16 | }; 17 | 18 | export const comparePassword = async (password, userPassword) => { 19 | return bcrypt.compare(password, userPassword); 20 | }; 21 | 22 | export const decodeJWT = async (authHeader = '') => { 23 | const [, token] = authHeader.split('Bearer '); 24 | const decoded = await jwt.verify(token, process.env.JWT_SECRET); 25 | 26 | return decoded; 27 | }; 28 | 29 | export const getUserFromHeader = async req => { 30 | try { 31 | const decoded = await decodeJWT(req?.headers?.authorization); 32 | 33 | if (decoded && decoded.id) { 34 | const user = await prisma.user.findFirst({ 35 | where: { 36 | id: decoded.id, 37 | }, 38 | }); 39 | 40 | return user; 41 | } 42 | 43 | return null; 44 | } catch { 45 | return null; 46 | } 47 | }; 48 | -------------------------------------------------------------------------------- /server/util/prisma.js: -------------------------------------------------------------------------------- 1 | // https://www.prisma.io/docs/support/help-articles/nextjs-prisma-client-dev-practices 2 | 3 | import { PrismaClient } from '@prisma/client'; 4 | 5 | // eslint-disable-next-line 6 | let prisma; 7 | 8 | if (process.env.NODE_ENV === 'production') { 9 | prisma = new PrismaClient(); 10 | } else { 11 | if (!global.prisma) { 12 | global.prisma = new PrismaClient(); 13 | } 14 | prisma = global.prisma; 15 | } 16 | 17 | export default prisma; 18 | --------------------------------------------------------------------------------