-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improvements on the nextJS demo
- Loading branch information
1 parent
1805cd8
commit d38e3ee
Showing
14 changed files
with
345 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useMountedApp } from "@/reducers/store"; | ||
|
||
export function PageHeader({ children }) { | ||
const app = useMountedApp(); | ||
|
||
const agent = app.agent.instance; | ||
const handleStart = async () => { | ||
if (agent) { | ||
app.startAgent({ agent }) | ||
} | ||
}; | ||
|
||
const handleStop = async () => { | ||
if (agent) { | ||
app.stopAgent({ agent }) | ||
} | ||
}; | ||
|
||
return <> | ||
|
||
<div className="flex justify-left"> | ||
<div className="mx-2 my-5 inline-flex items-center justify-center px-5 py-3 text-base font-medium text-center text-white"> | ||
|
||
{children} | ||
</div> | ||
<p className="mx-2 my-5 inline-flex items-center justify-center px-5 py-3 text-base font-medium text-center text-white"> | ||
<b>Status:</b> {app.agent.instance?.state ?? 'stopped'} | ||
</p> | ||
{app.agent.instance?.state === "stopped" && ( | ||
<div className="mx-2 my-5 inline-flex px-5 py-3 items-center justify-center "> | ||
<button className="px-5 py-3 text-base font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-900" style={{ width: 120 }} onClick={handleStart}>Start</button> | ||
</div> | ||
)} | ||
|
||
{app.agent.instance?.state === "running" && ( | ||
<div className="mx-2 my-5 inline-flex px-5 py-3 items-center justify-center "> | ||
<button className="px-5 py-3 text-base font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-900" style={{ width: 120 }} onClick={handleStop}>Stop</button> | ||
</div> | ||
)} | ||
</div> | ||
|
||
|
||
|
||
</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.