Skip to content

Commit 81b1c1e

Browse files
committed
refactor(getcloser): remove lastPage
1 parent fd06dc1 commit 81b1c1e

2 files changed

Lines changed: 2 additions & 22 deletions

File tree

getcloser/frontend/src/app/pages/Page3.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export default function Page3() {
141141
}
142142
localStorage.removeItem(CHALLENGE_DATA_KEY);
143143
reset();
144-
localStorage.removeItem('lastPage');
144+
145145
setCurrentPage('page1');
146146
}
147147
} else if (question) {
@@ -150,15 +150,14 @@ export default function Page3() {
150150
console.log('Missing id or teamId, cannot initialize challenge. Resetting.');
151151
localStorage.removeItem(CHALLENGE_DATA_KEY);
152152
reset();
153-
localStorage.removeItem('lastPage');
153+
154154
setCurrentPage('page1');
155155
}
156156
};
157157

158158
initializeChallenge();
159159
}, [id, teamId, question, memberIds, setQuestion, setChallengeId, reset, setCurrentPage]);
160160

161-
162161
const handleSubmit = async (e: React.FormEvent) => {
163162
e.preventDefault();
164163

@@ -168,8 +167,6 @@ export default function Page3() {
168167
submitted_answer: answer,
169168
};
170169

171-
console.log(JSON.stringify(requestBody));
172-
173170
try {
174171
const response = await authenticatedFetch('/api/v1/challenges/submit', {
175172
method: 'POST',

getcloser/frontend/src/app/providers.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,18 @@ function StoreInitializer() {
1212
// Function to run on initial load
1313
const initialize = () => {
1414
if (typeof window !== 'undefined') {
15-
const savedPage = localStorage.getItem('lastPage');
16-
if (savedPage) {
17-
useNavigationStore.getState().setCurrentPage(savedPage);
18-
}
19-
2015
const accessToken = useFormStore.getState().accessToken;
2116
const currentPage = useNavigationStore.getState().currentPage;
2217

2318
// If no accessToken and not already on 'page1', redirect to 'page1'
2419
if (!accessToken && currentPage !== 'page1') {
2520
useNavigationStore.getState().setCurrentPage('page1');
26-
localStorage.removeItem('lastPage'); // Clear lastPage on auth redirect
2721
}
2822
}
2923
};
3024

3125
initialize();
3226

33-
// Subscribe to store changes and save to localStorage
34-
const unsubscribe = useNavigationStore.subscribe(
35-
(state) => {
36-
if (typeof window !== 'undefined') {
37-
localStorage.setItem('lastPage', state.currentPage);
38-
}
39-
}
40-
);
41-
4227
// Also subscribe to formStore for accessToken changes
4328
const unsubscribeFormStore = useFormStore.subscribe(
4429
(state, prevState) => {
@@ -48,14 +33,12 @@ function StoreInitializer() {
4833
// If the access token is cleared and we are not on page1, navigate to page1
4934
if (!accessToken && prevState.accessToken && currentPage !== 'page1') {
5035
useNavigationStore.getState().setCurrentPage('page1');
51-
localStorage.removeItem('lastPage'); // Clear lastPage on auth redirect
5236
}
5337
}
5438
}
5539
);
5640

5741
return () => {
58-
unsubscribe();
5942
unsubscribeFormStore();
6043
};
6144
}, []);

0 commit comments

Comments
 (0)