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 router = useRouter();
|
||||
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 => {
|
||||
if (!parentId) return "WebCalibre";
|
||||
|
|
@ -121,6 +122,7 @@ export default function DashboardView({ initialFiles, user }: DashboardViewProps
|
|||
setLoading(true);
|
||||
try {
|
||||
await syncOneDrive();
|
||||
setLastSynced(new Date()); // Update the time
|
||||
router.refresh();
|
||||
} catch (error) {
|
||||
console.error("Sync failed:", error);
|
||||
|
|
@ -226,7 +228,12 @@ export default function DashboardView({ initialFiles, user }: DashboardViewProps
|
|||
|
||||
return (
|
||||
<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
|
||||
variant="outlined"
|
||||
startIcon={isRefreshing ? <CircularProgress size={16} /> : <RefreshIcon />}
|
||||
|
|
|
|||
Loading…
Reference in a new issue