When the user clicks a project on /projects, and then clicks
"New task" the project that has been clicked should persist to
the "New task" page.
This commit is contained in:
0x1eef 2024-04-25 02:16:48 -03:00
parent 97486320cb
commit a34c48b26c

View file

@ -16,6 +16,14 @@ export function App({ children }: PropsWithChildren<{}>) {
const cookies = Object.fromEntries(
document.cookie.split(";").map(e => e.split("=")),
);
/* allowlist: param keys acceptable as cookie keys */
const allowlist = ["projectId"];
Object.entries(params).forEach(([key, value]) => {
if (allowlist.includes(key) && cookies[key] !== value &&
/^[0-9A-Za-z]+$/.test(String(value))) {
document.cookie = `${key}=${value}; path=/`;
}
});
return (
<AppContext.Provider value={{ params, cookies }}>
<ApolloProvider client={client}>{children}</ApolloProvider>