Skip to content

Commit

Permalink
[assistant_builder] - refactor: streamline PrevNextButtons component …
Browse files Browse the repository at this point in the history
…and support tab updates (#9075)

- Refactor the PrevNextButtons component to simplify the logic for navigating between screens
 - Extend PrevNextButtons functionality to update current tab when navigating between screens
  • Loading branch information
JulesBelveze authored Dec 3, 2024
1 parent 49412f1 commit 9a179be
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
6 changes: 5 additions & 1 deletion front/components/assistant_builder/AssistantBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,11 @@ export default function AssistantBuilder({
assertNever(screen);
}
})()}
<PrevNextButtons screen={screen} setScreen={setScreen} />
<PrevNextButtons
screen={screen}
setScreen={setScreen}
setCurrentTab={setCurrentTab}
/>
</div>
}
buttonsRightPanel={
Expand Down
28 changes: 14 additions & 14 deletions front/components/assistant_builder/PrevNextButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import React from "react";

import type { BuilderScreen } from "@app/components/assistant_builder/types";

interface PrevNextButtonsProps {
screen: BuilderScreen;
setScreen: (screen: BuilderScreen) => void;
setCurrentTab: (tab: string) => void;
}

export function PrevNextButtons({
screen,
setScreen,
}: {
screen: BuilderScreen;
setScreen: (screen: BuilderScreen) => void;
}) {
setCurrentTab,
}: PrevNextButtonsProps) {
return (
<div className="flex py-6">
{screen !== "instructions" && (
Expand All @@ -18,11 +22,9 @@ export function PrevNextButtons({
size="md"
variant="highlight"
onClick={() => {
if (screen === "actions") {
setScreen("instructions");
} else if (screen === "naming") {
setScreen("actions");
}
const newScreen = screen === "actions" ? "instructions" : "actions";
setScreen(newScreen);
setCurrentTab(newScreen);
}}
/>
)}
Expand All @@ -33,11 +35,9 @@ export function PrevNextButtons({
size="md"
variant="highlight"
onClick={() => {
if (screen === "instructions") {
setScreen("actions");
} else if (screen === "actions") {
setScreen("naming");
}
const newScreen = screen === "instructions" ? "actions" : "naming";
setScreen(newScreen);
setCurrentTab(newScreen);
}}
/>
)}
Expand Down

0 comments on commit 9a179be

Please sign in to comment.