summaryrefslogtreecommitdiff
path: root/nodejs/lib
diff options
context:
space:
mode:
authorJulien Dessaux2023-09-14 00:02:51 +0200
committerJulien Dessaux2023-09-14 00:02:51 +0200
commit4c1a5fdfe1fb99901a24bfdd9d5c42a6939e6dd8 (patch)
tree4d9a8c6319e718a0cb679af2df34ecc7f8e4cf0b /nodejs/lib
parent[javascript] reworked basic exploration with systems fetch after registering (diff)
downloadspacetraders-4c1a5fdfe1fb99901a24bfdd9d5c42a6939e6dd8.tar.gz
spacetraders-4c1a5fdfe1fb99901a24bfdd9d5c42a6939e6dd8.tar.bz2
spacetraders-4c1a5fdfe1fb99901a24bfdd9d5c42a6939e6dd8.zip
[javascript] improved contract lib
Diffstat (limited to '')
-rw-r--r--nodejs/lib/contracts.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/nodejs/lib/contracts.js b/nodejs/lib/contracts.js
index e4ba2ae..f73f297 100644
--- a/nodejs/lib/contracts.js
+++ b/nodejs/lib/contracts.js
@@ -1,9 +1,16 @@
import * as dbContracts from '../database/contracts.js';
import * as api from './api.js';
import * as dbShips from '../database/ships.js';
+import * as libShips from '../lib/ships.js';
export async function accept(ctx) {
- return await api.send({endpoint: `/my/contracts/${ctx.contract}/accept`, method: 'POST'});
+ const contract = dbContracts.getContract(ctx.id);
+ if (contract.accepted) {
+ return;
+ }
+ await api.send({endpoint: `/my/contracts/${ctx.id}/accept`, method: 'POST'});
+ contract.accepted = true;
+ dbContracts.setContract(contract);
}
export async function contracts() {