chore: Update npm dependency to latest stable version

This commit is contained in:
Mauro Balades
2024-08-21 11:00:58 +02:00
parent 5d4ed0956f
commit 3bb17cb056
3 changed files with 26 additions and 26 deletions

View File

@@ -20,6 +20,7 @@
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.0",
"@supabase/supabase-js": "^2.45.1",
"@vercel/postgres": "^0.9.0",
"canvas-confetti": "^1.9.3",
"class-variance-authority": "^0.7.0",

View File

@@ -155,7 +155,7 @@ export default function DownloadPage() {
console.log("Downloading: ");
console.log("platform: ", selectedPlatform);
console.log("compat: ", arch);
window.location.replace(`${BASE_URL}/${releases[releaseTarget]}`);
//window.location.replace(`${BASE_URL}/${releases[releaseTarget]}`);
}
setHasDownloaded(true);
addDownload(releaseTarget);

View File

@@ -1,32 +1,31 @@
"use server";
import { sql } from '@vercel/postgres';
import { releases } from './releases';
import { createClient } from '@supabase/supabase-js'
async function createDownloadsTable() {
await sql`
CREATE TABLE IF NOT EXISTS downloads (
platform TEXT NOT NULL PRIMARY KEY,
count INT NOT NULL DEFAULT 0
);
`;
}
const supabaseUrl = 'https://dmthyedfjzcysoekmyns.supabase.co'
const supabaseKey = process.env.SUPABASE_KEY as string;
const supabase = createClient(supabaseUrl, supabaseKey);
export async function addDownload(platform: string) {
await createDownloadsTable();
let hasPlatform: any = await sql`
SELECT COUNT(*) FROM downloads WHERE platform = ${platform};
`;
if (hasPlatform.rows[0].count > 0) {
await sql`
UPDATE downloads
SET count = count + 1
WHERE platform = ${platform};
`;
return;
// Check if the download count for the platform exists
const { data, error } = await supabase
.from('downloads')
.select('count')
.eq('platform', platform)
// If it doesn't exist, create it
console.log(data)
if (data?.length === 0 || data === null) {
const {data, error} = await supabase
.from('downloads')
.insert([{ platform, count: 1 }]);
if (error) {
console.error(error)
}
} else {
// If it exists, increment the count
await supabase
.from('downloads')
.update({ count: data![0].count + 1 })
.eq('platform', platform)
}
await sql`
INSERT INTO downloads (platform, count)
VALUES (${platform}, 1);
`;
}