Persist Google Workspace connection state in localStorage across browser refreshes
This commit is contained in:
+20
@@ -175,6 +175,26 @@
|
|||||||
},
|
},
|
||||||
"ai_job_portal_applications": {
|
"ai_job_portal_applications": {
|
||||||
"items": [
|
"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",
|
"company": "STATLINX",
|
||||||
"role": "Patient Care Specialist",
|
"role": "Patient Care Specialist",
|
||||||
|
|||||||
@@ -92,11 +92,17 @@ export const GoogleWorkspaceHub: React.FC<GoogleWorkspaceHubProps> = ({
|
|||||||
const [notificationMsg, setNotificationMsg] = useState<string | null>(null);
|
const [notificationMsg, setNotificationMsg] = useState<string | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const token = getCachedAccessToken();
|
const savedConnected = localStorage.getItem('ai_job_portal_google_connected');
|
||||||
if (token) {
|
const savedToken = getCachedAccessToken() || localStorage.getItem('ai_job_portal_google_token');
|
||||||
setAccessToken(token);
|
const savedUser = localStorage.getItem('ai_job_portal_google_user');
|
||||||
|
|
||||||
|
if (savedConnected === 'true') {
|
||||||
setIsConnected(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',
|
email: res.user.email || 'dkifer19@gmail.com',
|
||||||
name: res.user.displayName || 'David Kifer'
|
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!');
|
showToast('✓ Google Workspace connected successfully!');
|
||||||
loadDriveFiles(res.accessToken);
|
loadDriveFiles(res.accessToken);
|
||||||
return;
|
return;
|
||||||
@@ -122,11 +131,11 @@ export const GoogleWorkspaceHub: React.FC<GoogleWorkspaceHubProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Auto-connect with local profile credentials immediately without modal prompt
|
// Auto-connect with local profile credentials immediately without modal prompt
|
||||||
|
const userObj = { email: 'dkifer19@gmail.com', name: 'David Kifer' };
|
||||||
setIsConnected(true);
|
setIsConnected(true);
|
||||||
setConnectedUser({
|
setConnectedUser(userObj);
|
||||||
email: 'dkifer19@gmail.com',
|
localStorage.setItem('ai_job_portal_google_connected', 'true');
|
||||||
name: 'David Kifer'
|
localStorage.setItem('ai_job_portal_google_user', JSON.stringify(userObj));
|
||||||
});
|
|
||||||
showToast('✓ Google Workspace connected for David Kifer (dkifer19@gmail.com)!');
|
showToast('✓ Google Workspace connected for David Kifer (dkifer19@gmail.com)!');
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -149,6 +158,9 @@ export const GoogleWorkspaceHub: React.FC<GoogleWorkspaceHubProps> = ({
|
|||||||
await googleSignOut();
|
await googleSignOut();
|
||||||
setIsConnected(false);
|
setIsConnected(false);
|
||||||
setAccessToken(null);
|
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.');
|
showToast('Disconnected Google Workspace.');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user