feat(time-ago-component): TimeAgo relative-time (vor X min) [tsc:fail]
This commit is contained in:
parent
a7ce22cc11
commit
1068ec827d
@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"completed_features": [],
|
"completed_features": [],
|
||||||
"current_feature": "price-tag-component",
|
"current_feature": "time-ago-component",
|
||||||
"started_at": "2026-05-23T10:48:26.654134"
|
"started_at": "2026-05-23T10:48:26.654134",
|
||||||
|
"attempted_features": [
|
||||||
|
"price-tag-component"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@ -4685,3 +4685,21 @@ src/index.ts(27,25): error TS2769: No overload matches this call.
|
|||||||
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||||
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||||
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>,
|
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>,
|
||||||
|
- `10:48:34` **INFO** Committed feature price-tag-component
|
||||||
|
- `10:48:34` **INFO** Pushed: rc=0
|
||||||
|
|
||||||
|
## Phase-3 Feature: time-ago-component (2026-05-23 10:48:34)
|
||||||
|
|
||||||
|
- `10:48:34` **INFO** Description: TimeAgo relative-time (vor X min)
|
||||||
|
- `10:48:34` **INFO** Generating apps/web/src/components/TimeAgo.tsx (TimeAgo-Component. Props: date (Date|string). Berechnet diff. Output: …)
|
||||||
|
- `10:48:46` **INFO** wrote 1475 chars in 11.6s (attempt 1)
|
||||||
|
- `10:48:46` **INFO** Running tsc --noEmit on api…
|
||||||
|
- `10:48:47` **WARN** tsc errors:
|
||||||
|
src/db/schema.ts(37,14): error TS7022: 'customers' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
|
||||||
|
src/db/schema.ts(45,59): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
|
||||||
|
src/db/schema.ts(49,14): error TS7022: 'projects' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
|
||||||
|
src/db/schema.ts(53,56): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
|
||||||
|
src/index.ts(27,25): error TS2769: No overload matches this call.
|
||||||
|
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||||
|
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||||
|
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>,
|
||||||
|
|||||||
47
apps/web/src/components/TimeAgo.tsx
Normal file
47
apps/web/src/components/TimeAgo.tsx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
|
||||||
|
interface TimeAgoProps {
|
||||||
|
date: Date | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TimeAgo: React.FC<TimeAgoProps> = ({ date }) => {
|
||||||
|
const [timeAgo, setTimeAgo] = useState<string>('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const calculateTimeAgo = () => {
|
||||||
|
const now = new Date().getTime();
|
||||||
|
const past = new Date(date).getTime();
|
||||||
|
const diffInSeconds = Math.floor((now - past) / 1000);
|
||||||
|
|
||||||
|
if (diffInSeconds < 5) return 'gerade eben';
|
||||||
|
if (diffInSeconds < 60) return `vor ${diffInSeconds} Sekunden`;
|
||||||
|
|
||||||
|
const diffInMinutes = Math.floor(diffInSeconds / 60);
|
||||||
|
if (diffInMinutes < 60) return `vor ${diffInMinutes} Minute${diffInMinutes > 1 ? 'n' : ''}`;
|
||||||
|
|
||||||
|
const diffInHours = Math.floor(diffInMinutes / 60);
|
||||||
|
if (diffInHours < 24) return `vor ${diffInHours} Stunde${diffInHours > 1 ? 'n' : ''}`;
|
||||||
|
|
||||||
|
const diffInDays = Math.floor(diffInHours / 24);
|
||||||
|
if (diffInDays < 7) return `vor ${diffInDays} Tag${diffInDays > 1 ? 'en' : ''}`;
|
||||||
|
|
||||||
|
return new Date(date).toLocaleDateString('de-DE', {
|
||||||
|
day: '2-digit',
|
||||||
|
month: '2-digit',
|
||||||
|
year: 'numeric',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
setTimeAgo(calculateTimeAgo());
|
||||||
|
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
setTimeAgo(calculateTimeAgo());
|
||||||
|
}, 60000);
|
||||||
|
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, [date]);
|
||||||
|
|
||||||
|
return <span className="text-xs text-slate-500 dark:text-slate-400">{timeAgo}</span>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TimeAgo;
|
||||||
Loading…
Reference in New Issue
Block a user