Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor utilities.js #1251

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Refactor getStatusTranslation
ahmed0saber committed Jul 14, 2023
commit 219022de376e3a7e3d0c59317a06327cc989b27e
42 changes: 17 additions & 25 deletions resources/scripts/helpers/utilities.js
Original file line number Diff line number Diff line change
@@ -152,32 +152,24 @@ export default {
return statusColors[status];
},
getStatusTranslation(status) {
switch (status) {
case 'DRAFT':
return global.t('general.draft')
case 'PAID':
return global.t('invoices.paid')
case 'UNPAID':
return global.t('invoices.unpaid')
case 'SENT':
return global.t('general.sent')
case 'REJECTED':
return global.t('estimates.rejected')
case 'ACCEPTED':
return global.t('estimates.accepted')
case 'VIEWED':
return global.t('invoices.viewed')
case 'EXPIRED':
return global.t('estimates.expired')
case 'PARTIALLY PAID':
return global.t('estimates.partially_paid')
case 'COMPLETED':
return global.t('invoices.completed')
case 'DUE':
return global.t('general.due')
default:
return status
const statusMessages = {
DRAFT: 'general.draft',
PAID: 'invoices.paid',
UNPAID: 'invoices.unpaid',
SENT: 'general.sent',
REJECTED: 'estimates.rejected',
ACCEPTED: 'estimates.accepted',
VIEWED: 'invoices.viewed',
EXPIRED: 'estimates.expired',
'PARTIALLY PAID': 'estimates.partially_paid',
COMPLETED: 'invoices.completed',
DUE: 'general.due',
};
const messageKey = statusMessages[status];
if (messageKey) {
return global.t(messageKey);
}
return status;
},
toFormData(object) {
const formData = new FormData()