您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

450 行
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 = 4);
  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 getTransactionPrepared(token = "") {
  143. var res = await _apollo.default.query(`
  144. query {
  145. transactions(where: { status: "2" }){
  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 getTransactionSending(token = "") {
  164. var res = await _apollo.default.query(`
  165. query {
  166. transactions(where: { status: "3" }){
  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 getTransactionFinished(token = "") {
  185. var res = await _apollo.default.query(`
  186. query {
  187. transactions(where: { status: "4" }){
  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 newTransactionYamaha(content, token = "") {
  206. var res = await _apollo.default.mutation(`
  207. mutation($input : TransactionInput!){
  208. createTransaction( input:{data:$input} )
  209. {
  210. transaction{
  211. id
  212. }
  213. }
  214. }
  215. `, token, {
  216. input: content
  217. });
  218. return res;
  219. }
  220. async function newTransactionSuzuki(content, token = "") {
  221. var res = await _apollo.default.mutation(`
  222. mutation($input : TransactionInput!){
  223. createTransaction( input:{data:$input} )
  224. {
  225. transactionSuzuki{
  226. id
  227. }
  228. }
  229. }
  230. `, token, {
  231. input: content
  232. });
  233. return res;
  234. }
  235. async function newTransactionHonda(content, token = "") {
  236. var res = await _apollo.default.mutation(`
  237. mutation($input : TransactionInput!){
  238. createTransaction( input:{data:$input} )
  239. {
  240. transactionHonda{
  241. id
  242. }
  243. }
  244. }
  245. `, token, {
  246. input: content
  247. });
  248. return res;
  249. }
  250. async function newTransactionHino(content, token = "") {
  251. var res = await _apollo.default.mutation(`
  252. mutation($input : TransactionInput!){
  253. createTransaction( input:{data:$input} )
  254. {
  255. transactionHino{
  256. id
  257. }
  258. }
  259. }
  260. `, token, {
  261. input: content
  262. });
  263. return res;
  264. }
  265. module.exports = {
  266. newTransactionYamaha: newTransactionYamaha,
  267. newTransactionSuzuki: newTransactionSuzuki,
  268. newTransactionHonda: newTransactionHonda,
  269. newTransactionHino: newTransactionHino,
  270. getTransaction: getTransaction,
  271. getTransactionUnpaid: getTransactionUnpaid,
  272. getTransactionPrepared: getTransactionPrepared,
  273. getTransactionSending: getTransactionSending,
  274. getTransactionFinished: getTransactionFinished
  275. };
  276. /***/ }),
  277. /***/ 4:
  278. /***/ (function(module, exports, __webpack_require__) {
  279. module.exports = __webpack_require__("wmLm");
  280. /***/ }),
  281. /***/ "B/3u":
  282. /***/ (function(module, exports, __webpack_require__) {
  283. "use strict";
  284. var _client = __webpack_require__("z+8S");
  285. var _apolloConfig = _interopRequireDefault(__webpack_require__("bx/+"));
  286. var _crossFetch = _interopRequireDefault(__webpack_require__("CCqr"));
  287. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  288. function errorHandler(object) {
  289. 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";
  290. }
  291. function initApollo(token) {
  292. const httpLink = (0, _client.createHttpLink)({
  293. uri: _apolloConfig.default.graphql_uri,
  294. fetch: _crossFetch.default,
  295. headers: token != "" ? {
  296. Authorization: `Bearer ${token}`
  297. } : null
  298. });
  299. return new _client.ApolloClient({
  300. ssrMode: false,
  301. cache: new _client.InMemoryCache({
  302. addTypename: false
  303. }),
  304. link: httpLink
  305. });
  306. }
  307. async function query(query, token = "", variables = {}, cache = false) {
  308. const client = initApollo(token);
  309. var res;
  310. try {
  311. var sql = await client.query({
  312. query: (0, _client.gql)`
  313. ${query}
  314. `,
  315. variables: variables,
  316. fetchPolicy: cache ? "cache-first" : "no-cache"
  317. });
  318. res = {
  319. STATUS: 1,
  320. DATA: sql.data
  321. };
  322. } catch (e) {
  323. res = {
  324. STATUS: 0,
  325. DATA: errorHandler(e)
  326. };
  327. }
  328. return res;
  329. }
  330. async function mutation(mutation, token = "", variables = {}) {
  331. const client = initApollo(token);
  332. var res;
  333. try {
  334. var sql = await client.mutate({
  335. mutation: (0, _client.gql)`
  336. ${mutation}
  337. `,
  338. variables: variables
  339. });
  340. res = {
  341. STATUS: 1,
  342. DATA: sql.data
  343. };
  344. } catch (e) {
  345. console.log(e);
  346. res = {
  347. STATUS: 0,
  348. DATA: errorHandler(e)
  349. };
  350. }
  351. return res;
  352. }
  353. module.exports = {
  354. query: query,
  355. mutation: mutation
  356. };
  357. /***/ }),
  358. /***/ "CCqr":
  359. /***/ (function(module, exports) {
  360. module.exports = require("cross-fetch");
  361. /***/ }),
  362. /***/ "bx/+":
  363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  364. "use strict";
  365. __webpack_require__.r(__webpack_exports__);
  366. // Apollo Value Configuration
  367. const ApolloConfig = {
  368. graphql_uri: process.env.API_GRAPHQL_URI
  369. };
  370. /* harmony default export */ __webpack_exports__["default"] = (ApolloConfig);
  371. /***/ }),
  372. /***/ "wmLm":
  373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  374. "use strict";
  375. __webpack_require__.r(__webpack_exports__);
  376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return handler; });
  377. /* harmony import */ var api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("2bMH");
  378. /* harmony import */ var api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0__);
  379. async function handler(req, resp) {
  380. var input = req.body;
  381. var res = await api_transaction_transaction__WEBPACK_IMPORTED_MODULE_0___default.a.newTransactionYamaha(input.formValue);
  382. console.log(input);
  383. resp.status(200).json(res);
  384. } // import Transaction from "api/transaction/transaction";
  385. // async function handler(req, resp) {
  386. // var input = req.body;
  387. // var res = await Transaction.newTransaction(input.formValue);
  388. // console.log(input);
  389. // resp.status(200).json(res);
  390. // }
  391. // module.exports = {
  392. // handler: handler,
  393. // };
  394. /***/ }),
  395. /***/ "z+8S":
  396. /***/ (function(module, exports) {
  397. module.exports = require("@apollo/client");
  398. /***/ })
  399. /******/ });