()
| 18 | }; |
| 19 | |
| 20 | const App = () => { |
| 21 | const { token, refreshToken, setToken, setRefreshToken } = useAuthStore(); |
| 22 | const [projectId, setProjectId] = useState(storage.getItem("pd.projectId") ?? ""); |
| 23 | const [overleafSession, setOverleafSession] = useState(storage.getItem("pd.auth.overleafSession") ?? ""); |
| 24 | const [gclb, setGclb] = useState(storage.getItem("pd.auth.gclb") ?? ""); |
| 25 | const [csrfToken, setCsrfToken] = useState(storage.getItem("pd.auth.csrfToken") ?? ""); |
| 26 | |
| 27 | const { showTool } = useDevtoolStore(); |
| 28 | |
| 29 | useEffect(() => { |
| 30 | getCookies(window.location.hostname).then((cookies) => { |
| 31 | setOverleafSession(cookies.session ?? storage.getItem("pd.auth.overleafSession") ?? ""); |
| 32 | setGclb(cookies.gclb ?? storage.getItem("pd.auth.gclb") ?? ""); |
| 33 | }); |
| 34 | }, []); |
| 35 | |
| 36 | const setProjectId_ = useCallback((projectId: string) => { |
| 37 | storage.setItem("pd.projectId", projectId); |
| 38 | setProjectId(projectId); |
| 39 | }, []); |
| 40 | |
| 41 | const setOverleafSession_ = useCallback((overleafSession: string) => { |
| 42 | storage.setItem("pd.auth.overleafSession", overleafSession); |
| 43 | setOverleafSession(overleafSession); |
| 44 | }, []); |
| 45 | |
| 46 | const setGclb_ = useCallback((gclb: string) => { |
| 47 | storage.setItem("pd.auth.gclb", gclb); |
| 48 | setGclb(gclb); |
| 49 | }, []); |
| 50 | |
| 51 | const setCsrfToken_ = useCallback((csrfToken: string) => { |
| 52 | storage.setItem("pd.auth.csrfToken", csrfToken); |
| 53 | setCsrfToken(csrfToken); |
| 54 | // Update meta tag in DOM |
| 55 | updateCsrfTokenMeta(csrfToken); |
| 56 | }, []); |
| 57 | |
| 58 | return ( |
| 59 | <main className="flex flex-row gap-2"> |
| 60 | <div className="flex flex-col gap-2 max-w-xl p-4 bg-slate-50 rounded-lg border-slate-200 border"> |
| 61 | <div className="flex flex-col gap-2"> |
| 62 | <VariableInput |
| 63 | title="Project ID" |
| 64 | description="Overleaf → URL → /projectId" |
| 65 | value={projectId} |
| 66 | setValue={setProjectId_} |
| 67 | /> |
| 68 | <VariableInput |
| 69 | title="Overleaf Session" |
| 70 | description="Overleaf → Request Headers → Cookie → overleaf_session2" |
| 71 | value={overleafSession} |
| 72 | setValue={setOverleafSession_} |
| 73 | /> |
| 74 | <VariableInput |
| 75 | title="GCLB" |
| 76 | description="Overleaf → Request Headers → Cookie → GCLB" |
| 77 | value={gclb} |
nothing calls this directly
no test coverage detected