Skip to content

Commit

Permalink
feat: whatsapp products catalogs base
Browse files Browse the repository at this point in the history
  • Loading branch information
sthefanisilveira committed Sep 29, 2023
1 parent 8032c96 commit cdf4ee9
Show file tree
Hide file tree
Showing 12 changed files with 458 additions and 21 deletions.
9 changes: 9 additions & 0 deletions src/api/appType/whatsapp_cloud/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import qs from 'query-string';
import request from '@/api/request.js';

const resource = '/api/v1/apptypes/wpp-cloud/apps';
const catalogsResource = '/api/v1/apptypes/wpp-cloud';

export default {
getDebugToken(params) {
const queryString = qs.stringify(params);
Expand All @@ -14,4 +16,11 @@ export default {
configurePhoneNumber(data) {
return request.$http.post(`${resource}/`, data);
},
getWhatsAppCloudCatalogs(appUuid, params) {
const queryString = qs.stringify(params);
return request.$http.get(`${catalogsResource}/${appUuid}/catalogs/?${queryString}`);
},
fetchCatalogData(appUuid, catalogUuid) {
return request.$http.get(`${catalogsResource}/${appUuid}/catalogs/${catalogUuid}/`);
},
};
3 changes: 2 additions & 1 deletion src/components/config/channels/whatsapp/Setup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@
},
{
return_scopes: true,
scope: 'business_management,whatsapp_business_management,whatsapp_business_messaging',
scope:
'business_management,whatsapp_business_management,whatsapp_business_messaging,catalog_management',
extras: {
feature: 'whatsapp_embedded_signup',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,35 @@
<div class="account-tab__content">
<div class="account-tab__content__info">
<div class="account-tab__content__info__templates">
<div class="account-tab__content__info__templates__title">
{{ $t('WhatsApp.config.templates.title') }}
<div class="account-tab__content__info__templates__buttons">
<div class="account-tab__content__info__templates__buttons__title">
{{ $t('WhatsApp.config.templates.title') }}
</div>

<unnnic-button-next
class="account-tab__content__info__templates__buttons__button"
@click="navigateToTemplates"
type="secondary"
size="small"
scheme="feedback-green"
>
{{ $t('WhatsApp.config.templates.button') }}
</unnnic-button-next>
</div>
<div class="account-tab__content__info__templates__buttons">
<div class="account-tab__content__info__templates__buttons__title">
{{ $t('WhatsApp.config.catalog.title') }}
</div>

<unnnic-button
class="account-tab__content__info__templates__button"
@click="navigateToTemplates"
type="secondary"
size="small"
>
{{ $t('WhatsApp.config.templates.button') }}
</unnnic-button>
<unnnic-button-next
class="account-tab__content__info__templates__buttons__button"
@click="navigateToCatalogs"
type="primary"
size="small"
>
{{ $t('WhatsApp.config.catalog.button') }}
</unnnic-button-next>
</div>
</div>

<div class="account-tab__content__info__qr">
Expand Down Expand Up @@ -93,6 +110,10 @@
const { code, uuid } = this.appInfo;
this.$router.push({ path: `/apps/my/${code}/${uuid}/templates` });
},
navigateToCatalogs() {
const { code, uuid } = this.appInfo;
this.$router.push({ path: `/apps/my/${code}/${uuid}/catalogs` });
},
},
computed: {
QRCodeUrl() {
Expand Down Expand Up @@ -222,20 +243,23 @@
gap: $unnnic-spacing-stack-lg;
&__templates {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
gap: $unnnic-spacing-stack-sm;
&__title {
font-weight: $unnnic-font-weight-black;
font-size: $unnnic-font-size-body-lg;
line-height: $unnnic-font-size-body-lg + $unnnic-line-height-md;
color: $unnnic-color-neutral-darkest;
}
&__buttons {
width: 100%;
&__button {
max-width: 160px;
&__title {
font-weight: $unnnic-font-weight-bold;
font-size: $unnnic-font-size-body-lg;
line-height: $unnnic-font-size-body-lg + $unnnic-line-height-md;
color: $unnnic-color-neutral-darkest;
margin-bottom: $unnnic-spacing-sm;
}
&__button {
width: 100%;
}
}
}
Expand Down
166 changes: 166 additions & 0 deletions src/components/whatsAppCatalogs/Card.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<template>
<div
class="whatsapp-catalog-card"
v-if="!loadingWhatsAppCloudCatalogs && !errorWhatsAppCloudCatalogs"
>
<div v-for="(item, index) in listItems" :key="index" class="whatsapp-catalog-card__wrapper">
<div class="whatsapp-catalog-card__wrapper__header">
<div class="whatsapp-catalog-card__wrapper__header__title">
<span class="u font secondary body-lg color-neutral-darkest bold">
{{ item.name }}
</span>
</div>
<div class="whatsapp-catalog-card__wrapper__header__description">
<span class="u font secondary body-md color-neutral-cloudy">
{{ $t('WhatsApp.catalog.list.identification') }}
</span>
<span class="u font secondary body-md color-brand-weni bold">
{{ item.facebook_catalog_id }}
</span>
</div>
</div>

<div class="whatsapp-catalog-card__wrapper__actions">
<unnnic-switch
:value="item.is_connected"
size="small"
:textRight="
item.is_connected
? $t('WhatsApp.catalog.list.actions.enabled_catalog')
: $t('WhatsApp.catalog.list.actions.disabled_catalog')
"
@click.native="modalDisableCatalog()"
/>
<unnnic-switch
v-if="item.is_connected"
:inititalState="false"
size="small"
:textRight="
item.is_connected
? $t('WhatsApp.catalog.list.actions.enabled_cart')
: $t('WhatsApp.catalog.list.actions.disabled_cart')
"
/>
</div>
</div>

<unnnic-modal-next
v-if="openModal"
type="alert"
icon="alert-circle-1"
scheme="feedback-red"
:validate="$t('WhatsApp.catalog.list.disable_modal.placeholder')"
:validatePlaceholder="$t('WhatsApp.catalog.list.disable_modal.placeholder')"
:validateLabel="$t('WhatsApp.catalog.list.disable_modal.label')"
:title="$t('WhatsApp.catalog.list.disable_modal.title')"
:actionPrimaryLabel="$t('WhatsApp.catalog.list.disable_modal.confirm')"
:actionSecondaryLabel="$t('general.Cancel')"
@click-action-secondary="openModal = false"
@click-action-primary="disableCatalog"
>
<template slot="description">
{{ $t('WhatsApp.catalog.list.disable_modal.description') }}
</template>
</unnnic-modal-next>
</div>
</template>

<script>
import { mapActions, mapState } from 'vuex';
/* import debounce from 'lodash.debounce';
import { unnnicCallAlert } from '@weni/unnnic-system'; */
export default {
name: 'Card',
data() {
return {
openModal: false,
listCatalog: [
{
uuid: '3081a268-fff5-4366-bf44-ee387c8ddcdc',
name: 'Teste_localizacao',
facebook_catalog_id: '312538484461506',
category: 'commerce',
is_connected: false,
},
{
uuid: 'eaf96431-9be8-4cbd-8541-f4ae08af0d1e',
name: 'catalogo marketing token',
facebook_catalog_id: '339959911815729',
category: 'commerce',
is_connected: true,
},
{
uuid: 'e7974bfa-14d8-470a-8b1b-669718bc1036',
name: 'catalogo criado em dev',
facebook_catalog_id: '664025605666699',
category: 'commerce',
is_connected: false,
},
],
};
},
/* created() {
this.fetchData();
}, */
computed: {
...mapState('WhatsAppCloud', [
'loadingWhatsAppCloudCatalogs',
'errorWhatsAppCloudCatalogs',
'whatsAppCloudCatalogs',
]),
listItems() {
return this.whatsAppCloudCatalogs?.results || [];
},
},
methods: {
...mapActions('WhatsAppCloud', ['getWhatsAppCloudCatalogs']),
/* fetchData: debounce(async function () {
const { appUuid } = this.$route.params;
await this.getWhatsAppCloudCatalogs({ appUuid });
if (this.errorWhatsAppCloudCatalog) {
unnnicCallAlert({
props: {
text: this.$t('WhatsApp.templates.error.fetch_templates'),
title: this.$t('general.error'),
icon: 'alert-circle-1-1',
scheme: 'feedback-red',
position: 'bottom-right',
closeText: this.$t('general.Close'),
},
seconds: 8,
});
}
}, 750), */
modalDisableCatalog() {
this.openModal = true;
},
},
};
</script>
<style lang="scss" scoped>
.whatsapp-catalog-card {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
gap: $unnnic-spacing-md;
&__wrapper {
display: flex;
justify-content: space-between;
align-items: center;
border: $unnnic-border-width-thinner solid $unnnic-color-neutral-soft;
border-radius: $unnnic-border-radius-md;
padding: $unnnic-spacing-md;
&__actions {
display: flex;
gap: $unnnic-spacing-xs;
}
}
}
</style>
62 changes: 62 additions & 0 deletions src/components/whatsAppCatalogs/Table.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<div class="whatsapp-catalog-table">
<div class="whatsapp-catalog-table__header">
<div class="whatsapp-catalog-table__header__title">
<unnnic-card
class="whatsapp-catalog-table__header__title__text"
type="title"
:title="$t('WhatsApp.catalog.list.title')"
:hasInformationIcon="false"
icon="house-1-1"
scheme="brand-weni-soft"
/>
<span class="u font secondary body-gt color-neutral-darkest">
{{ $t('WhatsApp.catalog.list.description') }}
</span>
</div>
<div class="whatsapp-catalog-table__header__button">
<unnnic-button-next type="terciary" size="large">
{{ $t('WhatsApp.catalog.list.advanced_settings') }}
</unnnic-button-next>
</div>
</div>
<Card />
</div>
</template>

<script>
import Card from '@/components/whatsAppCatalogs/Card';
export default {
name: 'Table',
components: {
Card,
},
};
</script>

<style lang="scss" scoped>
.whatsapp-catalog-table {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
margin-top: $unnnic-spacing-lg;
&__header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: $unnnic-spacing-md;
&__title {
display: flex;
flex-direction: column;
&__text {
margin-bottom: $unnnic-spacing-xs;
}
}
}
}
</style>
31 changes: 31 additions & 0 deletions src/locales/pt_br.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,37 @@
"templates": {
"button": "Ver meus templates",
"title": "Templates"
},
"catalog": {
"button": "Ver lista de catálogos",
"title": "Catálogo"
}
},
"catalog": {
"list": {
"title": "Lista de catálogos",
"description": "Adicione todos os itens que você quer anunciar ou vender",
"advanced_settings": "Configurações avançadas",
"identification": "Identificação",
"actions": {
"enabled_cart": "Carrinho habilitado",
"disabled_cart": "Carrinho desabilitado",
"enabled_catalog": "Catálogo habilitado",
"disabled_catalog": "Desabilitado"
},
"disable_modal": {
"title": "Vai mesmo desabilitar o catálogo?",
"description": "Para continuar enviando seus produtos no Whatsapp você precisa de um catálogo ativo.",
"label": "Digite “desabilitar catálogo” para confirmar",
"placeholder": "desabilitar catálogo",
"confirm": "Desabilitar"
},
"advanced_configurations_modal": {
"title": "Configurações avançadas",
"description": "Configure o nível de precisão do envio automático dos seus produtos",
"recomendation": "Configuração recomendada: 1.55",
"confirm": "Salvar"
}
}
},
"templates": {
Expand Down
Loading

0 comments on commit cdf4ee9

Please sign in to comment.