Você não pode selecionar mais de 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.
 
 

244 linhas
4.5 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 PayTransactionUnpaid(token = "") {
  51. var res = await apollo.query(
  52. `
  53. query {
  54. transaction(where: { status: "1" }){
  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 getTransactionPrepared(token = "") {
  75. var res = await apollo.query(
  76. `
  77. query {
  78. transactions(where: { status: "2" }){
  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 getTransactionSending(token = "") {
  99. var res = await apollo.query(
  100. `
  101. query {
  102. transactions(where: { status: "3" }){
  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 getTransactionFinished(token = "") {
  123. var res = await apollo.query(
  124. `
  125. query {
  126. transactions(where: { status: "4" }){
  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. token
  143. );
  144. return res;
  145. }
  146. async function newTransactionYamaha(content, token="") {
  147. var res = await apollo.mutation(
  148. `
  149. mutation($input : TransactionInput!){
  150. createTransaction( input:{data:$input} )
  151. {
  152. transaction{
  153. id
  154. }
  155. }
  156. }
  157. `,
  158. token,
  159. {
  160. input: content,
  161. }
  162. );
  163. return res;
  164. }
  165. async function newTransactionSuzuki(content, token="") {
  166. var res = await apollo.mutation(
  167. `
  168. mutation($input : TransactionInput!){
  169. createTransaction( input:{data:$input} )
  170. {
  171. transactionSuzuki{
  172. id
  173. }
  174. }
  175. }
  176. `,
  177. token,
  178. {
  179. input: content,
  180. }
  181. );
  182. return res;
  183. }
  184. async function newTransactionHonda(content, token="") {
  185. var res = await apollo.mutation(
  186. `
  187. mutation($input : TransactionInput!){
  188. createTransaction( input:{data:$input} )
  189. {
  190. transactionHonda{
  191. id
  192. }
  193. }
  194. }
  195. `,
  196. token,
  197. {
  198. input: content,
  199. }
  200. );
  201. return res;
  202. }
  203. async function newTransactionHino(content, token="") {
  204. var res = await apollo.mutation(
  205. `
  206. mutation($input : TransactionInput!){
  207. createTransaction( input:{data:$input} )
  208. {
  209. transactionHino{
  210. id
  211. }
  212. }
  213. }
  214. `,
  215. token,
  216. {
  217. input: content,
  218. }
  219. );
  220. return res;
  221. }
  222. module.exports = {
  223. newTransactionYamaha: newTransactionYamaha,
  224. newTransactionSuzuki: newTransactionSuzuki,
  225. newTransactionHonda: newTransactionHonda,
  226. newTransactionHino: newTransactionHino,
  227. getTransaction: getTransaction,
  228. getTransactionUnpaid: getTransactionUnpaid,
  229. PayTransactionUnpaid: PayTransactionUnpaid,
  230. getTransactionPrepared: getTransactionPrepared,
  231. getTransactionSending: getTransactionSending,
  232. getTransactionFinished: getTransactionFinished,
  233. };