You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

464 lines
12 KiB

  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = require('../../../../../ssr-module-cache.js');
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ var threw = true;
  22. /******/ try {
  23. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  24. /******/ threw = false;
  25. /******/ } finally {
  26. /******/ if(threw) delete installedModules[moduleId];
  27. /******/ }
  28. /******/
  29. /******/ // Flag the module as loaded
  30. /******/ module.l = true;
  31. /******/
  32. /******/ // Return the exports of the module
  33. /******/ return module.exports;
  34. /******/ }
  35. /******/
  36. /******/
  37. /******/ // expose the modules object (__webpack_modules__)
  38. /******/ __webpack_require__.m = modules;
  39. /******/
  40. /******/ // expose the module cache
  41. /******/ __webpack_require__.c = installedModules;
  42. /******/
  43. /******/ // define getter function for harmony exports
  44. /******/ __webpack_require__.d = function(exports, name, getter) {
  45. /******/ if(!__webpack_require__.o(exports, name)) {
  46. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  47. /******/ }
  48. /******/ };
  49. /******/
  50. /******/ // define __esModule on exports
  51. /******/ __webpack_require__.r = function(exports) {
  52. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  53. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  54. /******/ }
  55. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  56. /******/ };
  57. /******/
  58. /******/ // create a fake namespace object
  59. /******/ // mode & 1: value is a module id, require it
  60. /******/ // mode & 2: merge all properties of value into the ns
  61. /******/ // mode & 4: return value when already ns object
  62. /******/ // mode & 8|1: behave like require
  63. /******/ __webpack_require__.t = function(value, mode) {
  64. /******/ if(mode & 1) value = __webpack_require__(value);
  65. /******/ if(mode & 8) return value;
  66. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  67. /******/ var ns = Object.create(null);
  68. /******/ __webpack_require__.r(ns);
  69. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  70. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  71. /******/ return ns;
  72. /******/ };
  73. /******/
  74. /******/ // getDefaultExport function for compatibility with non-harmony modules
  75. /******/ __webpack_require__.n = function(module) {
  76. /******/ var getter = module && module.__esModule ?
  77. /******/ function getDefault() { return module['default']; } :
  78. /******/ function getModuleExports() { return module; };
  79. /******/ __webpack_require__.d(getter, 'a', getter);
  80. /******/ return getter;
  81. /******/ };
  82. /******/
  83. /******/ // Object.prototype.hasOwnProperty.call
  84. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  85. /******/
  86. /******/ // __webpack_public_path__
  87. /******/ __webpack_require__.p = "";
  88. /******/
  89. /******/
  90. /******/ // Load entry module and return exports
  91. /******/ return __webpack_require__(__webpack_require__.s = 9);
  92. /******/ })
  93. /************************************************************************/
  94. /******/ ({
  95. /***/ "2bMH":
  96. /***/ (function(module, exports, __webpack_require__) {
  97. "use strict";
  98. var _apollo = _interopRequireDefault(__webpack_require__("B/3u"));
  99. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  100. async function getTransaction(token = "") {
  101. var res = await _apollo.default.query(`
  102. query {
  103. transactions{
  104. id
  105. order_id
  106. cust_name
  107. cust_telp
  108. cust_address
  109. product_img{
  110. url
  111. }
  112. product_name
  113. product_color
  114. product_quantity
  115. product_courier
  116. product_price
  117. }
  118. }`, token);
  119. return res;
  120. }
  121. async function getTransactionUnpaid(token = "") {
  122. var res = await _apollo.default.query(`
  123. query {
  124. transactions(where: { status: "1" }){
  125. id
  126. order_id
  127. cust_name
  128. cust_telp
  129. cust_address
  130. product_img{
  131. url
  132. }
  133. product_name
  134. product_color
  135. product_quantity
  136. product_courier
  137. product_price
  138. }
  139. }`, token);
  140. return res;
  141. }
  142. async function PayTransactionUnpaid(token = "") {
  143. var res = await _apollo.default.query(`
  144. query {
  145. transaction(where: { status: "1" }){
  146. id
  147. order_id
  148. cust_name
  149. cust_telp
  150. cust_address
  151. product_img{
  152. url
  153. }
  154. product_name
  155. product_color
  156. product_quantity
  157. product_courier
  158. product_price
  159. }
  160. }`, token);
  161. return res;
  162. }
  163. async function getTransactionPrepared(token = "") {
  164. var res = await _apollo.default.query(`
  165. query {
  166. transactions(where: { status: "2" }){
  167. id
  168. order_id
  169. cust_name
  170. cust_telp
  171. cust_address
  172. product_img{
  173. url
  174. }
  175. product_name
  176. product_color
  177. product_quantity
  178. product_courier
  179. product_price
  180. }
  181. }`, token);
  182. return res;
  183. }
  184. async function getTransactionSending(token = "") {
  185. var res = await _apollo.default.query(`
  186. query {
  187. transactions(where: { status: "3" }){
  188. id
  189. order_id
  190. cust_name
  191. cust_telp
  192. cust_address
  193. product_img{
  194. url
  195. }
  196. product_name
  197. product_color
  198. product_quantity
  199. product_courier
  200. product_price
  201. }
  202. }`, token);
  203. return res;
  204. }
  205. async function getTransactionFinished(token = "") {
  206. var res = await _apollo.default.query(`
  207. query {
  208. transactions(where: { status: "4" }){
  209. id
  210. order_id
  211. cust_name
  212. cust_telp
  213. cust_address
  214. product_img{
  215. url
  216. }
  217. product_name
  218. product_color
  219. product_quantity
  220. product_courier
  221. product_price
  222. }
  223. }`, token);
  224. return res;
  225. }
  226. async function newTransactionYamaha(content, token = "") {
  227. var res = await _apollo.default.mutation(`
  228. mutation($input : TransactionInput!){
  229. createTransaction( input:{data:$input} )
  230. {
  231. transaction{
  232. id
  233. }
  234. }
  235. }
  236. `, token, {
  237. input: content
  238. });
  239. return res;
  240. }
  241. async function newTransactionSuzuki(content, token = "") {
  242. var res = await _apollo.default.mutation(`
  243. mutation($input : TransactionInput!){
  244. createTransaction( input:{data:$input} )
  245. {
  246. transactionSuzuki{
  247. id
  248. }
  249. }
  250. }
  251. `, token, {
  252. input: content
  253. });
  254. return res;
  255. }
  256. async function newTransactionHonda(content, token = "") {
  257. var res = await _apollo.default.mutation(`
  258. mutation($input : TransactionInput!){
  259. createTransaction( input:{data:$input} )
  260. {
  261. transactionHonda{
  262. id
  263. }
  264. }
  265. }
  266. `, token, {
  267. input: content
  268. });
  269. return res;
  270. }
  271. async function newTransactionHino(content, token = "") {
  272. var res = await _apollo.default.mutation(`
  273. mutation($input : TransactionInput!){
  274. createTransaction( input:{data:$input} )
  275. {
  276. transactionHino{
  277. id
  278. }
  279. }
  280. }
  281. `, token, {
  282. input: content
  283. });
  284. return res;
  285. }
  286. module.exports = {
  287. newTransactionYamaha: newTransactionYamaha,
  288. newTransactionSuzuki: newTransactionSuzuki,
  289. newTransactionHonda: newTransactionHonda,
  290. newTransactionHino: newTransactionHino,
  291. getTransaction: getTransaction,
  292. getTransactionUnpaid: getTransactionUnpaid,
  293. PayTransactionUnpaid: PayTransactionUnpaid,
  294. getTransactionPrepared: getTransactionPrepared,
  295. getTransactionSending: getTransactionSending,
  296. getTransactionFinished: getTransactionFinished
  297. };
  298. /***/ }),
  299. /***/ 9:
  300. /***/ (function(module, exports, __webpack_require__) {
  301. module.exports = __webpack_require__("HEtx");
  302. /***/ }),
  303. /***/ "B/3u":
  304. /***/ (function(module, exports, __webpack_require__) {
  305. "use strict";
  306. var _client = __webpack_require__("z+8S");
  307. var _apolloConfig = _interopRequireDefault(__webpack_require__("bx/+"));
  308. var _crossFetch = _interopRequireDefault(__webpack_require__("CCqr"));
  309. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  310. function errorHandler(object) {
  311. return object.graphQLErrors.length != 0 ? object.graphQLErrors[0].message : object.networkError && object.networkError.result ? object.networkError.result.errors.join(" ; ") : object.networkError ? object.networkError[Object.keys(object.networkError)[0]].toString() : "Fetch failed";
  312. }
  313. function initApollo(token) {
  314. const httpLink = (0, _client.createHttpLink)({
  315. uri: _apolloConfig.default.graphql_uri,
  316. fetch: _crossFetch.default,
  317. headers: token != "" ? {
  318. Authorization: `Bearer ${token}`
  319. } : null
  320. });
  321. return new _client.ApolloClient({
  322. ssrMode: false,
  323. cache: new _client.InMemoryCache({
  324. addTypename: false
  325. }),
  326. link: httpLink
  327. });
  328. }
  329. async function query(query, token = "", variables = {}, cache = false) {
  330. const client = initApollo(token);
  331. var res;
  332. try {
  333. var sql = await client.query({
  334. query: (0, _client.gql)`
  335. ${query}
  336. `,
  337. variables: variables,
  338. fetchPolicy: cache ? "cache-first" : "no-cache"
  339. });
  340. res = {
  341. STATUS: 1,
  342. DATA: sql.data
  343. };
  344. } catch (e) {
  345. res = {
  346. STATUS: 0,
  347. DATA: errorHandler(e)
  348. };
  349. }
  350. return res;
  351. }
  352. async function mutation(mutation, token = "", variables = {}) {
  353. const client = initApollo(token);
  354. var res;
  355. try {
  356. var sql = await client.mutate({
  357. mutation: (0, _client.gql)`
  358. ${mutation}
  359. `,
  360. variables: variables
  361. });
  362. res = {
  363. STATUS: 1,
  364. DATA: sql.data
  365. };
  366. } catch (e) {
  367. console.log(e.networkError.result);
  368. res = {
  369. STATUS: 0,
  370. DATA: errorHandler(e)
  371. };
  372. }
  373. return res;
  374. }
  375. module.exports = {
  376. query: query,
  377. mutation: mutation
  378. };
  379. /***/ }),
  380. /***/ "CCqr":
  381. /***/ (function(module, exports) {
  382. module.exports = require("cross-fetch");
  383. /***/ }),
  384. /***/ "HEtx":
  385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  386. "use strict";
  387. __webpack_require__.r(__webpack_exports__);
  388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return handler; });
  389. /* harmony import */ var api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("2bMH");
  390. /* harmony import */ var api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0__);
  391. async function handler(req, resp) {
  392. var input = req.body;
  393. var res = await api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0___default.a.newTransactionSuzuki(input);
  394. console.log(input);
  395. resp.status(200).json(res);
  396. }
  397. /***/ }),
  398. /***/ "bx/+":
  399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  400. "use strict";
  401. __webpack_require__.r(__webpack_exports__);
  402. // Apollo Value Configuration
  403. const ApolloConfig = {
  404. graphql_uri: process.env.API_GRAPHQL_URI
  405. };
  406. /* harmony default export */ __webpack_exports__["default"] = (ApolloConfig);
  407. /***/ }),
  408. /***/ "z+8S":
  409. /***/ (function(module, exports) {
  410. module.exports = require("@apollo/client");
  411. /***/ })
  412. /******/ });