Skip to content

Commit

Permalink
#135 Added Council.ts and fixed small bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Jan 24, 2023
1 parent d36f17d commit 9951318
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/components/elements/CouncilComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
<div align="center">
<div class="InfoContainer">
<info-component
v-if="councilId != null"
class="ELement Info"
:current-card="card"
/>
<div
v-if="councilId != null"
class="ELement"
>
<CardComponent
Expand All @@ -14,6 +16,7 @@
/>
</div>
<div
v-if="councilId == null"
class="ELement"
>
<img
Expand Down
50 changes: 50 additions & 0 deletions src/model/Council.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Council = void 0;
const Coin_1 = require("./Coin");
class Council {
constructor() {
this.hashResponses = [];
this.clearResponses = [];
}
static from(json) {
let council = Object.assign(new Council(), json);
console.log(json);
council.hoshResponses = json.hoshResponses?.map(resp => {
return WrapHashResponse.from(resp);
});
council.clearResponses = json.clearResponses?.map(resp => {
return WrapClearResponse.from(resp);
});
council.treasury = Coin_1.Coin.from(json.treasury);
council.status = CouncelingStatus[json.status];
return council;
}
}
exports.Council = Council;
class WrapClearResponse {
static from(json) {
return Object.assign(new WrapClearResponse(), json);
}
}
class WrapHashResponse {
static from(json) {
return Object.assign(new WrapHashResponse(), json);
}
}
var Response;
(function (Response) {
Response[Response["Yes"] = 0] = "Yes";
Response[Response["No"] = 1] = "No";
Response[Response["Suggestion"] = 2] = "Suggestion";
})(Response || (Response = {}));
var CouncelingStatus;
(function (CouncelingStatus) {
CouncelingStatus[CouncelingStatus["councilDoesNotExist"] = 0] = "councilDoesNotExist";
CouncelingStatus[CouncelingStatus["councilOpen"] = 1] = "councilOpen";
CouncelingStatus[CouncelingStatus["councilCreated"] = 2] = "councilCreated";
CouncelingStatus[CouncelingStatus["councilClosed"] = 3] = "councilClosed";
CouncelingStatus[CouncelingStatus["commited"] = 4] = "commited";
CouncelingStatus[CouncelingStatus["revealed"] = 5] = "revealed";
CouncelingStatus[CouncelingStatus["suggestionsMade"] = 6] = "suggestionsMade";
})(CouncelingStatus || (CouncelingStatus = {}));
60 changes: 60 additions & 0 deletions src/model/Council.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Coin } from "./Coin";

export class Council {
cardId: number
voters: Array<string>
hashResponses: Array<WrapHashResponse> = []
clearResponses: Array<WrapClearResponse> = []
treasury: Coin
status: CouncelingStatus
trialStart: number

static from(json) {
let council = Object.assign(new Council(), json);
console.log(json)
council.hoshResponses = json.hoshResponses?.map(resp => {
return WrapHashResponse.from(resp)
})
council.clearResponses = json.clearResponses?.map(resp => {
return WrapClearResponse.from(resp)
})
council.treasury = Coin.from(json.treasury)
council.status = CouncelingStatus[json.status]
return council
}
}

class WrapClearResponse {
user: string
response: Response
suggestion: string

static from(json) {
return Object.assign(new WrapClearResponse(), json);
}
}

class WrapHashResponse {
user: string
hash: string

static from(json) {
return Object.assign(new WrapHashResponse(), json);
}
}

enum Response {
Yes,
No,
Suggestion,
}

enum CouncelingStatus {
councilDoesNotExist,
councilOpen,
councilCreated,
councilClosed,
commited,
revealed,
suggestionsMade,
}
4 changes: 3 additions & 1 deletion src/model/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class CouncilParticipation {
this.status = "";
}
static from(json) {
return Object.assign(new CouncilParticipation(), json);
let cp = Object.assign(new CouncilParticipation(), json);
cp.council = parseInt(json.council);
return cp;
}
}
4 changes: 3 additions & 1 deletion src/model/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class CouncilParticipation {
status: string = ""

static from(json) {
return Object.assign(new CouncilParticipation(), json);
let cp = Object.assign(new CouncilParticipation(), json);
cp.council = parseInt(json.council)
return cp
}
}

0 comments on commit 9951318

Please sign in to comment.