Skip to content

Commit

Permalink
fix: fixed action qr code
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasflopes committed Nov 25, 2024
1 parent 5212375 commit b6dd291
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const nextConfig = {
remotePatterns: [
{
protocol: "https",
hostname: "*.storage.googleapis.com",
hostname: "*.storage.googleapis.com/**",
},
{
protocol: "https",
Expand Down
28 changes: 16 additions & 12 deletions src/app/(admin)/actions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ const actions: React.FC = async () => {
<table className="w-full table-auto border-collapse overflow-x-scroll">
<thead className="bg-gray-200 text-sm uppercase text-gray-700">
<tr>
<th className="px-2 py-3 text-left">Name</th>
<th className="px-2 py-3 text-left">Points</th>
<th className="px-2 py-3 text-left">Alt Text</th>
<th className="px-2 py-3 text-left">Live</th>
<th className="px-2 py-3 text-left">Visible</th>
<th className="px-2 py-3 text-left">Action</th>
<th className="px-2 py-3 text-left md:px-6">Name</th>
<th className="px-2 py-3 text-left md:px-6">Points</th>
<th className="px-2 py-3 text-left md:px-6">Alt Text</th>
<th className="px-2 py-3 text-left md:px-6">Live</th>
<th className="px-2 py-3 text-left md:px-6">Visible</th>
<th className="px-2 py-3 text-left md:px-6">Action</th>
</tr>
</thead>
<tbody className="text-base text-gray-600">
Expand All @@ -32,12 +32,16 @@ const actions: React.FC = async () => {
key={action.id}
className="border-b transition-colors hover:bg-gray-100"
>
<td className="px-2 py-4">{action.name}</td>
<td className="px-2 py-4">{action.points}</td>
<td className="px-2 py-4">{action.altText || "N/A"}</td>
<td className="px-2 py-4">{action.isLive ? "Yes" : "No"}</td>
<td className="px-2 py-4">{action.isVisible ? "Yes" : "No"}</td>
<td className="px-2 py-4">
<td className="px-2 py-4 md:px-6">{action.name}</td>
<td className="px-2 py-4 md:px-6">{action.points}</td>
<td className="px-2 py-4 md:px-6">{action.altText || "N/A"}</td>
<td className="px-2 py-4 md:px-6">
{action.isLive ? "Yes" : "No"}
</td>
<td className="px-2 py-4 md:px-6">
{action.isVisible ? "Yes" : "No"}
</td>
<td className="px-2 py-4 md:px-6">
<Link
href={`/actions/${action.id}`}
className="text-blue-500 hover:underline"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Action/ActionQrCodeData/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ActionQrCodeData: React.FC<ActionQrCodeDataProps> = ({ id }) => {
}, [id]);

return (
<div>
<div className="bg-white p-2">
{qrCodeData && (
<QRCode
size={innerWidth ? Math.min(innerWidth / 2, 520) : 320}
Expand Down
9 changes: 8 additions & 1 deletion src/components/QRCode/QRCodeTab/ScanTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ const ScanTab: React.FC<ScanTabProps> = ({ setHidden }) => {
async function handleActionScan(data: string) {
const actionId = data.split("-")[1];

await fetch(BASE_URL + `/actions/${actionId}`, {
const res = await fetch(BASE_URL + `/actions/${actionId}`, {
method: "POST",
body: JSON.stringify({ data }),
});

if (!res.ok) {
swal("Erro", "Ocorreu um erro a dar scan no QR Code da ação...", "error");
return;
}

swal("Sucesso", "Os teus pontos foram adicionados com sucesso!", "success");

setHidden(true);
setProcessing(false);
}
Expand Down

0 comments on commit b6dd291

Please sign in to comment.