Compare commits

...

3 Commits

6 changed files with 38 additions and 25 deletions

1
.gitignore vendored
View File

@ -30,3 +30,4 @@ nextSteps.txt
/playwright-report/ /playwright-report/
/blob-report/ /blob-report/
/playwright/.cache/ /playwright/.cache/
resources

View File

@ -1,7 +1,7 @@
[Interface] [Interface]
PrivateKey = OPasvZsdAdU46BJLXOLMqy4BgZq/UvKtjTRpTTVSGX8= PrivateKey = QBPeUFxS5EVEZT2QRhMgSW4gUXG2WoUTlUFg/p9ZEEk=
Address = 10.0.0.96/32 Address = 10.0.0.97/32
DNS = 1.1.1.1 DNS = 1.1.1.1
[Peer] [Peer]

View File

@ -152,6 +152,14 @@ const Dashboard: React.FC = () => {
}) })
); );
// FIX: Check if we have any projects
if (res.data.length === 0) {
// No projects available, clear selected project
dispatch(setSelectedProjectSlice(null));
// fetchProfile();
return;
}
// Check if we already have a selected project that's being tracked // Check if we already have a selected project that's being tracked
const currentlySelected = selectedProject; const currentlySelected = selectedProject;
const currentlyTracking = isTracking; const currentlyTracking = isTracking;
@ -208,9 +216,13 @@ const Dashboard: React.FC = () => {
fetchProfile(); fetchProfile();
} else { } else {
console.warn("⚠️ Unexpected response:", res); console.warn("⚠️ Unexpected response:", res);
// FIX: Also clear selected project on unexpected response
dispatch(setSelectedProjectSlice(null));
} }
} catch (err) { } catch (err) {
console.error("❌ Error fetching projects:", err); console.error("❌ Error fetching projects:", err);
// FIX: Clear selected project on error
dispatch(setSelectedProjectSlice(null));
} finally { } finally {
setIsRefreshing(false); setIsRefreshing(false);
} }
@ -218,6 +230,7 @@ const Dashboard: React.FC = () => {
useEffect(() => { useEffect(() => {
fetchProjects(); fetchProjects();
fetchProfile()
}, []); }, []);
const handleRefresh = async () => { const handleRefresh = async () => {
@ -285,6 +298,7 @@ const Dashboard: React.FC = () => {
<h1 className="text-md font-bold">Dashboard</h1> <h1 className="text-md font-bold">Dashboard</h1>
</div> </div>
{/* Tracking Section */} {/* Tracking Section */}
{/* Tracking Section */}
<div className="w-full mb-4"> <div className="w-full mb-4">
<div className="card bg-base-100 border border-base-200 shadow-sm card-sm"> <div className="card bg-base-100 border border-base-200 shadow-sm card-sm">
<div className="card-body"> <div className="card-body">
@ -305,11 +319,6 @@ const Dashboard: React.FC = () => {
<p className="text-lg font-extrabold text-success"> <p className="text-lg font-extrabold text-success">
{formatTime(displayTime)} {formatTime(displayTime)}
</p> </p>
{/* <p className={`text-lg font-extrabold ${isLimitReached ? 'text-error' : 'text-success'}`}>
{formatTime(displayTime)}
{isLimitReached && " ⚠️"}
</p> */}
<div> <div>
<span className="text-base-content/70">Project:</span>{" "} <span className="text-base-content/70">Project:</span>{" "}
<span className="font-semibold"> <span className="font-semibold">
@ -356,7 +365,9 @@ const Dashboard: React.FC = () => {
</> </>
) : ( ) : (
<p className="text-sm text-base-content/60 text-center"> <p className="text-sm text-base-content/60 text-center">
Select a project below to start tracking. {projectsData.length === 0
? "No projects available."
: "Select a project below to start tracking."}
</p> </p>
)} )}
</div> </div>
@ -371,7 +382,7 @@ const Dashboard: React.FC = () => {
{!selectedData?.isTracking && {!selectedData?.isTracking &&
<button <button
onClick={handleRefresh} onClick={handleRefresh}
disabled={isRefreshing } disabled={isRefreshing}
className="btn btn-xs btn-ghost gap-1 text-warning" className="btn btn-xs btn-ghost gap-1 text-warning"
title="Refresh projects" title="Refresh projects"
> >

View File

@ -9,6 +9,8 @@ const PaysSlips = () => {
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const [rows, setRows] = useState<any[]>([]); const [rows, setRows] = useState<any[]>([]);
useEffect(() => { useEffect(() => {
if (!projectSummary?.vaId) return; if (!projectSummary?.vaId) return;

View File

@ -64,13 +64,11 @@ const Timesheets: React.FC = () => {
const [lastRefreshed, setLastRefreshed] = useState<Date | null>(null); const [lastRefreshed, setLastRefreshed] = useState<Date | null>(null);
const [initialLoading, setInitialLoading] = useState(true); const [initialLoading, setInitialLoading] = useState(true);
const [tick, setTick] = useState(0); const [tick, setTick] = useState(0);
const { selectedProject } = const { selectedProject } = useSelector((state: any) => state.projects);
useSelector((state: any) => state.projects); const selectedProjectId = selectedProject?.projectId ?? null;
const activeProjects = projectsData.filter(p => p.status === "ACTIVE"); const activeProjects = projectsData.filter(p => p.status === "ACTIVE");
console.log("selectedProject", selectedProject.projectId)
useEffect(() => { useEffect(() => {
const interval = setInterval(() => { const interval = setInterval(() => {
@ -225,13 +223,13 @@ const Timesheets: React.FC = () => {
<td>{formatWorkTime(entry.totalWorkTime)}</td> <td>{formatWorkTime(entry.totalWorkTime)}</td>
<td> <td>
<button <button
disabled={(formatWorkTime(entry.totalWorkTime) === "0h 0m" || (isTracking && entry.projectId === selectedProject.projectId))} disabled={(formatWorkTime(entry.totalWorkTime) === "0h 0m" || (isTracking && entry.projectId === selectedProjectId))}
onClick={() => onClick={() =>
handleViewLogs(entry.projectId, entry.projectName) handleViewLogs(entry.projectId, entry.projectName)
} }
className="btn btn-ghost btn-xs" className="btn btn-ghost btn-xs"
> >
{(formatWorkTime(entry.totalWorkTime) === "0h 0m" || (isTracking && entry.projectId === selectedProject.projectId)) ? ( {(formatWorkTime(entry.totalWorkTime) === "0h 0m" || (isTracking && entry.projectId === selectedProjectId)) ? (
<EyeOff size={16} /> <EyeOff size={16} />
) : ( ) : (
<Eye size={16} /> <Eye size={16} />

View File

@ -7,7 +7,7 @@ interface Props {
const VpnGuard: React.FC<Props> = ({ children }) => { const VpnGuard: React.FC<Props> = ({ children }) => {
const VPN_API = "http://10.0.0.1:3000"; const VPN_API = "http://10.0.0.1";
const DEFAULT_API = "https://portal-sf.docva.com" const DEFAULT_API = "https://portal-sf.docva.com"
const [checking, setChecking] = useState(true); const [checking, setChecking] = useState(true);
@ -66,6 +66,7 @@ const VpnGuard: React.FC<Props> = ({ children }) => {
console.log("vpnRes", vpnRes); console.log("vpnRes", vpnRes);
if (vpnRes) { if (vpnRes) {
// Run VPN check again AFTER URL changes // Run VPN check again AFTER URL changes
await checkVPN(); await checkVPN();
} else { } else {