databaseQueries.constants.ts 2.86 KB
Newer Older
1
import type { DocumentNode } from "@apollo/client/core";
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
import { gql } from "@apollo/client/core";

export const QUESTIONNAIRE_EPDS = gql`
  query QuestionsReponses {
    questionnaireEpds(sort: "ordre") {
      ordre
      libelle
      reponse_1_libelle
      reponse_1_points
      reponse_2_libelle
      reponse_2_points
      reponse_3_libelle
      reponse_3_points
      reponse_4_libelle
      reponse_4_points
    }
  }
`;
20 21

export const EPDS_ADD_RESPONSE = gql`
22 23 24 25
  mutation (
    $genre: ENUM_REPONSESEPDS_GENRE!
    $compteur: Int!
    $score: Int!
26 27 28 29 30 31 32 33 34 35
    $reponseNum1: Int!
    $reponseNum2: Int!
    $reponseNum3: Int!
    $reponseNum4: Int!
    $reponseNum5: Int!
    $reponseNum6: Int!
    $reponseNum7: Int!
    $reponseNum8: Int!
    $reponseNum9: Int!
    $reponseNum10: Int!
36
  ) {
37
    createReponsesEpd(
38 39 40 41 42
      input: {
        data: {
          genre: $genre
          compteur: $compteur
          score: $score
43 44 45 46 47 48 49 50 51 52
          reponse_1: $reponseNum1
          reponse_2: $reponseNum2
          reponse_3: $reponseNum3
          reponse_4: $reponseNum4
          reponse_5: $reponseNum5
          reponse_6: $reponseNum6
          reponse_7: $reponseNum7
          reponse_8: $reponseNum8
          reponse_9: $reponseNum9
          reponse_10: $reponseNum10
53 54
        }
      }
55 56
    ) {
      reponsesEpd {
57
        id
58 59 60 61 62
        created_at
      }
    }
  }
`;
63

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
export const EPDS_CONTACT_INFORMATION = gql`
  mutation (
    $email: String!
    $telephone: String
    $prenom: String!
    $nombreEnfants: Int!
    $naissanceDernierEnfant: String!
  ) {
    epdsContact(
      email: $email
      telephone: $telephone
      prenom: $prenom
      nombre_enfants: $nombreEnfants
      naissance_dernier_enfant: $naissanceDernierEnfant
    )
  }
`;
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131

export const GET_EVENT_ARTICLES = (
  whereCondition: string,
  limit: number
): DocumentNode => {
  return gql`
  query GetArticles($etapeIds: [ID], $thematiqueId: ID) {
    articles(
      sort: "ordre"
      where: { ${whereCondition} }
      limit: ${limit}
    ) {
      id
      titre
      resume
      visuel {
        url
        height
        width
      }
      thematiques {
        nom
        id
      }
    }
  }
`;
};

export const GET_EVENT_DETAILS = (eventId: string): DocumentNode => {
  return gql`
    query GetEventDetails {
      evenement(id: ${eventId})
      {
        id
        nom
        description
        debut
        fin
        thematique {
          id
          nom
        }
        etapes {
          id
          nom
        }
      }
    }
  `;
};
132 133 134 135 136 137 138 139 140

export const CARTO_SEND_SUGGESTIONS = gql`
  mutation (
    $nouveauxPois: String
    $suggestionsAmeliorations: String
    $nombreEnfants: Int!
    $codePostal: String!
  ) {
    cartographieSuggestions(
141 142
      nouveaux_pois: $nouveauxPois
      suggestions_ameliorations: $suggestionsAmeliorations
143 144 145 146 147
      nombre_enfants: $nombreEnfants
      code_postal: $codePostal
    )
  }
`;