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.
 
 

155 rivejä
2.8 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 newTransaction(content, token="") {
  123. var res = await apollo.mutation(
  124. `
  125. mutation($input : TransactionInput!){
  126. createTransaction( input:{data:$input} )
  127. {
  128. transaction{
  129. id
  130. }
  131. }
  132. }
  133. `,
  134. token,
  135. {
  136. input: content,
  137. }
  138. );
  139. return res;
  140. }
  141. module.exports = {
  142. newTransaction: newTransaction,
  143. getTransaction:getTransaction,
  144. getTransactionUnpaid:getTransactionUnpaid,
  145. getTransactionPrepared:getTransactionPrepared,
  146. getTransactionSending:getTransactionSending,
  147. getTransactionFinished:getTransactionFinished,
  148. };