Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 

182 rader
3.4 KiB

  1. import apollo from "../../lib/apollo.js";
  2. async function getTransaction(token = "") {
  3. var res = await apollo.query(
  4. `
  5. query {
  6. transactions{
  7. id
  8. order_id
  9. cust_name
  10. cust_telp
  11. cust_address
  12. product_img{
  13. url
  14. }
  15. product_name
  16. product_color
  17. product_quantity
  18. product_courier
  19. product_price
  20. }
  21. }`,
  22. token
  23. );
  24. return res;
  25. }
  26. async function getTransactionUnpaid(token = "") {
  27. var res = await apollo.query(
  28. `
  29. query {
  30. transactions(where: { status: "1" }){
  31. id
  32. order_id
  33. cust_name
  34. cust_telp
  35. cust_address
  36. product_img{
  37. url
  38. }
  39. product_name
  40. product_color
  41. product_quantity
  42. product_courier
  43. product_price
  44. }
  45. }`,
  46. token
  47. );
  48. return res;
  49. }
  50. async function getTransactionPrepared(token = "") {
  51. var res = await apollo.query(
  52. `
  53. query {
  54. transactions(where: { status: "2" }){
  55. id
  56. order_id
  57. cust_name
  58. cust_telp
  59. cust_address
  60. product_img{
  61. url
  62. }
  63. product_name
  64. product_color
  65. product_quantity
  66. product_courier
  67. product_price
  68. }
  69. }`,
  70. token
  71. );
  72. return res;
  73. }
  74. async function getTransactionSending(token = "") {
  75. var res = await apollo.query(
  76. `
  77. query {
  78. transactions(where: { status: "3" }){
  79. id
  80. order_id
  81. cust_name
  82. cust_telp
  83. cust_address
  84. product_img{
  85. url
  86. }
  87. product_name
  88. product_color
  89. product_quantity
  90. product_courier
  91. product_price
  92. }
  93. }`,
  94. token
  95. );
  96. return res;
  97. }
  98. async function getTransactionFinished(token = "") {
  99. var res = await apollo.query(
  100. `
  101. query {
  102. transactions(where: { status: "4" }){
  103. id
  104. order_id
  105. cust_name
  106. cust_telp
  107. cust_address
  108. product_img{
  109. url
  110. }
  111. product_name
  112. product_color
  113. product_quantity
  114. product_courier
  115. product_price
  116. }
  117. }`,
  118. token
  119. );
  120. return res;
  121. }
  122. async function GetCheckoutTransaction(id, token = "") {
  123. var res = await apollo.query(
  124. `
  125. query{
  126. transaction(where: { status: "1" }){
  127. id
  128. order_id
  129. cust_name
  130. cust_telp
  131. cust_address
  132. product_img{
  133. url
  134. }
  135. product_name
  136. product_color
  137. product_quantity
  138. product_courier
  139. product_price
  140. }
  141. }
  142. `,
  143. token,
  144. );
  145. return res;
  146. }
  147. async function newTransaction(content, token="") {
  148. var res = await apollo.mutation(
  149. `
  150. mutation($input : TransactionInput!){
  151. createTransaction( input:{data:$input} )
  152. {
  153. transaction{
  154. id
  155. }
  156. }
  157. }
  158. `,
  159. token,
  160. {
  161. input: content,
  162. }
  163. );
  164. return res;
  165. }
  166. module.exports = {
  167. newTransaction: newTransaction,
  168. getTransaction:getTransaction,
  169. getTransactionUnpaid:getTransactionUnpaid,
  170. getTransactionPrepared:getTransactionPrepared,
  171. getTransactionSending:getTransactionSending,
  172. getTransactionFinished:getTransactionFinished,
  173. GetCheckoutTransaction:GetCheckoutTransaction,
  174. };