dev #19
@@ -30,12 +30,39 @@ const AdminUserView = () => {
|
||||
const fileInputRef = useRef(null);
|
||||
const [changeRoleDialogOpen, setChangeRoleDialogOpen] = useState(false);
|
||||
|
||||
const formatLocalDateInputValue = (date) => {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
const formatDateInputValue = (value) => {
|
||||
if (!value) return '';
|
||||
if (typeof value === 'string') {
|
||||
return value.slice(0, 10);
|
||||
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
||||
return value;
|
||||
}
|
||||
const parsed = new Date(value);
|
||||
if (Number.isNaN(parsed.getTime())) {
|
||||
return value.slice(0, 10);
|
||||
}
|
||||
return formatLocalDateInputValue(parsed);
|
||||
}
|
||||
return new Date(value).toISOString().slice(0, 10);
|
||||
const parsed = new Date(value);
|
||||
if (Number.isNaN(parsed.getTime())) return '';
|
||||
return formatLocalDateInputValue(parsed);
|
||||
};
|
||||
|
||||
const formatDateDisplayValue = (value) => {
|
||||
if (!value) return 'N/A';
|
||||
if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
||||
const [year, month, day] = value.split('-').map(Number);
|
||||
return new Date(year, month - 1, day).toLocaleDateString();
|
||||
}
|
||||
const parsed = new Date(value);
|
||||
if (Number.isNaN(parsed.getTime())) return 'N/A';
|
||||
return parsed.toLocaleDateString();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -304,7 +331,7 @@ const AdminUserView = () => {
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Calendar className="h-4 w-4" />
|
||||
<span>Joined {joinedDate ? new Date(joinedDate).toLocaleDateString() : 'N/A'}</span>
|
||||
<span>Joined {formatDateDisplayValue(joinedDate)}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -401,7 +428,7 @@ const AdminUserView = () => {
|
||||
<div>
|
||||
<label className="text-sm font-medium text-brand-purple " style={{ fontFamily: "'Nunito Sans', sans-serif" }}>Date of Birth</label>
|
||||
<p className="text-[var(--purple-ink)] mt-1" style={{ fontFamily: "'Nunito Sans', sans-serif" }}>
|
||||
{new Date(user.date_of_birth).toLocaleDateString()}
|
||||
{formatDateDisplayValue(user.date_of_birth)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -492,14 +519,14 @@ const AdminUserView = () => {
|
||||
<div>
|
||||
<label className="text-brand-purple font-medium" style={{ fontFamily: "'Nunito Sans', sans-serif" }}>Start Date</label>
|
||||
<p className="text-[var(--purple-ink)]" style={{ fontFamily: "'Nunito Sans', sans-serif" }}>
|
||||
{new Date(sub.start_date).toLocaleDateString()}
|
||||
{formatDateDisplayValue(sub.start_date)}
|
||||
</p>
|
||||
</div>
|
||||
{sub.end_date && (
|
||||
<div>
|
||||
<label className="text-brand-purple font-medium" style={{ fontFamily: "'Nunito Sans', sans-serif" }}>End Date</label>
|
||||
<p className="text-[var(--purple-ink)]" style={{ fontFamily: "'Nunito Sans', sans-serif" }}>
|
||||
{new Date(sub.end_date).toLocaleDateString()}
|
||||
{formatDateDisplayValue(sub.end_date)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user