Skip to content

Commit 9565a7c

Browse files
committed
FIX: Carregando numero de keys geradas corretamente
1 parent 78e8074 commit 9565a7c

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

index.html

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<section class="stats" aria-label="Estatísticas">
7474
<div class="scard">
7575
<div class="slabel">Keys geradas (30 dias)</div>
76-
<div class="sval">358</div>
76+
<div class="sval" id="keys">Carregando</div>
7777
<div class="sunit">chaves válidas entregues</div>
7878
</div>
7979
<div class="scard">
@@ -162,6 +162,31 @@ <h2 class="atitle" id="sobre-titulo">O que é o GreenScripts HUB?</h2>
162162

163163
</div>
164164

165+
<script>
166+
const keysDiv = document.getElementById('keys')
167+
getNumOfKeys();
168+
169+
async function getNumOfKeys() {
170+
const URL = 'https://btdbraicotnkhfkexwyh.supabase.co/functions/v1/ReturnGenerateKeys'
171+
const anomKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJ0ZGJyYWljb3Rua2hma2V4d3loIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Nzc1MDY2MjcsImV4cCI6MjA5MzA4MjYyN30.ftV4X0vN3NRHJhsIyI_z4D0rm8sGPxVtwzhOux1jykA'
172+
173+
const response = await fetch(URL,
174+
{method: 'GET',
175+
headers: {'Authorization': `Bearer ${anomKey}`, 'Content-Type': 'application/json'}}
176+
)
177+
178+
if(!response.ok)
179+
{
180+
keysDiv.innerText = '173'
181+
}
182+
183+
const data = await response.json()
184+
keysDiv.innerText = data.totalKeys
185+
}
186+
187+
</script>
188+
189+
165190
<script type="module">
166191
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
167192

0 commit comments

Comments
 (0)