Fixed id scrolling when clicking from Store

This commit is contained in:
Lucas Oliveira 2024-06-04 11:52:08 -03:00
commit 98e40f25e6
3 changed files with 36 additions and 31 deletions

View file

@ -41,12 +41,23 @@ import {
} from "../../../../types/components"; } from "../../../../types/components";
import { gradients } from "../../../../utils/styleUtils"; import { gradients } from "../../../../utils/styleUtils";
import { useStoreStore } from "../../../../stores/storeStore"; import { useStoreStore } from "../../../../stores/storeStore";
import { useParams } from "react-router-dom";
export default function GeneralPage() { export default function GeneralPage() {
const setCurrentFlowId = useFlowsManagerStore( const setCurrentFlowId = useFlowsManagerStore(
(state) => state.setCurrentFlowId, (state) => state.setCurrentFlowId,
); );
const { scrollId } = useParams();
useEffect(() => {
const element = document.getElementById(scrollId ?? "null");
if (element) {
// 👇 Will scroll smoothly to the top of the next section
element.scrollIntoView({ behavior: "smooth" });
}
}, [scrollId]);
const [inputState, setInputState] = useState<patchUserInputStateType>( const [inputState, setInputState] = useState<patchUserInputStateType>(
CONTROL_PATCH_USER_STATE, CONTROL_PATCH_USER_STATE,
); );
@ -272,9 +283,9 @@ export default function GeneralPage() {
handleSaveKey(); handleSaveKey();
}} }}
> >
<Card x-chunk="dashboard-04-chunk-2"> <Card x-chunk="dashboard-04-chunk-2" id="api">
<CardHeader> <CardHeader>
<CardTitle>API Key</CardTitle> <CardTitle>Store API Key</CardTitle>
<CardDescription> <CardDescription>
{(hasApiKey && !validApiKey {(hasApiKey && !validApiKey
? INVALID_API_KEY ? INVALID_API_KEY

View file

@ -180,9 +180,6 @@ export default function StorePage(): JSX.Element {
title={STORE_TITLE} title={STORE_TITLE}
description={STORE_DESC} description={STORE_DESC}
button={ button={
<>
{StoreApiKeyModal && (
<StoreApiKeyModal disabled={loading}>
<Button <Button
data-testid="api-key-button-store" data-testid="api-key-button-store"
disabled={loading} disabled={loading}
@ -191,13 +188,13 @@ export default function StorePage(): JSX.Element {
loading ? "cursor-not-allowed" : "", loading ? "cursor-not-allowed" : "",
)} )}
variant="primary" variant="primary"
onClick={() => {
navigate("/settings/general/api");
}}
> >
<IconComponent name="Key" className="mr-2 w-4" /> <IconComponent name="Key" className="mr-2 w-4" />
API Key API Key
</Button> </Button>
</StoreApiKeyModal>
)}
</>
} }
> >
<div className="flex h-full w-full flex-col justify-between"> <div className="flex h-full w-full flex-col justify-between">

View file

@ -56,7 +56,7 @@ const Router = () => {
> >
<Route index element={<Navigate replace to={"general"} />} /> <Route index element={<Navigate replace to={"general"} />} />
<Route path="global-variables" element={<GlobalVariablesPage />} /> <Route path="global-variables" element={<GlobalVariablesPage />} />
<Route path="general" element={<GeneralPage />} /> <Route path="general/:scrollId?" element={<GeneralPage />} />
<Route path="shortcuts" element={<ShortcutsPage />} /> <Route path="shortcuts" element={<ShortcutsPage />} />
</Route> </Route>
<Route <Route
@ -80,8 +80,6 @@ const Router = () => {
} }
/> />
<Route path="/playground/:id/"> <Route path="/playground/:id/">
element=
{
<Route <Route
path="" path=""
element={ element={
@ -90,7 +88,6 @@ const Router = () => {
</ProtectedRoute> </ProtectedRoute>
} }
/> />
}
</Route> </Route>
<Route path="/flow/:id/"> <Route path="/flow/:id/">
<Route <Route