Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
VUEJS: Component to update a users communication preference

I just need some help identifying what I am missing here. Just can't seem to send the correct data through:

Parent with the CommunicationPreference component:

        <CommunicationPreference
          v-for="(communication, index) in communicationPreference"
          :key="index"
          :consent="communication.consent"
          :name="communication.name"
          @update="updateConsent(consent)"
        />

METHOD

  methods: {
    async updateConsent(consent) {
      await this.$store.dispatch('account/updateCommunicationPreferences', { consent })
    },
  },

CommunicationPrefernce.vue

      <Button
        class="mr-4"
        :text="YES"
        :type="consent === true ? 'primary' : 'secondary'"
        @clicked="updateConsent(true)"
      />
      <Button
        :text="NO"
        :type="consent !== true ? 'primary' : 'secondary'"
        @clicked="updateConsent(false)"
      />

PROPS:

  props: {
    type: {
      type: String,
      default: '',
    },
    name: {
      type: String,
      default: '',
    },
    consent: {
      type: Boolean,
      default: true,
    },
  },

METHOD:

updateConsent(consent) {
  this.$emit('update', consent)
},

STORE:

async updateCommunicationPreferences({ commit, state }, payload) {
        const { consent } = payload
        const { communicationTypeName } = state.communicationTypeName
    
        try {
          const response = await this.$axios.put(`/communication-consent/${communicationTypeName}`, consent)
          const { data: updatedCommunicationPreferences } = response.data
    
          commit('SET_UPDATED_COMMUNICATION_PREFERENCES', updatedCommunicationPreferences)
        } catch (error) {
          commit('ADD_ERROR', { id: 'updateCommunicationPreferences', error }, { root: true })
        }
      },

Attached is the UI I am working towards for reference. the idea is each time the user selects either YES or NO the selection is updated and reflected on the UI

enter image description here

Here is my Swagger doc:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I assume that you have a mapped getter for communicationPreference prop, so that this is correct. I also assume that your @clicked event prop is proper provided the implementation of Button.vue.

So try to change @update="updateConsent(consent)" to @update="updateConsent"

Right now it seems to me that you are making a small mistake between a function call and declaration. Having it such as @update="updateConsent" will trigger updateConsent method, and the function declaration:

async updateConsent(consent) {
  await this.$store.dispatch('account/updateCommunicationPreferences', { consent })
},

will take care of getting the consent you pass in your event trigger.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda