-
Notifications
You must be signed in to change notification settings - Fork 73
(Post feedback version) GS Onboarding #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1b81099
Data validation for commands
GabrielGuirguis 14feae2
Complete remaining onboarding tasks
GabrielGuirguis fda6f11
Made fixes according to PR review, updated logger
GabrielGuirguis f415bed
Update frontend according to tasks
GabrielGuirguis efa1cd7
Update frontend to better handle errors
GabrielGuirguis da545ce
Update frontend to match functionality
GabrielGuirguis 1b88801
Fixed minor issues with logger, data and table
GabrielGuirguis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| export interface CommandRequest { | ||
| name: string | ||
| command_type: string | ||
| params: string | null | ||
| format: string | null | ||
| } | ||
|
|
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,30 +1,77 @@ | ||
| import "./command_input.css" | ||
| import { useEffect, useState } from "react"; | ||
| import { MainCommandResponse } from "../data/response"; | ||
| import "./command_input.css"; | ||
| import { createCommand, getMainCommands } from "./input_api"; | ||
| import { CommandRequest } from "../data/request"; | ||
|
|
||
| const CommandInput = () => { | ||
| // TODO: (Member) Setup state and useEffect calls here | ||
| const [mainCommands, setMainCommands] = useState<MainCommandResponse[]>([]); | ||
|
|
||
| const handleSubmit = () => { | ||
| // TODO:(Member) Submit to your post endpoint | ||
| } | ||
| const [selectedCommandId, setSelectedCommandId] = useState<string | null>( | ||
| null | ||
| ); | ||
| const [commandParams, setCommandParams] = useState<string | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| const getMainCommandsFn = async () => { | ||
| try { | ||
| const data = await getMainCommands(); | ||
| setMainCommands(data.data); | ||
| setSelectedCommandId(data.data[0].id.toString()); | ||
| } catch (error) { | ||
| alert("Failed to retrieve main commands"); | ||
| } | ||
| }; | ||
|
|
||
| getMainCommandsFn(); | ||
| }, []); | ||
|
|
||
| const handleSubmit = (e: React.FormEvent) => { | ||
| e.preventDefault(); | ||
|
|
||
| console.log("submitting command"); | ||
|
|
||
| if (!selectedCommandId) { | ||
| alert(`Select a command with an existing ID before submitting`); | ||
| return; | ||
| } | ||
|
|
||
| const command: CommandRequest = { | ||
| command_type: selectedCommandId, | ||
| params: commandParams, | ||
| }; | ||
|
|
||
| try { | ||
| createCommand(command); | ||
| window.location.reload(); | ||
| } catch (err) { | ||
| console.log("Failed to create command:", err); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <form> | ||
| <form onSubmit={handleSubmit}> | ||
| <div className="spreader"> | ||
| <div> | ||
| <label>Command Type: </label> | ||
| <select>{/* TODO: (Member) Display the list of commands based on the get commands request*/} | ||
| <option value={"1"}>Command 1</option> | ||
| <option value={"2"}>Command 2</option> | ||
| <option value={"3"}>Command 3</option> | ||
| <select onChange={(e) => setSelectedCommandId(e.target.value)}> | ||
| {/* TODO: (Member) Display the list of commands based on the get commands request*/} | ||
| {mainCommands.map((command, index) => ( | ||
| <option key={index} value={command.id}> | ||
| {command.name} | ||
| </option> | ||
| ))} | ||
| </select> | ||
| </div> | ||
| <input /> {/* TODO: (Member) Add input handling here if the selected command has a param input*/} | ||
| <button onClick={handleSubmit}>Submit</button> | ||
| <input onChange={(e) => setCommandParams(e.target.value)} />{" "} | ||
| {/* TODO: (Member) Add input handling here if the selected command has a param input*/} | ||
| <button type="submit">Submit</button> | ||
| </div> | ||
| </form> | ||
| </> | ||
| ) | ||
| } | ||
| ); | ||
| }; | ||
|
|
||
| export default CommandInput; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each command can have different types and number of arguments and the frontend should be able to handle that. They are encoded in the mainCommands