25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

465 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 = 8);
  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. transactions(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. }
  161. `, token);
  162. return res;
  163. }
  164. async function getTransactionPrepared(token = "") {
  165. var res = await _apollo.default.query(`
  166. query {
  167. transactions(where: { status: "2" }){
  168. id
  169. order_id
  170. cust_name
  171. cust_telp
  172. cust_address
  173. product_img{
  174. url
  175. }
  176. product_name
  177. product_color
  178. product_quantity
  179. product_courier
  180. product_price
  181. }
  182. }`, token);
  183. return res;
  184. }
  185. async function getTransactionSending(token = "") {
  186. var res = await _apollo.default.query(`
  187. query {
  188. transactions(where: { status: "3" }){
  189. id
  190. order_id
  191. cust_name
  192. cust_telp
  193. cust_address
  194. product_img{
  195. url
  196. }
  197. product_name
  198. product_color
  199. product_quantity
  200. product_courier
  201. product_price
  202. }
  203. }`, token);
  204. return res;
  205. }
  206. async function getTransactionFinished(token = "") {
  207. var res = await _apollo.default.query(`
  208. query {
  209. transactions(where: { status: "4" }){
  210. id
  211. order_id
  212. cust_name
  213. cust_telp
  214. cust_address
  215. product_img{
  216. url
  217. }
  218. product_name
  219. product_color
  220. product_quantity
  221. product_courier
  222. product_price
  223. }
  224. }`, token);
  225. return res;
  226. }
  227. async function newTransactionYamaha(content, token = "") {
  228. var res = await _apollo.default.mutation(`
  229. mutation($input : TransactionInput!){
  230. createTransaction( input:{data:$input} )
  231. {
  232. transaction{
  233. id
  234. }
  235. }
  236. }
  237. `, token, {
  238. input: content
  239. });
  240. return res;
  241. }
  242. async function newTransactionSuzuki(content, token = "") {
  243. var res = await _apollo.default.mutation(`
  244. mutation($input : TransactionInput!){
  245. createTransaction( input:{data:$input} )
  246. {
  247. transactionSuzuki{
  248. id
  249. }
  250. }
  251. }
  252. `, token, {
  253. input: content
  254. });
  255. return res;
  256. }
  257. async function newTransactionHonda(content, token = "") {
  258. var res = await _apollo.default.mutation(`
  259. mutation($input : TransactionInput!){
  260. createTransaction( input:{data:$input} )
  261. {
  262. transactionHonda{
  263. id
  264. }
  265. }
  266. }
  267. `, token, {
  268. input: content
  269. });
  270. return res;
  271. }
  272. async function newTransactionHino(content, token = "") {
  273. var res = await _apollo.default.mutation(`
  274. mutation($input : TransactionInput!){
  275. createTransaction( input:{data:$input} )
  276. {
  277. transactionHino{
  278. id
  279. }
  280. }
  281. }
  282. `, token, {
  283. input: content
  284. });
  285. return res;
  286. }
  287. module.exports = {
  288. newTransactionYamaha: newTransactionYamaha,
  289. newTransactionSuzuki: newTransactionSuzuki,
  290. newTransactionHonda: newTransactionHonda,
  291. newTransactionHino: newTransactionHino,
  292. getTransaction: getTransaction,
  293. getTransactionUnpaid: getTransactionUnpaid,
  294. PayTransactionUnpaid: PayTransactionUnpaid,
  295. getTransactionPrepared: getTransactionPrepared,
  296. getTransactionSending: getTransactionSending,
  297. getTransactionFinished: getTransactionFinished
  298. };
  299. /***/ }),
  300. /***/ 8:
  301. /***/ (function(module, exports, __webpack_require__) {
  302. module.exports = __webpack_require__("gMn8");
  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. /***/ "bx/+":
  386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  387. "use strict";
  388. __webpack_require__.r(__webpack_exports__);
  389. // Apollo Value Configuration
  390. const ApolloConfig = {
  391. graphql_uri: process.env.API_GRAPHQL_URI
  392. };
  393. /* harmony default export */ __webpack_exports__["default"] = (ApolloConfig);
  394. /***/ }),
  395. /***/ "gMn8":
  396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  397. "use strict";
  398. __webpack_require__.r(__webpack_exports__);
  399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return handler; });
  400. /* harmony import */ var api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("2bMH");
  401. /* harmony import */ var api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0__);
  402. async function handler(req, resp) {
  403. var input = req.body;
  404. var res = await api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0___default.a.newTransactionHonda(input);
  405. console.log(input);
  406. resp.status(200).json(res);
  407. }
  408. /***/ }),
  409. /***/ "z+8S":
  410. /***/ (function(module, exports) {
  411. module.exports = require("@apollo/client");
  412. /***/ })
  413. /******/ });