added Sync Status
This commit is contained in:
parent
c1a9bb6465
commit
fd837fe22f
1 changed files with 12 additions and 5 deletions
|
|
@ -108,6 +108,7 @@ export default function DashboardView({ initialFiles, user }: DashboardViewProps
|
||||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const isAdmin = user?.role === "ADMIN";
|
const isAdmin = user?.role === "ADMIN";
|
||||||
|
const [lastSynced, setLastSynced] = useState<Date | null>(new Date()); // Defaults to 'Just now' on load
|
||||||
|
|
||||||
const getVirtualPath = (parentId: string | null): string => {
|
const getVirtualPath = (parentId: string | null): string => {
|
||||||
if (!parentId) return "WebCalibre";
|
if (!parentId) return "WebCalibre";
|
||||||
|
|
@ -118,10 +119,11 @@ export default function DashboardView({ initialFiles, user }: DashboardViewProps
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSync = async () => {
|
const handleSync = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
await syncOneDrive();
|
await syncOneDrive();
|
||||||
router.refresh();
|
setLastSynced(new Date()); // Update the time
|
||||||
|
router.refresh();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Sync failed:", error);
|
console.error("Sync failed:", error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -226,7 +228,12 @@ export default function DashboardView({ initialFiles, user }: DashboardViewProps
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: 2 }}>
|
<Box sx={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center', gap: 2 }}>
|
||||||
|
{lastSynced && (
|
||||||
|
<Typography variant="caption" color="text.secondary" sx={{ fontStyle: 'italic' }}>
|
||||||
|
Last synced: {lastSynced.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
startIcon={isRefreshing ? <CircularProgress size={16} /> : <RefreshIcon />}
|
startIcon={isRefreshing ? <CircularProgress size={16} /> : <RefreshIcon />}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue