Skip to content

Commit

Permalink
Merge pull request #333 from weni-ai/feat/whatsapp-products-catalogs
Browse files Browse the repository at this point in the history
feat: whatsapp products catalogs base
  • Loading branch information
sthefanisilveira authored Sep 29, 2023
2 parents 8032c96 + eddd433 commit 01fe5d7
Show file tree
Hide file tree
Showing 14 changed files with 841 additions and 21 deletions.
23 changes: 23 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,25 @@ export default {
configurePhoneNumber(data) {
return request.$http.post(`${resource}/`, data);
},
getWhatsAppCloudCatalogs(appUuid) {
return request.$http.get(`${catalogsResource}/${appUuid}/catalogs/`);
},
fetchCatalogData(appUuid, catalogUuid) {
return request.$http.get(`${catalogsResource}/${appUuid}/catalogs/${catalogUuid}/`);
},
disableWhatsAppCloudCatalogs(appUuid, catalogUuid) {
return request.$http.post(`${catalogsResource}/${appUuid}/catalogs/${catalogUuid}/disable/`);
},
enableWhatsAppCloudCatalogs(appUuid, catalogUuid) {
return request.$http.post(`${catalogsResource}/${appUuid}/catalogs/${catalogUuid}/enable/`);
},
toggleCartVisibility(appUuid, data) {
return request.$http.post(`${catalogsResource}/${appUuid}/toggle-cart-visibility/`, data);
},
toggleCatalogVisibility(appUuid, data) {
return request.$http.post(`${catalogsResource}/${appUuid}/toggle-catalog-visibility/`, data);
},
getCommerceSettings(appUuid) {
return request.$http.get(`${catalogsResource}/${appUuid}/commerce-settings/`);
},
};
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
128 changes: 128 additions & 0 deletions src/components/whatsAppCatalogs/Card.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<template>
<div class="whatsapp-catalog-card">
<div 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">
{{ catalog.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">
{{ catalog.facebook_catalog_id }}
</span>
</div>
</div>

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

<script>
import { mapActions, mapState } from 'vuex';
export default {
name: 'Card',
props: {
catalog: {
type: Object,
required: true,
default: () => {},
},
enabledCart: {
type: Boolean,
default: false,
},
},
data() {
return {
currentDisable: null,
catalogStatus: this.catalog.is_connected,
cartStatus: this.enabledCart,
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,
},
],
};
},
computed: {
...mapState('WhatsAppCloud', ['errorDisableCatalog']),
},
methods: {
...mapActions('WhatsAppCloud', ['disableWhatsAppCloudCatalogs']),
toggleCatalogConnect(event) {
if (event) {
this.$emit('enable');
} else {
this.$emit('disable');
}
},
toggleCart() {
this.$emit('toggleCart');
},
},
};
</script>

<style lang="scss" scoped>
.whatsapp-catalog-card {
&__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>
Loading

0 comments on commit 01fe5d7

Please sign in to comment.