Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

245 linhas
4.6 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 newTransactionYamaha(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. async function newTransactionSuzuki(content, token="") {
  167. var res = await apollo.mutation(
  168. `
  169. mutation($input : TransactionInput!){
  170. createTransaction( input:{data:$input} )
  171. {
  172. transaction{
  173. id
  174. }
  175. }
  176. }
  177. `,
  178. token,
  179. {
  180. input: content,
  181. }
  182. );
  183. return res;
  184. }
  185. async function newTransactionHonda(content, token="") {
  186. var res = await apollo.mutation(
  187. `
  188. mutation($input : TransactionInput!){
  189. createTransaction( input:{data:$input} )
  190. {
  191. transaction{
  192. id
  193. }
  194. }
  195. }
  196. `,
  197. token,
  198. {
  199. input: content,
  200. }
  201. );
  202. return res;
  203. }
  204. async function newTransactionHino(content, token="") {
  205. var res = await apollo.mutation(
  206. `
  207. mutation($input : TransactionInput!){
  208. createTransaction( input:{data:$input} )
  209. {
  210. transaction{
  211. id
  212. }
  213. }
  214. }
  215. `,
  216. token,
  217. {
  218. input: content,
  219. }
  220. );
  221. return res;
  222. }
  223. module.exports = {
  224. newTransactionYamaha: newTransactionYamaha,
  225. newTransactionSuzuki: newTransactionSuzuki,
  226. newTransactionHonda: newTransactionHonda,
  227. newTransactionHino: newTransactionHino,
  228. getTransaction:getTransaction,
  229. getTransactionUnpaid:getTransactionUnpaid,
  230. getTransactionPrepared:getTransactionPrepared,
  231. getTransactionSending:getTransactionSending,
  232. getTransactionFinished:getTransactionFinished,
  233. GetCheckoutTransaction:GetCheckoutTransaction,
  234. };