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-select": "^2.1.1",
"@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.0", "@radix-ui/react-tabs": "^1.1.0",
"@supabase/supabase-js": "^2.45.1",
"@vercel/postgres": "^0.9.0", "@vercel/postgres": "^0.9.0",
"canvas-confetti": "^1.9.3", "canvas-confetti": "^1.9.3",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",

View File

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

View File

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