Introduce Edit actions #8

Merged
maxime.batista merged 10 commits from editor/bootstrap into master 1 year ago

This PR introduces the actions to create and edit tactics.

actions added :

GET:/tactic/new -- create a new tactic
GET:/tactic/[i:id]/edit -- edit a specific tactic by its identifier 
This PR introduces the actions to create and edit tactics. actions added : ``` GET:/tactic/new -- create a new tactic GET:/tactic/[i:id]/edit -- edit a specific tactic by its identifier ```
maxime.batista added 3 commits 1 year ago
clement.freville2 requested changes 1 year ago
clement.freville2 left a comment

PHP and JavaScript often use the camelCase naming convention.

PHP and JavaScript often use the camelCase naming convention.
/**
* This constant defines the API endpoint.
*/
export const API = import.meta.env.VITE_API_ENDPOINT;

This does not pass the TypeScript type checking. Add "types": ["vite/client"], to the tsconfig.json.

This does not pass the TypeScript type checking. Add `"types": ["vite/client"],` to the `tsconfig.json`.
maxime.batista marked this conversation as resolved
//FIXME avoid absolute path as they would not work on staging server
fetch(`${API}/tactic/${id}/edit/name`, {
method: "POST",
body: JSON.stringify({

It is recommended to specify the Content-Type of the request:

        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
It is recommended to specify the `Content-Type` of the request: ```js headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, ```
maxime.batista marked this conversation as resolved
package.json Outdated
"@types/node": "^16.18.59",
"@types/react": "^18.2.31",
"@types/react-dom": "^18.2.14",
"node-promises": "^0.2.1",
-     "node-promises": "^0.2.1",

This module is not used.

```diff - "node-promises": "^0.2.1", ``` This module is not used.
maxime.batista marked this conversation as resolved
if ($match == null) {
echo "404 not found";
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
-     echo "404 not found";
-     header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
+     http_response_code(404);
+     header('Content-type: application/json');
+     echo '{ "error": "404 not found" }';

Headers must be sent before the body.

```diff - echo "404 not found"; - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); + http_response_code(404); + header('Content-type: application/json'); + echo '{ "error": "404 not found" }'; ``` Headers must be sent before the body.
maxime.batista marked this conversation as resolved
exit(1);
}
call_user_func_array($match['target'], $match['params']);
header('Content-type: application/json');

The API only return JSON, so it can be specified here.

```php header('Content-type: application/json'); ``` The API only return JSON, so it can be specified here.
maxime.batista marked this conversation as resolved
CREATE TABLE TacticInfo(
id integer PRIMARY KEY AUTOINCREMENT,
name varchar,
creation_date timestamp
-     creation_date timestamp
+     creation_date timestamp DEFAULT CURRENT_TIMESTAMP
```diff - creation_date timestamp + creation_date timestamp DEFAULT CURRENT_TIMESTAMP ```
maxime.batista marked this conversation as resolved
return $this->name;
}
public function getCreationDate(): int {
-     public function getCreationDate(): int { 
+     public function getCreationTimestamp(): int { 
```diff - public function getCreationDate(): int { + public function getCreationTimestamp(): int { ```
maxime.batista marked this conversation as resolved
$this->con = $con;
}
public function get(int $id): TacticInfo {

This should return ?TacticInfo, the id will not always be found in the database.

This should return `?TacticInfo`, the id will not always be found in the database.
maxime.batista marked this conversation as resolved
"INSERT INTO TacticInfo(name, creation_date) VALUES(:name, CURRENT_TIMESTAMP)",
[":name" => [$name, PDO::PARAM_STR]]
);
$row = $this->con->fetch("SELECT id, creation_date FROM TacticInfo ORDER BY id DESC LIMIT 1", [])[0];

You may be interested in using PDO::lastInsertId.

You may be interested in using [PDO::lastInsertId](https://www.php.net/manual/en/pdo.lastinsertid.php).
maxime.batista marked this conversation as resolved
plugins: [
react()
react(),
cssInjectedByJsPlugin({

Couldn't the CSS be a standalone file (bundled by Vite) and not integrated in JS?

Couldn't the CSS be a standalone file (bundled by Vite) and not integrated in JS?
maxime.batista added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
1f261fe4fe
avoid use of 'RETURNING' sql clause
maxime.batista added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
29685562bb
add TacticModel
maxime.batista added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
f8e8e642d3
validate user inputs
maxime.batista added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
cccc68e3ce
apply suggestion
maxime.batista requested review from yanis.dahmane-bounoua 1 year ago
maxime.batista requested review from vivien.dufour 1 year ago
maxime.batista requested review from mael.daim 1 year ago
maxime.batista requested review from samuel.berion 1 year ago
maxime.batista added 1 commit 1 year ago
maxime.batista added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
b08e761abb
add diagrams, fix documentation
maxime.batista added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
6ee05c7916
add more validations, handle invalid json payloads
vivien.dufour approved these changes 1 year ago
samuel.berion approved these changes 1 year ago
mael.daim approved these changes 1 year ago
maxime.batista merged commit 86373fb81b into master 1 year ago
maxime.batista deleted branch editor/bootstrap 1 year ago

Reviewers

clement.freville2 requested changes 1 year ago
yanis.dahmane-bounoua was requested for review 1 year ago
vivien.dufour approved these changes 1 year ago
samuel.berion approved these changes 1 year ago
mael.daim approved these changes 1 year ago
continuous-integration/drone/push Build is passing
The pull request has been merged as 86373fb81b.
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: IQBall/Application-Web#8
Loading…
There is no content yet.