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.
 
 

465 line
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 = 10);
  92. /******/ })
  93. /************************************************************************/
  94. /******/ ({
  95. /***/ 10:
  96. /***/ (function(module, exports, __webpack_require__) {
  97. module.exports = __webpack_require__("HEtx");
  98. /***/ }),
  99. /***/ "2bMH":
  100. /***/ (function(module, exports, __webpack_require__) {
  101. "use strict";
  102. var _apollo = _interopRequireDefault(__webpack_require__("B/3u"));
  103. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  104. async function getTransaction(token = "") {
  105. var res = await _apollo.default.query(`
  106. query {
  107. transactions{
  108. id
  109. order_id
  110. cust_name
  111. cust_telp
  112. cust_address
  113. product_img{
  114. url
  115. }
  116. product_name
  117. product_color
  118. product_quantity
  119. product_courier
  120. product_price
  121. }
  122. }`, token);
  123. return res;
  124. }
  125. async function getTransactionUnpaid(token = "") {
  126. var res = await _apollo.default.query(`
  127. query {
  128. transactions(where: { status: "1" }){
  129. id
  130. order_id
  131. cust_name
  132. cust_telp
  133. cust_address
  134. product_img{
  135. url
  136. }
  137. product_name
  138. product_color
  139. product_quantity
  140. product_courier
  141. product_price
  142. }
  143. }`, token);
  144. return res;
  145. }
  146. async function PayTransactionUnpaid(token = "") {
  147. var res = await _apollo.default.query(`
  148. query{
  149. transactions(where: { status: "1" }){
  150. id
  151. order_id
  152. cust_name
  153. cust_telp
  154. cust_address
  155. product_img{
  156. url
  157. }
  158. product_name
  159. product_color
  160. product_quantity
  161. product_courier
  162. product_price
  163. }
  164. }
  165. `, token);
  166. return res;
  167. }
  168. async function getTransactionPrepared(token = "") {
  169. var res = await _apollo.default.query(`
  170. query {
  171. transactions(where: { status: "2" }){
  172. id
  173. order_id
  174. cust_name
  175. cust_telp
  176. cust_address
  177. product_img{
  178. url
  179. }
  180. product_name
  181. product_color
  182. product_quantity
  183. product_courier
  184. product_price
  185. }
  186. }`, token);
  187. return res;
  188. }
  189. async function getTransactionSending(token = "") {
  190. var res = await _apollo.default.query(`
  191. query {
  192. transactions(where: { status: "3" }){
  193. id
  194. order_id
  195. cust_name
  196. cust_telp
  197. cust_address
  198. product_img{
  199. url
  200. }
  201. product_name
  202. product_color
  203. product_quantity
  204. product_courier
  205. product_price
  206. }
  207. }`, token);
  208. return res;
  209. }
  210. async function getTransactionFinished(token = "") {
  211. var res = await _apollo.default.query(`
  212. query {
  213. transactions(where: { status: "4" }){
  214. id
  215. order_id
  216. cust_name
  217. cust_telp
  218. cust_address
  219. product_img{
  220. url
  221. }
  222. product_name
  223. product_color
  224. product_quantity
  225. product_courier
  226. product_price
  227. }
  228. }`, token);
  229. return res;
  230. }
  231. async function newTransactionYamaha(content, token = "") {
  232. var res = await _apollo.default.mutation(`
  233. mutation($input : TransactionInput!){
  234. createTransaction( input:{data:$input} )
  235. {
  236. transaction{
  237. id
  238. }
  239. }
  240. }
  241. `, token, {
  242. input: content
  243. });
  244. return res;
  245. }
  246. async function newTransactionSuzuki(content, token = "") {
  247. var res = await _apollo.default.mutation(`
  248. mutation($input : TransactionInput!){
  249. createTransaction( input:{data:$input} )
  250. {
  251. transactionSuzuki{
  252. id
  253. }
  254. }
  255. }
  256. `, token, {
  257. input: content
  258. });
  259. return res;
  260. }
  261. async function newTransactionHonda(content, token = "") {
  262. var res = await _apollo.default.mutation(`
  263. mutation($input : TransactionInput!){
  264. createTransaction( input:{data:$input} )
  265. {
  266. transactionHonda{
  267. id
  268. }
  269. }
  270. }
  271. `, token, {
  272. input: content
  273. });
  274. return res;
  275. }
  276. async function newTransactionHino(content, token = "") {
  277. var res = await _apollo.default.mutation(`
  278. mutation($input : TransactionInput!){
  279. createTransaction( input:{data:$input} )
  280. {
  281. transactionHino{
  282. id
  283. }
  284. }
  285. }
  286. `, token, {
  287. input: content
  288. });
  289. return res;
  290. }
  291. module.exports = {
  292. newTransactionYamaha: newTransactionYamaha,
  293. newTransactionSuzuki: newTransactionSuzuki,
  294. newTransactionHonda: newTransactionHonda,
  295. newTransactionHino: newTransactionHino,
  296. getTransaction: getTransaction,
  297. getTransactionUnpaid: getTransactionUnpaid,
  298. PayTransactionUnpaid: PayTransactionUnpaid,
  299. getTransactionPrepared: getTransactionPrepared,
  300. getTransactionSending: getTransactionSending,
  301. getTransactionFinished: getTransactionFinished
  302. };
  303. /***/ }),
  304. /***/ "B/3u":
  305. /***/ (function(module, exports, __webpack_require__) {
  306. "use strict";
  307. var _client = __webpack_require__("z+8S");
  308. var _apolloConfig = _interopRequireDefault(__webpack_require__("bx/+"));
  309. var _crossFetch = _interopRequireDefault(__webpack_require__("CCqr"));
  310. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  311. function errorHandler(object) {
  312. 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";
  313. }
  314. function initApollo(token) {
  315. const httpLink = (0, _client.createHttpLink)({
  316. uri: _apolloConfig.default.graphql_uri,
  317. fetch: _crossFetch.default,
  318. headers: token != "" ? {
  319. Authorization: `Bearer ${token}`
  320. } : null
  321. });
  322. return new _client.ApolloClient({
  323. ssrMode: false,
  324. cache: new _client.InMemoryCache({
  325. addTypename: false
  326. }),
  327. link: httpLink
  328. });
  329. }
  330. async function query(query, token = "", variables = {}, cache = false) {
  331. const client = initApollo(token);
  332. var res;
  333. try {
  334. var sql = await client.query({
  335. query: (0, _client.gql)`
  336. ${query}
  337. `,
  338. variables: variables,
  339. fetchPolicy: cache ? "cache-first" : "no-cache"
  340. });
  341. res = {
  342. STATUS: 1,
  343. DATA: sql.data
  344. };
  345. } catch (e) {
  346. res = {
  347. STATUS: 0,
  348. DATA: errorHandler(e)
  349. };
  350. }
  351. return res;
  352. }
  353. async function mutation(mutation, token = "", variables = {}) {
  354. const client = initApollo(token);
  355. var res;
  356. try {
  357. var sql = await client.mutate({
  358. mutation: (0, _client.gql)`
  359. ${mutation}
  360. `,
  361. variables: variables
  362. });
  363. res = {
  364. STATUS: 1,
  365. DATA: sql.data
  366. };
  367. } catch (e) {
  368. console.log(e.networkError.result);
  369. res = {
  370. STATUS: 0,
  371. DATA: errorHandler(e)
  372. };
  373. }
  374. return res;
  375. }
  376. module.exports = {
  377. query: query,
  378. mutation: mutation
  379. };
  380. /***/ }),
  381. /***/ "CCqr":
  382. /***/ (function(module, exports) {
  383. module.exports = require("cross-fetch");
  384. /***/ }),
  385. /***/ "HEtx":
  386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  387. "use strict";
  388. __webpack_require__.r(__webpack_exports__);
  389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return handler; });
  390. /* harmony import */ var api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("2bMH");
  391. /* harmony import */ var api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0__);
  392. async function handler(req, resp) {
  393. var input = req.body;
  394. var res = await api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0___default.a.newTransactionSuzuki(input);
  395. console.log(input);
  396. resp.status(200).json(res);
  397. }
  398. /***/ }),
  399. /***/ "bx/+":
  400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  401. "use strict";
  402. __webpack_require__.r(__webpack_exports__);
  403. // Apollo Value Configuration
  404. const ApolloConfig = {
  405. graphql_uri: process.env.API_GRAPHQL_URI
  406. };
  407. /* harmony default export */ __webpack_exports__["default"] = (ApolloConfig);
  408. /***/ }),
  409. /***/ "z+8S":
  410. /***/ (function(module, exports) {
  411. module.exports = require("@apollo/client");
  412. /***/ })
  413. /******/ });