FEAT: Enhance authentication session management with configurable cookie domain and improved token refresh logic

This commit is contained in:
2025-06-16 17:53:43 +02:00
parent 3a83831a20
commit d436367ee6
11 changed files with 594 additions and 149 deletions

View File

@@ -340,6 +340,7 @@ import ContractStatusBadge from "~/components/ContractStatusBadge.vue";
import { useFetch } from "#app";
import { ref, computed } from "vue";
import type { Interest } from "@/utils/types";
import { formatDate, formatDateUS, getRelativeTime } from "@/utils/dateUtils";
useHead({
title: "Interest List",
@@ -428,50 +429,6 @@ const getSalesStatusColor = (status: string) => {
return 'grey';
};
const formatDate = (dateString: string) => {
if (!dateString) return "-";
try {
// Handle DD-MM-YYYY format
const parts = dateString.split("-");
if (parts.length === 3) {
const day = parseInt(parts[0], 10);
const month = parseInt(parts[1], 10) - 1; // Month is 0-indexed in JavaScript
const year = parseInt(parts[2], 10);
const date = new Date(year, month, day);
// Check if the date is valid
if (isNaN(date.getTime())) {
console.warn("Invalid date format:", dateString);
return "-";
}
return date.toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
});
} else {
// Fallback to standard Date parsing
const date = new Date(dateString);
if (isNaN(date.getTime())) {
console.warn("Invalid date format:", dateString);
return "-";
}
return date.toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
});
}
} catch (error) {
console.error("Error formatting date:", dateString, error);
return "-";
}
};
const filteredInterests = computed(() => {
if (!interests.value?.list) return [];
@@ -526,42 +483,6 @@ const getInitials = (name: string) => {
return name.substring(0, 2).toUpperCase();
};
// Helper function to get relative time
const getRelativeTime = (dateString: string) => {
if (!dateString) return '';
try {
let date: Date;
// Handle DD-MM-YYYY format
if (dateString.includes('-')) {
const parts = dateString.split('-');
if (parts.length === 3) {
const [day, month, year] = parts;
date = new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
} else {
date = new Date(dateString);
}
} else {
date = new Date(dateString);
}
if (isNaN(date.getTime())) return '';
const now = new Date();
const diffTime = Math.abs(now.getTime() - date.getTime());
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
if (diffDays === 0) return 'Today';
if (diffDays === 1) return 'Yesterday';
if (diffDays < 7) return `${diffDays} days ago`;
if (diffDays < 30) return `${Math.floor(diffDays / 7)} weeks ago`;
if (diffDays < 365) return `${Math.floor(diffDays / 30)} months ago`;
return `${Math.floor(diffDays / 365)} years ago`;
} catch (error) {
return '';
}
};
</script>
<style scoped>