40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import Swal from 'sweetalert2';
|
|
|
|
|
|
export function formatDate(date:string) {
|
|
const options = { year: 'numeric', month: 'long', day: 'numeric',locale: 'id-ID' };
|
|
return new Date(date).toLocaleDateString('id-ID', options);
|
|
}
|
|
export function getDateNow(){
|
|
const now = new Date();
|
|
const formattedDate = `${now.getFullYear()}-${(now.getMonth()+1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')}`;
|
|
// console.log(formattedDate); // Contoh output: "2025-05-07"
|
|
return formattedDate;
|
|
}
|
|
export function capitalizeEachWord(text:string) {
|
|
// const lowercase = text.toLowerCase();
|
|
// return lowercase.charAt(0).toUpperCase() + lowercase.slice(1);
|
|
return text
|
|
.toLowerCase()
|
|
.split(' ')
|
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
.join(' ');
|
|
}
|
|
export function confirmAlert(message: string,subtitle:string,type: string) {
|
|
Swal.fire({
|
|
title: message,
|
|
text: subtitle,
|
|
icon: type,
|
|
// confirmButtonText: 'Cool'
|
|
})
|
|
}
|
|
export function sweetalert(message: string,subtitle:string,type: string) {
|
|
Swal.fire({
|
|
position: "center",
|
|
icon: type,
|
|
title: message,
|
|
text: subtitle,
|
|
showConfirmButton: false,
|
|
timer: 3500
|
|
});
|
|
} |