From fc6a73df836b2a848d895747563eb67087486e43 Mon Sep 17 00:00:00 2001 From: mistikk Date: Wed, 14 Nov 2018 17:13:22 +0100 Subject: [PATCH 1/3] Created environment variables structure --- .env.example | 1 + .gitignore | 1 + android/app/build.gradle | 2 + .../main/java/com/esteem/MainApplication.java | 2 + android/settings.gradle | 2 + ios/eSteem.xcodeproj/project.pbxproj | 52 +++++++++++++++++++ package-lock.json | 9 +++- package.json | 1 + src/config/api.js | 10 ++++ 9 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 .env.example create mode 100644 src/config/api.js diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..15d6c6b14 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +BACKEND_URL = https://myapi.com \ No newline at end of file diff --git a/.gitignore b/.gitignore index c27484e2d..41d885bf6 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,4 @@ buck-out/ config.js !src/screens/steem-connect/config.js keystore/ +.env \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index 13f9279a4..7cdc72812 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,4 +1,5 @@ apply plugin: "com.android.application" +apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" import com.android.build.OutputFile @@ -137,6 +138,7 @@ android { } dependencies { + compile project(':react-native-config') compile project(':react-native-vector-icons') compile project(':react-native-fast-image') compile project(':realm') diff --git a/android/app/src/main/java/com/esteem/MainApplication.java b/android/app/src/main/java/com/esteem/MainApplication.java index 44b9c4d3e..d7a9ca872 100644 --- a/android/app/src/main/java/com/esteem/MainApplication.java +++ b/android/app/src/main/java/com/esteem/MainApplication.java @@ -3,6 +3,7 @@ package com.esteem; import android.app.Application; import com.facebook.react.ReactApplication; +import com.lugg.ReactNativeConfig.ReactNativeConfigPackage; import com.oblador.vectoricons.VectorIconsPackage; import com.dylanvann.fastimage.FastImageViewPackage; import io.realm.react.RealmReactPackage; @@ -28,6 +29,7 @@ public class MainApplication extends Application implements ReactApplication { protected List getPackages() { return Arrays.asList( new MainReactPackage(), + new ReactNativeConfigPackage(), new VectorIconsPackage(), new FastImageViewPackage(), new RealmReactPackage(), diff --git a/android/settings.gradle b/android/settings.gradle index 38b8fc8c9..a8fcaee34 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,6 @@ rootProject.name = 'esteem' +include ':react-native-config' +project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android') include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') include ':react-native-fast-image' diff --git a/ios/eSteem.xcodeproj/project.pbxproj b/ios/eSteem.xcodeproj/project.pbxproj index f9e4db117..d47dbf86e 100644 --- a/ios/eSteem.xcodeproj/project.pbxproj +++ b/ios/eSteem.xcodeproj/project.pbxproj @@ -45,6 +45,7 @@ 3D18392E6B3D4AAAB054A206 /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CDA19DB138184C9BB67FFA73 /* EvilIcons.ttf */; }; 4314A99BA5C94BCD9E527873 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D4E083B771D4AF2AF62E4D2 /* libz.tbd */; }; 548C6A754DAD401A8235DF14 /* Sansation_Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 224245E1366F46F98214C9B8 /* Sansation_Regular.ttf */; }; + 562E0C9042E0460E986E5415 /* libReactNativeConfig.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B9E70136F0D4FD8A55F8031 /* libReactNativeConfig.a */; }; 6C00FDC7B4B54ACBABA6F462 /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 388EA3B93FD64F479AA9977E /* Ionicons.ttf */; }; 7918030CDF7C4D2A98040422 /* Sansation_Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E434A344B09D49AD966063AD /* Sansation_Bold.ttf */; }; 7B80523EC6D64C05BF3B069B /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 454696104228474690AC269D /* libc++.tbd */; }; @@ -308,6 +309,13 @@ remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4; remoteInfo = "jschelpers-tvOS"; }; + 583D5B48219C7F2900C5006F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 062A4D4B07614C30BF03D907 /* ReactNativeConfig.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = EB2648DF1C7BE17A00B8F155; + remoteInfo = ReactNativeConfig; + }; 58712346219B601100354CBE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = AAAB371C708C493896DF647D /* RCTRestart.xcodeproj */; @@ -404,6 +412,7 @@ 00E356EE1AD99517003FC87E /* esteemTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = esteemTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 00E356F21AD99517003FC87E /* esteemTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = esteemTests.m; sourceTree = ""; }; + 062A4D4B07614C30BF03D907 /* ReactNativeConfig.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = ReactNativeConfig.xcodeproj; path = "../node_modules/react-native-config/ios/ReactNativeConfig.xcodeproj"; sourceTree = ""; }; 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = ""; }; 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; }; 13B07F961A680F5B00A75B9A /* esteem.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = esteem.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -431,6 +440,7 @@ 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; 62AB655DC50F43FEA43A0DB5 /* Roboto.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Roboto.ttf; path = "../node_modules/native-base/Fonts/Roboto.ttf"; sourceTree = ""; }; 66AD4642077143E393F52059 /* MaterialIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialIcons.ttf; path = ../src/assets/Fonts/MaterialIcons.ttf; sourceTree = ""; }; + 6B9E70136F0D4FD8A55F8031 /* libReactNativeConfig.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libReactNativeConfig.a; sourceTree = ""; }; 6E13BF49AA984CC7A97DBF2A /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialCommunityIcons.ttf; path = ../src/assets/Fonts/MaterialCommunityIcons.ttf; sourceTree = ""; }; 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 7BCF48F9914F4B659820D0F8 /* libRCTRestart.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTRestart.a; sourceTree = ""; }; @@ -489,6 +499,7 @@ F2A4ABA54EB8471B90554653 /* libRealmReact.a in Frameworks */, 7B80523EC6D64C05BF3B069B /* libc++.tbd in Frameworks */, 4314A99BA5C94BCD9E527873 /* libz.tbd in Frameworks */, + 562E0C9042E0460E986E5415 /* libReactNativeConfig.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -645,6 +656,14 @@ name = Frameworks; sourceTree = ""; }; + 583D5B45219C7F2800C5006F /* Products */ = { + isa = PBXGroup; + children = ( + 583D5B49219C7F2900C5006F /* libReactNativeConfig.a */, + ); + name = Products; + sourceTree = ""; + }; 5871231D219B600900354CBE /* Recovered References */ = { isa = PBXGroup; children = ( @@ -654,6 +673,7 @@ A3F54D7123BF487B9E36857D /* libRNVectorIcons.a */, 9C88393A6064468CBBC856BA /* libRealmReact.a */, 57A2D4F43661441EB7931F73 /* libRNVectorIcons-tvOS.a */, + 6B9E70136F0D4FD8A55F8031 /* libReactNativeConfig.a */, ); name = "Recovered References"; sourceTree = ""; @@ -738,6 +758,7 @@ AAAB371C708C493896DF647D /* RCTRestart.xcodeproj */, CECE249991544C198CBC7498 /* RNVectorIcons.xcodeproj */, 2E516DDCFE2646AA87414D17 /* RealmReact.xcodeproj */, + 062A4D4B07614C30BF03D907 /* ReactNativeConfig.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -986,6 +1007,10 @@ ProductGroup = 146834001AC3E56700842450 /* Products */; ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; }, + { + ProductGroup = 583D5B45219C7F2800C5006F /* Products */; + ProjectRef = 062A4D4B07614C30BF03D907 /* ReactNativeConfig.xcodeproj */; + }, { ProductGroup = 58712351219B601200354CBE /* Products */; ProjectRef = 2E516DDCFE2646AA87414D17 /* RealmReact.xcodeproj */; @@ -1230,6 +1255,13 @@ remoteRef = 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 583D5B49219C7F2900C5006F /* libReactNativeConfig.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libReactNativeConfig.a; + remoteRef = 583D5B48219C7F2900C5006F /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 58712347219B601100354CBE /* libRCTRestart.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -1480,6 +1512,7 @@ "$(SRCROOT)/../node_modules/react-native-restart/ios/RCTRestart/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", "$(SRCROOT)/../node_modules/realm/src/**", + "$(SRCROOT)/../node_modules/react-native-config/ios/ReactNativeConfig", ); INFOPLIST_FILE = esteemTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; @@ -1492,6 +1525,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1515,6 +1549,7 @@ "$(SRCROOT)/../node_modules/react-native-restart/ios/RCTRestart/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", "$(SRCROOT)/../node_modules/realm/src/**", + "$(SRCROOT)/../node_modules/react-native-config/ios/ReactNativeConfig", ); INFOPLIST_FILE = esteemTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; @@ -1527,6 +1562,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1551,6 +1587,7 @@ "$(SRCROOT)/../node_modules/react-native-restart/ios/RCTRestart/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", "$(SRCROOT)/../node_modules/realm/src/**", + "$(SRCROOT)/../node_modules/react-native-config/ios/ReactNativeConfig", ); INFOPLIST_FILE = esteem/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1577,6 +1614,7 @@ "$(SRCROOT)/../node_modules/react-native-restart/ios/RCTRestart/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", "$(SRCROOT)/../node_modules/realm/src/**", + "$(SRCROOT)/../node_modules/react-native-config/ios/ReactNativeConfig", ); INFOPLIST_FILE = esteem/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1610,6 +1648,7 @@ "$(SRCROOT)/../node_modules/react-native-restart/ios/RCTRestart/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", "$(SRCROOT)/../node_modules/realm/src/**", + "$(SRCROOT)/../node_modules/react-native-config/ios/ReactNativeConfig", ); INFOPLIST_FILE = "esteem-tvOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1621,6 +1660,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1653,6 +1693,7 @@ "$(SRCROOT)/../node_modules/react-native-restart/ios/RCTRestart/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", "$(SRCROOT)/../node_modules/realm/src/**", + "$(SRCROOT)/../node_modules/react-native-config/ios/ReactNativeConfig", ); INFOPLIST_FILE = "esteem-tvOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1664,6 +1705,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1695,6 +1737,7 @@ "$(SRCROOT)/../node_modules/react-native-restart/ios/RCTRestart/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", "$(SRCROOT)/../node_modules/realm/src/**", + "$(SRCROOT)/../node_modules/react-native-config/ios/ReactNativeConfig", ); INFOPLIST_FILE = "esteem-tvOSTests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1706,6 +1749,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1737,6 +1781,7 @@ "$(SRCROOT)/../node_modules/react-native-restart/ios/RCTRestart/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", "$(SRCROOT)/../node_modules/realm/src/**", + "$(SRCROOT)/../node_modules/react-native-config/ios/ReactNativeConfig", ); INFOPLIST_FILE = "esteem-tvOSTests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1748,6 +1793,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1807,6 +1853,9 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional"; + INFOPLIST_PREFIX_HEADER = "${BUILD_DIR}/GeneratedInfoPlistDotEnv.h"; + INFOPLIST_PREPROCESS = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -1853,6 +1902,9 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional"; + INFOPLIST_PREFIX_HEADER = "${BUILD_DIR}/GeneratedInfoPlistDotEnv.h"; + INFOPLIST_PREPROCESS = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; diff --git a/package-lock.json b/package-lock.json index f806ec847..734bcd3f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8240,7 +8240,7 @@ }, "fs-extra": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", "requires": { "graceful-fs": "^4.1.2", @@ -10015,7 +10015,7 @@ }, "fs-extra": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", "requires": { "graceful-fs": "^4.1.2", @@ -10063,6 +10063,11 @@ "prop-types": "^15.5.10" } }, + "react-native-config": { + "version": "0.11.5", + "resolved": "https://registry.npmjs.org/react-native-config/-/react-native-config-0.11.5.tgz", + "integrity": "sha512-u1ScTyJXsCZM8Kt8eVEZZw4vtbWOffwAv1HpMwGRRuerqQC99hTBOhFKGCvxPr6APHqYJO3vQYoad/Cjb5VGWw==" + }, "react-native-dismiss-keyboard": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/react-native-dismiss-keyboard/-/react-native-dismiss-keyboard-1.0.0.tgz", diff --git a/package.json b/package.json index 85463a4d7..a2e079301 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "react": "^16.6.0-alpha.8af6728", "react-intl": "^2.7.2", "react-native": "^0.57.5", + "react-native-config": "^0.11.5", "react-native-extended-stylesheet": "^0.10.0", "react-native-fast-image": "^4.0.14", "react-native-html-renderer": "^1.0.0", diff --git a/src/config/api.js b/src/config/api.js new file mode 100644 index 000000000..005a76246 --- /dev/null +++ b/src/config/api.js @@ -0,0 +1,10 @@ +import axios from 'axios'; + +const api = axios.create({ + baseURL: 'https://us-central1-bubi-7c3f6.cloudfunctions.net/api/', + headers: { + 'Content-Type': 'application/json', + }, +}); + +export default api; From 194479a3926deccc09f916f185be4533d67266e4 Mon Sep 17 00:00:00 2001 From: mistikk Date: Wed, 14 Nov 2018 17:17:53 +0100 Subject: [PATCH 2/3] Changed axios base url with configuration variable --- src/config/api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config/api.js b/src/config/api.js index 005a76246..704e22742 100644 --- a/src/config/api.js +++ b/src/config/api.js @@ -1,7 +1,8 @@ import axios from 'axios'; +import Config from 'react-native-config'; const api = axios.create({ - baseURL: 'https://us-central1-bubi-7c3f6.cloudfunctions.net/api/', + baseURL: Config.BACKEND_URL, headers: { 'Content-Type': 'application/json', }, From f604e2938391793ebba2cc4321a03d3fc490234a Mon Sep 17 00:00:00 2001 From: mistikk Date: Wed, 14 Nov 2018 17:54:37 +0100 Subject: [PATCH 3/3] Added draft api implementation --- src/providers/esteem/esteem.js | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/providers/esteem/esteem.js diff --git a/src/providers/esteem/esteem.js b/src/providers/esteem/esteem.js new file mode 100644 index 000000000..920ddde71 --- /dev/null +++ b/src/providers/esteem/esteem.js @@ -0,0 +1,45 @@ +import api from '../../config/api'; + +export const getDrafts = data => new Promise((resolve, reject) => { + api + .get(`/drafts/${data.user}`) + .then((res) => { + resolve(res.data); + }) + .catch((error) => { + reject(error); + }); +}); + +export const removeDraft = data => new Promise((resolve, reject) => { + api + .delete(`/drafts/${data.user}/${data.draftId}`) + .then((res) => { + resolve(res.data); + }) + .catch((error) => { + reject(error); + }); +}); + +export const addDraft = data => new Promise((resolve, reject) => { + api + .post('/draft', data) + .then((res) => { + resolve(res.data); + }) + .catch((error) => { + reject(error); + }); +}); + +export const updateDraft = data => new Promise((resolve, reject) => { + api + .put(`/drafts/${data.user}/${data.draftId}`, data) + .then((res) => { + resolve(res.data); + }) + .catch((error) => { + reject(error); + }); +});