Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

337 lignes
7.4 KiB

  1. import apollo from "../../../lib/apollo";
  2. async function allCompanies(){
  3. var res = await apollo.query(
  4. `
  5. query($input: String!){
  6. companies{
  7. data{
  8. attributes{
  9. Ready
  10. Business_name
  11. Name
  12. Description
  13. Icon {
  14. data {
  15. attributes{
  16. url
  17. }
  18. }
  19. }
  20. Background{
  21. data{
  22. attributes{
  23. url
  24. }
  25. }
  26. }
  27. Website
  28. }
  29. }
  30. }
  31. social:companies(filters:{Name:{eq:$input}}){
  32. data{
  33. attributes{
  34. Social_Medias{
  35. data{
  36. attributes{
  37. Type
  38. Link
  39. }
  40. }
  41. }
  42. }
  43. }
  44. }
  45. dealers:companies(filters:{Name:{eq:$input}}){
  46. data{
  47. attributes{
  48. Dealers{
  49. data{
  50. attributes{
  51. Image{
  52. data{
  53. attributes{
  54. url
  55. }
  56. }
  57. }
  58. Name
  59. Kota
  60. Address
  61. Gmap
  62. Telp
  63. Region{
  64. data{
  65. attributes{
  66. Name
  67. }
  68. }
  69. }
  70. Email
  71. }
  72. }
  73. }
  74. }
  75. }
  76. }
  77. main_banner:companies(filters:{Name:{eq:$input}}){
  78. data{
  79. id
  80. attributes{
  81. Contents(filters :{Type:{eq:"Main_Banner"}}){
  82. data{
  83. attributes{
  84. Title
  85. Description
  86. Image{
  87. data{
  88. attributes{
  89. url
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. news:companies(filters:{Name:{eq:$input}}){
  100. data{
  101. id
  102. attributes{
  103. Contents(filters:{Type:{eq:"News"}}){
  104. data{
  105. id
  106. attributes{
  107. Title
  108. Description
  109. Image{
  110. data{
  111. attributes{
  112. url
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. gallery:companies(filters:{Name:{eq:$input}}){
  123. data{
  124. attributes{
  125. Gallery{
  126. data{
  127. attributes{
  128. url
  129. }
  130. }
  131. }
  132. }
  133. }
  134. }
  135. }`,"",{
  136. "input":"Thamrin"
  137. }
  138. );
  139. return res;
  140. }
  141. async function companyIcon(input){
  142. var res = await apollo.query(
  143. `
  144. query($input: ID!){
  145. company(id:$input){
  146. data{
  147. attributes{
  148. Icon {
  149. data {
  150. attributes{
  151. url
  152. }
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }`,"",{
  159. "input":input
  160. }
  161. );
  162. return res;
  163. }
  164. async function companyByName(input){
  165. var res = await apollo.query(
  166. `
  167. query($input: String!){
  168. Main_Banner:companies(filters:{Name:{containsi:$input}}){
  169. data{
  170. id
  171. attributes{
  172. Contents(filters :{Type:{eq:"Main_Banner"}}){
  173. data{
  174. attributes{
  175. Title
  176. Description
  177. Image{
  178. data{
  179. attributes{
  180. url
  181. }
  182. }
  183. }
  184. Link
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. companies(filters:{Name:{eq:$input}}){
  192. data{
  193. id
  194. attributes{
  195. Business_name
  196. Name
  197. Description
  198. Visi
  199. Misi
  200. Address
  201. Email
  202. Phone
  203. Icon {
  204. data {
  205. attributes{
  206. url
  207. }
  208. }
  209. }
  210. Banner{
  211. data{
  212. id
  213. attributes{
  214. url
  215. }
  216. }
  217. }
  218. Dealers{
  219. data{
  220. attributes{
  221. Image{
  222. data{
  223. attributes{
  224. url
  225. }
  226. }
  227. }
  228. Name
  229. Kota
  230. Address
  231. Gmap
  232. Telp
  233. Region{
  234. data{
  235. attributes{
  236. Name
  237. }
  238. }
  239. }
  240. Email
  241. }
  242. }
  243. }
  244. Featured:Products(filters:{Featured:{eq:true}}){
  245. data{
  246. attributes{
  247. Image{
  248. data{
  249. attributes{
  250. url
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }
  257. Background{
  258. data{
  259. attributes{
  260. url
  261. }
  262. }
  263. }
  264. Gallery{
  265. data{
  266. attributes{
  267. url
  268. }
  269. }
  270. }
  271. Social_Medias{
  272. data{
  273. attributes{
  274. Type
  275. Link
  276. }
  277. }
  278. }
  279. }
  280. }
  281. }
  282. }`,"",{
  283. "input":input
  284. }
  285. );
  286. return res;
  287. }
  288. async function getID(partner, token = "") {
  289. var res = await apollo.query(
  290. `
  291. query($input : String!){
  292. businessPartners(where:{name_contains:$input}){
  293. id
  294. }
  295. }`,
  296. token,
  297. {
  298. input: partner,
  299. }
  300. );
  301. return res;
  302. }
  303. // async function getData(partner,token=''){
  304. // var res = await apollo.query(
  305. // `
  306. // query($input : String!){
  307. // businessPartners(where:{name_contains:$input}){
  308. // id,
  309. // name,
  310. // icon{
  311. // url
  312. // },
  313. // background{
  314. // url
  315. // },
  316. // carousel{
  317. // url
  318. // }
  319. // }
  320. // }
  321. // `
  322. // );
  323. // }
  324. module.exports = {
  325. getID: getID,
  326. companyByName:companyByName,
  327. companies:allCompanies,
  328. companyIcon:companyIcon,
  329. };