feat: enhance dialog warning with customizable action text and add customer name utility function
This commit is contained in:
parent
8dd36cbc64
commit
321a0a6048
1 changed files with 30 additions and 1 deletions
|
|
@ -14,6 +14,9 @@ import { getRole } from 'src/services/keycloak';
|
|||
|
||||
import GlobalDialog from 'components/GlobalDialog.vue';
|
||||
import DialogDuplicateData from 'components/DialogDuplicateData.vue';
|
||||
import useOptionStore from '../options';
|
||||
import { CustomerBranch } from '../customer/types';
|
||||
import { CustomerBranchRelation } from '../quotations';
|
||||
|
||||
export const baseUrl = import.meta.env.VITE_API_BASE_URL;
|
||||
|
||||
|
|
@ -53,6 +56,7 @@ export function dialogWarningClose(
|
|||
t: ComposerTranslation,
|
||||
opts: {
|
||||
message?: string;
|
||||
actionText?: string;
|
||||
action?: (...args: unknown[]) => unknown;
|
||||
cancel?: (...args: unknown[]) => unknown;
|
||||
},
|
||||
|
|
@ -61,7 +65,7 @@ export function dialogWarningClose(
|
|||
color: 'warning',
|
||||
icon: 'mdi-alert',
|
||||
title: t('form.warning.title'),
|
||||
actionText: t('dialog.action.close'),
|
||||
actionText: opts.actionText || t('dialog.action.close'),
|
||||
message: opts.message || t('dialog.message.warningClose'),
|
||||
action: async () => {
|
||||
if (opts.action) opts.action();
|
||||
|
|
@ -542,3 +546,28 @@ export function changeMode(mode: string) {
|
|||
export function capitalizeFirstLetter(val: string) {
|
||||
return String(val).charAt(0).toUpperCase() + String(val).slice(1);
|
||||
}
|
||||
|
||||
export function getCustomerName(
|
||||
record: CustomerBranch | CustomerBranchRelation,
|
||||
opts?: {
|
||||
locale?: string;
|
||||
noCode?: boolean;
|
||||
},
|
||||
) {
|
||||
const customer = record;
|
||||
|
||||
return (
|
||||
{
|
||||
['CORP']: {
|
||||
['eng']: customer.registerNameEN,
|
||||
['tha']: customer.registerName,
|
||||
}[opts?.locale || 'eng'],
|
||||
['PERS']:
|
||||
{
|
||||
['eng']: `${useOptionStore().mapOption(customer?.namePrefix || '')} ${customer?.firstNameEN} ${customer?.lastNameEN}`,
|
||||
['tha']: `${useOptionStore().mapOption(customer?.namePrefix || '')} ${customer?.firstName} ${customer?.lastName}`,
|
||||
}[opts?.locale || 'eng'] || '-',
|
||||
}[customer.customer.customerType] +
|
||||
(opts?.noCode ? '' : ' ' + `(${customer.code})`)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue