Skip to content

Commit

Permalink
Continue on frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarik-Popov committed Oct 5, 2024
1 parent d2069f2 commit a6b16a1
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 35 deletions.
23 changes: 13 additions & 10 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GS Onboarding</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
91 changes: 91 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.7.7",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand Down
Binary file added frontend/public/favicon.ico
Binary file not shown.
27 changes: 2 additions & 25 deletions frontend/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './app.css'
import CommandInput from './input/command_input'

function App() {
const [count, setCount] = useState(0)

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<CommandInput />
</>
)
}
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/data/command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export interface CommandRequest {
name: string
params: string | null
format: string | null
}

export interface CommandResponse {
id: number
name: string
params: string | null
format: string | null
created_on: string
updated_on: string
}
8 changes: 8 additions & 0 deletions frontend/src/data/main_command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface MainCommandResponse {
id: number;
name: string
params: string | null;
format: string | null;
data_size: number;
total_size: number;
}
1 change: 1 addition & 0 deletions frontend/src/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const API_URL = "http://localhost:8000"
17 changes: 17 additions & 0 deletions frontend/src/input/command_input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const CommandInput = () => {
return (
<>
<form>
<label>Command Type: </label>
<select>
<option value="1">Command 1</option>
<option value="2">Command 2</option>
<option value="3">Command 3</option>
</select>
<button type="submit">Submit</button>
</form>
</>
)
}

export default CommandInput;
12 changes: 12 additions & 0 deletions frontend/src/input/input_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { API_URL } from "../environment";
import { CommandRequest, CommandResponse } from "../data/command";
import axios from "axios";

export const createCommand = async (requestData: CommandRequest): Promise<CommandResponse | undefined> => {
try {
const { data } = await axios.post<CommandResponse>(`${API_URL}/commands`, requestData);
return data
} catch (error) {
console.error(error);
}
}

0 comments on commit a6b16a1

Please sign in to comment.