Ajustes Toast
This commit is contained in:
@@ -84,46 +84,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Notification Toast -->
|
||||
<div x-show="notification.show" x-transition:enter="transition ease-out duration-300"
|
||||
x-transition:enter-start="opacity-0 transform translate-y-2"
|
||||
x-transition:enter-end="opacity-100 transform translate-y-0"
|
||||
x-transition:leave="transition ease-in duration-200"
|
||||
x-transition:leave-start="opacity-100 transform translate-y-0"
|
||||
x-transition:leave-end="opacity-0 transform translate-y-2"
|
||||
class="fixed bottom-4 right-4 z-50 max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden">
|
||||
<div class="p-4">
|
||||
<div class="flex items-start">
|
||||
<div class="flex-shrink-0">
|
||||
<svg x-show="notification.type === 'success'" class="h-6 w-6 text-green-400" fill="none"
|
||||
viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
<svg x-show="notification.type === 'error'" class="h-6 w-6 text-red-400" fill="none"
|
||||
viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3 w-0 flex-1 pt-0.5">
|
||||
<p class="text-sm font-medium text-gray-900" x-text="notification.title"></p>
|
||||
<p class="mt-1 text-sm text-gray-500" x-text="notification.message"></p>
|
||||
</div>
|
||||
<div class="ml-4 flex-shrink-0 flex">
|
||||
<button @click="notification.show = false"
|
||||
class="bg-white rounded-md inline-flex text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
|
||||
<span class="sr-only">Fechar</span>
|
||||
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd"
|
||||
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
||||
clip-rule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@@ -131,12 +92,6 @@
|
||||
Alpine.data('settings', () => ({
|
||||
activeTab: 'interactions',
|
||||
testing: false,
|
||||
notification: {
|
||||
show: false,
|
||||
type: 'success',
|
||||
title: '',
|
||||
message: ''
|
||||
},
|
||||
|
||||
testIntegration() {
|
||||
this.testing = true;
|
||||
@@ -165,28 +120,22 @@
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
this.showNotification(
|
||||
data.success ? 'success' : 'error',
|
||||
data.success ? 'Sucesso' : 'Erro',
|
||||
data.message
|
||||
);
|
||||
this.$dispatch('notify', {
|
||||
type: data.success ? 'success' : 'error',
|
||||
title: data.success ? 'Sucesso' : 'Erro',
|
||||
message: data.message
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
this.showNotification('error', 'Erro', 'Falha na requisição.');
|
||||
this.$dispatch('notify', {
|
||||
type: 'error',
|
||||
title: 'Erro',
|
||||
message: 'Falha na requisição.'
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
this.testing = false;
|
||||
});
|
||||
},
|
||||
|
||||
showNotification(type, title, message) {
|
||||
this.notification.type = type;
|
||||
this.notification.title = title;
|
||||
this.notification.message = message;
|
||||
this.notification.show = true;
|
||||
setTimeout(() => {
|
||||
this.notification.show = false;
|
||||
}, 5000);
|
||||
}
|
||||
}))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user