Skip to content

Commit

Permalink
Merge pull request #56 from akakou/hotfix/html-bug
Browse files Browse the repository at this point in the history
Hotfix/html bug
  • Loading branch information
akakou authored May 6, 2024
2 parents 3e10ff5 + 2d9d373 commit bd4d863
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"domain": "example.com",
"public_key": "MTIzNA==",
"quote": "MTIzNA==",
"has_activated": true,
"has_activated": false,
"edges": {
"code": {
"id": 1,
"repository": "https://example.com",
"commit_id": "1234",
"unique_id": "MTIzNA==",
"is_active": true,
"is_active": false,
"edges": {}
}
}
Expand Down
9 changes: 6 additions & 3 deletions ttp/serv/views/redirect/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
const checkOneValidity = x => !x.edges.violation

const checkAllValidity = (data) => {
const res = data.reduce((accumulator, current) => accumulator && checkOneValidity(current), true)
return res
if (!data.length) return false

const reduced = data.reduce((accumulator, current) => accumulator && checkOneValidity(current), true)
const last_activated = data[data.length - 1].has_activated
return last_activated && reduced
}

const TableCompornent = ({ logs }) => {
Expand Down Expand Up @@ -71,7 +74,7 @@
const resp = await axios.get(`/api/server/${referrer.hostname}`)
console.log(resp)

const v = checkAllValidity(resp.data)
const v = resp.data.length > 0 && checkAllValidity(resp.data)
setLogs(resp.data)
setIsValid(v)
setMessage(v ? VALID_MESSAGE : INVALID_MESSAGE)
Expand Down

0 comments on commit bd4d863

Please sign in to comment.