date format updated

This commit is contained in:
victorAnumudu
2025-02-19 16:51:44 +01:00
parent 1b77d528df
commit 777f58ae23
5 changed files with 53 additions and 4 deletions
+13 -2
View File
@@ -10,6 +10,9 @@ import Avatar from '../../assets/user_avatar.jpg'
import queryKeys from '../../services/queryKeys'
import { applyLoan } from '../../services/siteServices'
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
import getDateFromDateString from '../../helpers/GetDateFromDateString';
export default function ApplyCom() {
const {data, isFetching, isError, error} = useQuery({
@@ -52,6 +55,9 @@ export default function ApplyCom() {
<th scope="col" className="px-4 py-2">
Added
</th>
<th scope="col" className="px-4 py-2">
Verified
</th>
<th scope="col" className="px-4 py-2">
Action
</th>
@@ -75,7 +81,12 @@ export default function ApplyCom() {
</td>
<td className="px-3 py-2">
<div className="flex items-center">
{new Date(item?.added).toDateString()}
{getDateFromDateString(item?.added)} {getTimeFromDateString(item?.added)}
</div>
</td>
<td className="px-3 py-2">
<div className="flex items-center">
{!item?.verified ? 'N/A' : `${getDateFromDateString(item?.verified)} ${getTimeFromDateString(item?.verified)}`}
</div>
</td>
<td className="px-3 py-2 flex gap-3 md:gap-4">
@@ -99,7 +110,7 @@ export default function ApplyCom() {
))
:
<tr className="w-3 p-3">
<td className="px-3 py-2" colSpan={5}>
<td className="px-3 py-2" colSpan={6}>
<div className="flex justify-center items-center">
No Record Found
</div>
@@ -9,6 +9,8 @@ import Icons from '../Icons'
import Avatar from '../../assets/user_avatar.jpg'
import queryKeys from '../../services/queryKeys'
import { approvedLoan } from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
export default function ApprovedLoanCom() {
@@ -69,7 +71,7 @@ export default function ApprovedLoanCom() {
</td>
<td className="px-3 py-2">
<div className="flex items-center">
{new Date(item?.added).toDateString()}
{getDateFromDateString(item?.added)} {getTimeFromDateString(item?.added)}
</div>
</td>
<td className="px-3 py-2 flex gap-3 md:gap-4">
@@ -9,6 +9,8 @@ import Icons from '../Icons'
import Avatar from '../../assets/user_avatar.jpg'
import queryKeys from '../../services/queryKeys'
import { selectLoan } from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
export default function SelectLoanCom() {
@@ -69,7 +71,7 @@ export default function SelectLoanCom() {
</td>
<td className="px-3 py-2">
<div className="flex items-center">
{new Date(item?.added).toDateString()}
{getDateFromDateString(item?.added)} {getTimeFromDateString(item?.added)}
</div>
</td>
<td className="px-3 py-2 flex gap-3 md:gap-4">
+17
View File
@@ -0,0 +1,17 @@
function getDateFromDateString(dateString) {
const date = new Date(dateString);
// Ensure the date is valid
if (isNaN(date)) {
return "Invalid date string";
}
// Get the year, month, and day
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed, so we add 1
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
}
export default getDateFromDateString
+17
View File
@@ -0,0 +1,17 @@
function getTimeFromDateString(dateString) {
const date = new Date(dateString);
// Ensure the date is valid
if (isNaN(date)) {
return "Invalid date string";
}
// Get hours, minutes, and seconds
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
// const seconds = String(date.getSeconds()).padStart(2, '0');
return `${hours <= 12 ? hours : hours%12}:${minutes} ${hours >= 12 ? 'PM' : 'AM'}`;
}
export default getTimeFromDateString