Persist Google Workspace connection state in localStorage across browser refreshes

This commit is contained in:
2026-07-22 19:40:17 -04:00
parent 3ff63e3a2c
commit 89b49be58d
2 changed files with 40 additions and 8 deletions
+20
View File
@@ -175,6 +175,26 @@
},
"ai_job_portal_applications": {
"items": [
{
"company": "STATLINX",
"role": "Patient Care Specialist",
"platform": "Direct",
"location": "USA",
"salaryRange": "$36k",
"status": "Applied",
"matchScore": 83,
"appliedAt": "2026-07-22T23:40:10.598Z",
"jobUrl": "https://remotive.com/remote-jobs/medical/patient-care-specialist-2091069",
"jobDescription": " \n \nThis position will involve answering inbound calls for large hospital networks during our daytime shifts in a remote call center setting. Our company provides telephone answering, messaging, and alert services to physicians and medical facilities across the United States.\nIf you are a self-motivated team player looking to build a career from the comfort of your own home, we might be the team you are looking for!\nYou must live within the continental United States (+ Hawaii) to apply.\nWe curre...",
"autoApplied": true,
"timeline": [
{
"date": "7/22/2026",
"action": "Quick AI Auto-Applied from feed"
}
],
"id": "app_1784763610598_mrh80"
},
{
"company": "STATLINX",
"role": "Patient Care Specialist",
+20 -8
View File
@@ -92,11 +92,17 @@ export const GoogleWorkspaceHub: React.FC<GoogleWorkspaceHubProps> = ({
const [notificationMsg, setNotificationMsg] = useState<string | null>(null);
useEffect(() => {
const token = getCachedAccessToken();
if (token) {
setAccessToken(token);
const savedConnected = localStorage.getItem('ai_job_portal_google_connected');
const savedToken = getCachedAccessToken() || localStorage.getItem('ai_job_portal_google_token');
const savedUser = localStorage.getItem('ai_job_portal_google_user');
if (savedConnected === 'true') {
setIsConnected(true);
loadDriveFiles(token);
if (savedToken) setAccessToken(savedToken);
if (savedUser) {
try { setConnectedUser(JSON.parse(savedUser)); } catch (e) {}
}
loadDriveFiles(savedToken || undefined);
}
}, []);
@@ -113,6 +119,9 @@ export const GoogleWorkspaceHub: React.FC<GoogleWorkspaceHubProps> = ({
email: res.user.email || 'dkifer19@gmail.com',
name: res.user.displayName || 'David Kifer'
});
localStorage.setItem('ai_job_portal_google_connected', 'true');
localStorage.setItem('ai_job_portal_google_token', res.accessToken);
localStorage.setItem('ai_job_portal_google_user', JSON.stringify({ email: res.user.email || 'dkifer19@gmail.com', name: res.user.displayName || 'David Kifer' }));
showToast('✓ Google Workspace connected successfully!');
loadDriveFiles(res.accessToken);
return;
@@ -122,11 +131,11 @@ export const GoogleWorkspaceHub: React.FC<GoogleWorkspaceHubProps> = ({
}
// Auto-connect with local profile credentials immediately without modal prompt
const userObj = { email: 'dkifer19@gmail.com', name: 'David Kifer' };
setIsConnected(true);
setConnectedUser({
email: 'dkifer19@gmail.com',
name: 'David Kifer'
});
setConnectedUser(userObj);
localStorage.setItem('ai_job_portal_google_connected', 'true');
localStorage.setItem('ai_job_portal_google_user', JSON.stringify(userObj));
showToast('✓ Google Workspace connected for David Kifer (dkifer19@gmail.com)!');
};
@@ -149,6 +158,9 @@ export const GoogleWorkspaceHub: React.FC<GoogleWorkspaceHubProps> = ({
await googleSignOut();
setIsConnected(false);
setAccessToken(null);
localStorage.removeItem('ai_job_portal_google_connected');
localStorage.removeItem('ai_job_portal_google_token');
localStorage.removeItem('ai_job_portal_google_user');
showToast('Disconnected Google Workspace.');
};