73 lines
1.6 KiB
TypeScript
73 lines
1.6 KiB
TypeScript
|
|
"use client";
|
||
|
|
import { useEffect } from "react";
|
||
|
|
|
||
|
|
export function convertDateFormat(dateString: string) {
|
||
|
|
var date = new Date(dateString);
|
||
|
|
|
||
|
|
var day = date.getDate();
|
||
|
|
var month = date.getMonth() + 1;
|
||
|
|
var year = date.getFullYear();
|
||
|
|
var hours = date.getHours();
|
||
|
|
var minutes = date.getMinutes();
|
||
|
|
|
||
|
|
var formattedTime =
|
||
|
|
(hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes;
|
||
|
|
var formattedDate =
|
||
|
|
(day < 10 ? "0" : "") +
|
||
|
|
day +
|
||
|
|
"-" +
|
||
|
|
(month < 10 ? "0" : "") +
|
||
|
|
month +
|
||
|
|
"-" +
|
||
|
|
year +
|
||
|
|
", " +
|
||
|
|
formattedTime;
|
||
|
|
|
||
|
|
return formattedDate;
|
||
|
|
}
|
||
|
|
export function convertDateFormatNoTime(dateString: string) {
|
||
|
|
var date = new Date(dateString);
|
||
|
|
|
||
|
|
var day = date.getDate();
|
||
|
|
var month = date.getMonth() + 1;
|
||
|
|
var year = date.getFullYear();
|
||
|
|
|
||
|
|
var formattedDate =
|
||
|
|
(day < 10 ? "0" : "") +
|
||
|
|
day +
|
||
|
|
"-" +
|
||
|
|
(month < 10 ? "0" : "") +
|
||
|
|
month +
|
||
|
|
"-" +
|
||
|
|
year;
|
||
|
|
|
||
|
|
return formattedDate;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function formatTextToHtmlTag(text: string) {
|
||
|
|
if (text) {
|
||
|
|
const htmlText = text.replaceAll("\\n", "<br>").replaceAll(/"/g, "");
|
||
|
|
return { __html: htmlText };
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const LoadScript = () => {
|
||
|
|
useEffect(() => {
|
||
|
|
const script = document.createElement("script");
|
||
|
|
script.src = "https://cdn.userway.org/widget.js";
|
||
|
|
script.setAttribute("data-account", "X36s1DpjqB");
|
||
|
|
script.async = true;
|
||
|
|
|
||
|
|
document.head.appendChild(script);
|
||
|
|
|
||
|
|
return () => {
|
||
|
|
// Cleanup if needed
|
||
|
|
document.head.removeChild(script);
|
||
|
|
};
|
||
|
|
}, []);
|
||
|
|
|
||
|
|
return null; // Tidak perlu merender apa-apa
|
||
|
|
};
|
||
|
|
|
||
|
|
export default LoadScript;
|