|
- import apollo from "../../../lib/apollo";
-
-
- async function allCompanies(){
- var res = await apollo.query(
- `
- query($input: String!){
- companies{
- data{
- attributes{
- Ready
- Business_name
- Name
- Description
- Icon {
- data {
- attributes{
- url
- }
- }
- }
- Background{
- data{
- attributes{
- url
- }
- }
- }
- Website
- }
- }
- }
- social:companies(filters:{Name:{eq:$input}}){
- data{
- attributes{
- Social_Medias{
- data{
- attributes{
- Type
- Link
- }
- }
- }
- }
- }
- }
- dealers:companies(filters:{Name:{eq:$input}}){
- data{
- attributes{
- Dealers{
- data{
- attributes{
- Image{
- data{
- attributes{
- url
- }
- }
- }
- Name
- Kota
- Address
- Gmap
- Telp
- Region{
- data{
- attributes{
- Name
- }
- }
- }
- Email
- }
- }
- }
- }
- }
- }
- main_banner:companies(filters:{Name:{eq:$input}}){
- data{
- id
- attributes{
- Contents(filters :{Type:{eq:"Main_Banner"}}){
- data{
- attributes{
- Title
- Description
- Image{
- data{
- attributes{
- url
- }
- }
- }
- }
- }
- }
- }
- }
- }
- news:companies(filters:{Name:{eq:$input}}){
- data{
- id
- attributes{
- Contents(filters:{Type:{eq:"News"}}){
- data{
- id
- attributes{
- Title
- Description
- Image{
- data{
- attributes{
- url
- }
- }
- }
- }
- }
- }
- }
- }
- }
- gallery:companies(filters:{Name:{eq:$input}}){
- data{
- attributes{
- Gallery{
- data{
- attributes{
- url
- }
- }
- }
- }
- }
- }
- }`,"",{
- "input":"Thamrin"
- }
- );
- return res;
- }
-
- async function companyIcon(input){
- var res = await apollo.query(
- `
- query($input: ID!){
- company(id:$input){
- data{
- attributes{
- Icon {
- data {
- attributes{
- url
- }
- }
- }
- }
- }
- }
- }`,"",{
- "input":input
- }
- );
- return res;
- }
-
- async function companyByName(input){
- var res = await apollo.query(
- `
- query($input: String!){
- Main_Banner:companies(filters:{Name:{containsi:$input}}){
- data{
- id
- attributes{
- Contents(filters :{Type:{eq:"Main_Banner"}}){
- data{
- attributes{
- Title
- Description
- Image{
- data{
- attributes{
- url
- }
- }
- }
- Link
- }
- }
- }
- }
- }
- }
- companies(filters:{Name:{eq:$input}}){
- data{
- id
- attributes{
- Business_name
- Name
- Description
- Visi
- Misi
- Address
- Email
- Phone
- Icon {
- data {
- attributes{
- url
- }
- }
- }
- Banner{
- data{
- id
- attributes{
- url
- }
- }
- }
- Dealers{
- data{
- attributes{
- Image{
- data{
- attributes{
- url
- }
- }
- }
- Name
- Kota
- Address
- Gmap
- Telp
- Region{
- data{
- attributes{
- Name
- }
- }
- }
- Email
- }
- }
- }
- Featured:Products(filters:{Featured:{eq:true}}){
- data{
- attributes{
- Image{
- data{
- attributes{
- url
- }
- }
- }
- }
- }
- }
- Background{
- data{
- attributes{
- url
- }
- }
- }
- Gallery{
- data{
- attributes{
- url
- }
- }
- }
- Social_Medias{
- data{
- attributes{
- Type
- Link
- }
- }
- }
- }
- }
- }
- }`,"",{
- "input":input
- }
- );
- return res;
- }
-
- async function getID(partner, token = "") {
- var res = await apollo.query(
- `
- query($input : String!){
- businessPartners(where:{name_contains:$input}){
- id
- }
- }`,
- token,
- {
- input: partner,
- }
- );
- return res;
- }
-
- // async function getData(partner,token=''){
- // var res = await apollo.query(
- // `
- // query($input : String!){
- // businessPartners(where:{name_contains:$input}){
- // id,
- // name,
- // icon{
- // url
- // },
- // background{
- // url
- // },
- // carousel{
- // url
- // }
- // }
- // }
- // `
- // );
- // }
-
- module.exports = {
- getID: getID,
- companyByName:companyByName,
- companies:allCompanies,
- companyIcon:companyIcon,
- };
|