Skip to content

Commit

Permalink
feat: show error campaign audience
Browse files Browse the repository at this point in the history
  • Loading branch information
clairton committed Sep 27, 2024
1 parent 00550c7 commit 4fc2dc1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/accounts/campaigns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Api::V1::Accounts::CampaignsController < Api::V1::Accounts::BaseController
before_action :check_authorization

def index
@campaigns = Current.account.campaigns.limit(50).order(created_at: :desc)
@campaigns = Current.account.campaigns.limit(200).order(created_at: :desc)
end

def show; end
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/dashboard/i18n/locale/en/campaign.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@
"HEADER": "Ongoing campaigns",
"404": "There are no ongoing campaigns created",
"INBOXES_NOT_FOUND": "Please create an website inbox and start adding campaigns"
},
"AUDIENCE": {
"REPORT": "Report",
"ERROR": "Error",
"FAILED": "Failed"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ export default {
},
onPhoneNumberInputChange(value, code) {
this.activeDialCode = code;
if (!code && value) {
this.phoneNumber = value;
}
},
setPhoneCode(code) {
if (this.phoneNumber !== '' && this.parsePhoneNumber) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ export default {
}
return reports;
},
},
campaignListError() {
const audience = this.campaign.audience || [];
return audience
.filter(a => a.status === 'error')
.map(a => `${a.name}: ${a.phone_number}`)
.join('<br/>');
campaignListError() {
const audience = this.campaign.audience || [];
return audience
.filter(a => a.status === 'error')
.map(
a =>
`${this.$t('CONTACT_FORM.FORM.NAME.LABEL')}: ${a.name},
${this.$t('CONTACT_FORM.FORM.PHONE_NUMBER.LABEL')}: ${
a.phone_number
}`
)
.join('<br/>');
},
},
methods: {
messageStamp,
Expand Down Expand Up @@ -139,16 +145,30 @@ export default {
>
{{ messageStamp(new Date(campaign.scheduled_at), 'LLL d, h:mm a') }}
</div>
<div
v-if="campaign.inbox.channel_type == 'Channel::Whatsapp'"
class="mb-1 text-xs text-slate-700 dark:text-slate-500"
>
</div>

<div
v-if="campaign.inbox.channel_type == 'Channel::Whatsapp'"
class="flex flex-row items-center mt-5 space-x-3"
>
<div class="mb-1 text-xs text-slate-700 dark:text-slate-500">
{{ $t('CAMPAIGN.AUDIENCE.REPORT') }}:
</div>
<div class="mb-1 text-xs text-slate-700 dark:text-slate-500">
{{ campaignReport }}
</div>
<div
v-if="campaign.inbox.channel_type == 'Channel::Whatsapp'"
class="mb-1 text-xs text-slate-700 dark:text-slate-500"
>
</div>

<div
v-if="
campaign.inbox.channel_type == 'Channel::Whatsapp' && campaignListError
"
class="flex flex-row items-center mt-5 space-x-3"
>
<div class="mb-1 text-xs text-slate-700 dark:text-slate-500">
{{ $t('CAMPAIGN.AUDIENCE.ERROR') }}:
</div>
<div class="mb-1 text-xs text-slate-700 dark:text-slate-500">
{{ campaignListError }}
</div>
</div>
Expand Down

0 comments on commit 4fc2dc1

Please sign in to comment.