first commit
This commit is contained in:
93
resources/assets/js/bootstrap-table/contactsFormatters.js
Normal file
93
resources/assets/js/bootstrap-table/contactsFormatters.js
Normal file
@ -0,0 +1,93 @@
|
||||
import {routes} from '../../../../../laravel-vuexy-admin/resources/assets/js/bootstrap-table/globalConfig.js';
|
||||
|
||||
|
||||
|
||||
export const contactActionFormatter = (value, row, index) => {
|
||||
if (!row.id) return '';
|
||||
|
||||
const showUrl = routes['admin.contact.show'].replace(':id', row.id);
|
||||
const editUrl = routes['admin.contact.edit'].replace(':id', row.id);
|
||||
const deleteUrl = routes['admin.contact.delete'].replace(':id', row.id);
|
||||
|
||||
return `
|
||||
<div class="flex space-x-2">
|
||||
<a href="${editUrl}" title="Editar" class="icon-button">
|
||||
<i class="ti ti-edit"></i>
|
||||
</a>
|
||||
<a href="${deleteUrl}" title="Eliminar" class="icon-button">
|
||||
<i class="ti ti-trash"></i>
|
||||
</a>
|
||||
<a href="${showUrl}" title="Ver" class="icon-button">
|
||||
<i class="ti ti-eye"></i>
|
||||
</a>
|
||||
</div>
|
||||
`.trim();
|
||||
};
|
||||
|
||||
export const agentFormatter = (value, row, index) => {
|
||||
if (!row.agent_name) return '';
|
||||
|
||||
const email = row.agent_email || 'Sin correo';
|
||||
const userUrl = routes['admin.user.show'].replace(':id', row.id);
|
||||
|
||||
return `
|
||||
<div class="flex flex-col">
|
||||
<a href="${userUrl}" class="font-medium text-slate-600 hover:underline block text-wrap">${row.agent_name}</a>
|
||||
<small class="text-muted">${email}</small>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
export const contactParentFormatter = (value, row, index) => {
|
||||
if (!row.parent_name) return '';
|
||||
|
||||
const email = row.parent_email || 'Sin correo';
|
||||
const showUrl = routes['admin.contact.show'].replace(':id', row.id);
|
||||
|
||||
return `
|
||||
<div class="flex flex-col">
|
||||
<a href="${showUrl}" class="font-medium text-slate-600 hover:underline block text-wrap">${row.parent_name}</a>
|
||||
<small class="text-muted">${email}</small>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const emailFormatter = (value, row, index) => {
|
||||
if (!value) return '';
|
||||
return `
|
||||
<a href="mailto:${value}" class="flex items-center space-x-2 text-blue-600 hover:underline">
|
||||
<i class="fa-solid fa-envelope"></i>
|
||||
<span>${value}</span>
|
||||
</a>
|
||||
`;
|
||||
};
|
||||
|
||||
export const telFormatter = (value, row, index) => {
|
||||
if (!value) return '';
|
||||
return `
|
||||
<a href="tel:${value}" class="flex items-center space-x-2 text-green-600 hover:underline">
|
||||
<i class="fa-solid fa-phone"></i>
|
||||
<span class="whitespace-nowrap">${value}</span>
|
||||
</a>
|
||||
`;
|
||||
};
|
||||
|
||||
export const direccionFormatter = (value, row, index) => {
|
||||
let direccion = row.direccion ? row.direccion.trim() : '';
|
||||
let numExt = row.num_ext ? ` #${row.num_ext}` : '';
|
||||
let numInt = row.num_int ? `, Int. ${row.num_int}` : '';
|
||||
|
||||
let fullAddress = `${direccion}${numExt}${numInt}`.trim();
|
||||
|
||||
return fullAddress ? `<span class="whitespace-nowrap">${fullAddress}</span>` : '<span class="text-muted">Sin dirección</span>';
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user