diff --git a/cypress/e2e/login.cy.ts b/cypress/e2e/login.cy.ts index 8e0ce459..0b3e099d 100644 --- a/cypress/e2e/login.cy.ts +++ b/cypress/e2e/login.cy.ts @@ -30,8 +30,8 @@ describe("Login Page", () => { cy.get("body").then(($body) => { if ($body.find("form#login").length > 0) { cy.get("form#login", { timeout: 10000 }).within(() => { - cy.get("input#identifier", { timeout: 5000 }).should("exist"); - cy.get("input#password", { timeout: 5000 }).should("exist"); + cy.get('input[name="identifier"]', { timeout: 5000 }).should("exist"); + cy.get('input[name="password"]', { timeout: 5000 }).should("exist"); }); cy.get('button[form="login"]', { timeout: 5000 }).should("be.visible"); @@ -54,15 +54,9 @@ describe("Login Page", () => { }); it("should display floating labels correctly", () => { - cy.get('label[for="identifier"]').should("exist"); - - cy.get("input#identifier").should("be.visible"); - - cy.get("input#identifier").type("root@goteo.org"); - - cy.get("input#identifier").should("have.value", "root@goteo.org"); - - cy.get('label[for="identifier"]').should("be.visible"); + cy.get('input[name="identifier"]').should("be.visible"); + cy.get('input[name="identifier"]').type("root@goteo.org"); + cy.get('input[name="identifier"]').should("have.value", "root@goteo.org"); }); it("should validate form fields appropriately", () => { diff --git a/eslint.config.js b/eslint.config.js index a8738f27..432ad4d6 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,6 +3,7 @@ import importPlugin from "eslint-plugin-import"; import globals from "globals"; import tseslint from "typescript-eslint"; import cypressPlugin from "eslint-plugin-cypress"; +import unusedImportsPlugin from "eslint-plugin-unused-imports"; /** @type {import('eslint').Linter.Config[]} */ export default [ @@ -19,6 +20,8 @@ export default [ ".astro/**", ".astro/**/*", "openapi/client/**", + ".github/**", + "env.d.ts", ], }, { files: ["**/*.{js,mjs,cjs,ts}"] }, @@ -28,6 +31,7 @@ export default [ { plugins: { import: importPlugin, + "unused-imports": unusedImportsPlugin, }, rules: { "import/order": [ @@ -48,6 +52,7 @@ export default [ }, ], "@typescript-eslint/no-explicit-any": "off", + "unused-imports/no-unused-imports": "error", }, }, // Cypress configuration diff --git a/package.json b/package.json index 38d6e47e..c2d72e5c 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "marked": "^15.0.12", "media-icons": "^1.1.5", "svelte": "^5.33.13", + "tailwind-merge": "^3.3.1", "tailwindcss": "^4.1.8", "typescript": "^5.8.3" }, @@ -51,6 +52,7 @@ "eslint": "^9.28.0", "eslint-plugin-cypress": "^5.0.1", "eslint-plugin-import": "^2.31.0", + "eslint-plugin-unused-imports": "^4.2.0", "flowbite": "^3.1.2", "flowbite-svelte": "1.5.2", "flowbite-svelte-icons": "^2.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 949d0924..95397fef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -56,6 +56,9 @@ importers: svelte: specifier: ^5.33.13 version: 5.33.13 + tailwind-merge: + specifier: ^3.3.1 + version: 3.3.1 tailwindcss: specifier: ^4.1.8 version: 4.1.8 @@ -90,6 +93,9 @@ importers: eslint-plugin-import: specifier: ^2.31.0 version: 2.31.0(@typescript-eslint/parser@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2)) + eslint-plugin-unused-imports: + specifier: ^4.2.0 + version: 4.2.0(@typescript-eslint/eslint-plugin@8.33.1(@typescript-eslint/parser@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2)) flowbite: specifier: ^3.1.2 version: 3.1.2(rollup@4.36.0) @@ -1761,6 +1767,15 @@ packages: '@typescript-eslint/parser': optional: true + eslint-plugin-unused-imports@4.2.0: + resolution: {integrity: sha512-hLbJ2/wnjKq4kGA9AUaExVFIbNzyxYdVo49QZmKCnhk5pc9wcYRbfgLHvWJ8tnsdcseGhoUAddm9gn/lt+d74w==} + peerDependencies: + '@typescript-eslint/eslint-plugin': ^8.0.0-0 || ^7.0.0 || ^6.0.0 || ^5.0.0 + eslint: ^9.0.0 || ^8.0.0 + peerDependenciesMeta: + '@typescript-eslint/eslint-plugin': + optional: true + eslint-scope@8.3.0: resolution: {integrity: sha512-pUNxi75F8MJ/GdeKtVLSbYg4ZI34J6C0C7sbL4YOp2exGwen7ZsuBqKzUhXd0qMQ362yET3z+uPwKeg/0C2XCQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -3462,8 +3477,8 @@ packages: tailwind-merge@3.0.2: resolution: {integrity: sha512-l7z+OYZ7mu3DTqrL88RiKrKIqO3NcpEO8V/Od04bNpvk0kiIFndGEoqfuzvj4yuhRkHKjRkII2z+KS2HfPcSxw==} - tailwind-merge@3.3.0: - resolution: {integrity: sha512-fyW/pEfcQSiigd5SNn0nApUOxx0zB/dm6UDU/rEwc2c3sX2smWUNbapHv+QRqLGVp9GWX3THIa7MUGPo+YkDzQ==} + tailwind-merge@3.3.1: + resolution: {integrity: sha512-gBXpgUm/3rp1lMZZrM/w7D8GKqshif0zAymAhbCyIt8KMe+0v9DQ7cdYLR4FHH/cKpdTXb+A/tKKU3eolfsI+g==} tailwind-variants@1.0.0: resolution: {integrity: sha512-2WSbv4ulEEyuBKomOunut65D8UZwxrHoRfYnxGcQNnHqlSCp2+B7Yz2W+yrNDrxRodOXtGD/1oCcKGNBnUqMqA==} @@ -5744,6 +5759,12 @@ snapshots: - eslint-import-resolver-webpack - supports-color + eslint-plugin-unused-imports@4.2.0(@typescript-eslint/eslint-plugin@8.33.1(@typescript-eslint/parser@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2)): + dependencies: + eslint: 9.28.0(jiti@2.4.2) + optionalDependencies: + '@typescript-eslint/eslint-plugin': 8.33.1(@typescript-eslint/parser@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3) + eslint-scope@8.3.0: dependencies: esrecurse: 4.3.0 @@ -5962,7 +5983,7 @@ snapshots: dependencies: clsx: 2.1.1 svelte: 5.33.13 - tailwind-merge: 3.3.0 + tailwind-merge: 3.3.1 flowbite-svelte@1.5.2(rollup@4.36.0)(svelte@5.33.13)(tailwindcss@4.1.8): dependencies: @@ -5972,7 +5993,7 @@ snapshots: clsx: 2.1.1 flowbite: 3.1.2(rollup@4.36.0) svelte: 5.33.13 - tailwind-merge: 3.3.0 + tailwind-merge: 3.3.1 tailwind-variants: 1.0.0(tailwindcss@4.1.8) tailwindcss: 4.1.8 transitivePeerDependencies: @@ -7851,7 +7872,7 @@ snapshots: tailwind-merge@3.0.2: {} - tailwind-merge@3.3.0: {} + tailwind-merge@3.3.1: {} tailwind-variants@1.0.0(tailwindcss@4.1.8): dependencies: diff --git a/src/actions/payment.ts b/src/actions/payment.ts index 37f3b8ec..e1d5fd0e 100644 --- a/src/actions/payment.ts +++ b/src/actions/payment.ts @@ -1,35 +1,12 @@ import { z } from "astro/zod"; import { ActionError, defineAction } from "astro:actions"; -import { apiGatewayCheckoutsPost, apiGatewaysGetCollection } from "../openapi/client/index.ts"; +import { apiGatewayCheckoutsPost } from "../openapi/client/index.ts"; import { getDefaultCurrency } from "../utils/consts.ts"; -import type { GatewayCharge, ApiGatewaysNameGetResponse } from "../openapi/client/index.ts"; +import type { GatewayCharge } from "../openapi/client/index.ts"; const defaultCurrency = getDefaultCurrency(); -async function getPaymentGateways(): Promise { - if (import.meta.env.NODE_ENV === "test" || process.env.NODE_ENV === "test") { - return [{ name: "test-gateway" }] as ApiGatewaysNameGetResponse[]; - } - - try { - const response = await apiGatewaysGetCollection(); - const paymentGateways: ApiGatewaysNameGetResponse[] | undefined = response.data; - - if (!paymentGateways) { - throw new Error("Payment gateways not found"); - } - - return paymentGateways; - } catch (error) { - console.error("Error fetching payment gateways:", error); - // En caso de error, devolver un gateway por defecto o re-lanzar según necesites - throw error; - } -} - -let cachedPaymentGateways: ApiGatewaysNameGetResponse[] | null = null; -let cachedPaymentGatewayNames: string[] | null = null; export const payment = defineAction({ accept: "form", @@ -61,23 +38,6 @@ export const payment = defineAction({ const { t } = context.locals; try { - if (!cachedPaymentGateways) { - cachedPaymentGateways = await getPaymentGateways(); - cachedPaymentGatewayNames = cachedPaymentGateways - .map((gateway) => gateway.name) - .filter((name): name is string => name !== undefined); - } - - if ( - cachedPaymentGatewayNames === null || - !cachedPaymentGatewayNames.includes(input.paymentMethod) - ) { - throw new ActionError({ - code: "BAD_REQUEST", - message: t("payment.error.invalidPaymentMethod"), - }); - } - const cart = input.cartData; const charges: GatewayCharge[] = cart.items.map((item) => ({ type: "single", @@ -115,8 +75,6 @@ export const payment = defineAction({ }, }); - console.log({ response }); - return { success: true, checkout: response.data }; } catch (err) { console.error(err); diff --git a/src/components/Admin/ActionsBtn.svelte b/src/components/Admin/ActionsBtn.svelte index 9b24f7e6..e5932187 100644 --- a/src/components/Admin/ActionsBtn.svelte +++ b/src/components/Admin/ActionsBtn.svelte @@ -5,21 +5,21 @@
diff --git a/src/components/Admin/ContentFooter.svelte b/src/components/Admin/ContentFooter.svelte index db4427a4..ce6990c5 100644 --- a/src/components/Admin/ContentFooter.svelte +++ b/src/components/Admin/ContentFooter.svelte @@ -44,11 +44,11 @@ {/if}
-

+

{$t("contributions.grid.content-footer.downloadDetails")}

{$t("contributions.grid.content-footer.annotations", { diff --git a/src/components/Admin/DetailsRow.svelte b/src/components/Admin/DetailsRow.svelte index 2d93fef2..268afbf3 100644 --- a/src/components/Admin/DetailsRow.svelte +++ b/src/components/Admin/DetailsRow.svelte @@ -59,7 +59,7 @@

{$t("contributions.grid.details.operationTime")}

@@ -68,7 +68,7 @@

{$t("contributions.grid.details.trackingCodes.title")}

@@ -322,7 +322,7 @@ type="button" onclick={handleExportCSV} disabled={isExporting} - class="relative inline-flex cursor-pointer items-center gap-2 rounded-2xl bg-[#E6E5F7] px-4 py-2 font-medium text-nowrap text-gray-700 transition-colors disabled:cursor-not-allowed disabled:opacity-50" + class="bg-purple-tint relative inline-flex cursor-pointer items-center gap-2 rounded-2xl px-4 py-2 font-medium text-nowrap text-gray-700 transition-colors disabled:cursor-not-allowed disabled:opacity-50" > {#if isExporting} diff --git a/src/components/Admin/Pagination.svelte b/src/components/Admin/Pagination.svelte index 7da21e92..0e9a4714 100644 --- a/src/components/Admin/Pagination.svelte +++ b/src/components/Admin/Pagination.svelte @@ -39,26 +39,26 @@ … + … {:else} {#if total > 0} - + {@html $t("contributions.pagination.showing", { items, total }, { allowHTML: true })} {:else if total === 0 && !isLoading} - + {@html $t("contributions.pagination.noResults")} {:else} - + {@html $t("contributions.pagination.unloaded")} {/if} diff --git a/src/components/Admin/Search.svelte b/src/components/Admin/Search.svelte index 7c17624a..70aedc42 100644 --- a/src/components/Admin/Search.svelte +++ b/src/components/Admin/Search.svelte @@ -100,7 +100,7 @@ oninput={(e) => handleInput(e.target instanceof HTMLInputElement ? e.target.value : "")} placeholder={$t("contributions.filters.search.placeholder")} - class="border-tertiary w-full rounded-3xl border p-4" + class="border-secondary w-full rounded-3xl border p-4" minlength="4" /> {#if query} diff --git a/src/components/Admin/Slider.svelte b/src/components/Admin/Slider.svelte index 30b64e27..3159ce2a 100644 --- a/src/components/Admin/Slider.svelte +++ b/src/components/Admin/Slider.svelte @@ -44,17 +44,17 @@
{#if !isLoaded}
- Cargando... + Cargando...
{/if} diff --git a/src/components/Admin/Table.svelte b/src/components/Admin/Table.svelte index 0a363aab..9b23669c 100644 --- a/src/components/Admin/Table.svelte +++ b/src/components/Admin/Table.svelte @@ -507,12 +507,12 @@
-

+

{$t("contributions.filters.order.title")}

@@ -540,10 +540,10 @@
- + {#each tableHeaders as header} handleHeaderClick(header)} > @@ -579,44 +579,46 @@ toggleRow(i)} class="{openRow === i - ? 'bg-[#FAF9FF]' - : 'bg-white'} border border-[#e6e5f7] transition-colors hover:bg-[#FAF9FF]" + ? 'bg-soft-purple]' + : 'bg-white'} border-purple-tint hover:bg-soft-purple] border transition-colors" > {charge.targetDisplayName} {#if charge.money.amount && charge.money.currency} - + {formatCurrency(charge.money.amount, charge.money.currency)} {:else} - — + — {/if} - {charge.originDisplayName} - + {$t(`contributions.table.rows.payments.${charge.paymentMethod}`)} - + {getDate(charge.dateCreated).date}

{charge.trackingCodes[0]?.value || "—"}

- + - {charge.refundToWallet}
@@ -624,7 +626,7 @@
{#each Object.entries($groupedByOwner) as [target, items]}
-

+

{$t("project.owner")} {$displayNames[target] ?? ""}

diff --git a/src/components/Checkout/CartItem.svelte b/src/components/Checkout/CartItem.svelte index 38b61354..e44fb797 100644 --- a/src/components/Checkout/CartItem.svelte +++ b/src/components/Checkout/CartItem.svelte @@ -29,11 +29,11 @@ {/if}
-

+

{formatCurrency(item.amount, item.currency)}

-

{item.title}

-

+

{item.title}

+

{#if typeof item.claimed === "number"} {#if item.claimed > 0} {item.claimed} {$t("checkout.reward.claimed")} @@ -53,7 +53,7 @@

- {item.quantity}
@@ -81,7 +81,7 @@ id={`reward-checkbox-${item.key}`} class="accent-primary h-6 w-6 rounded" /> -
--> diff --git a/src/components/Checkout/FeedbackForm.svelte b/src/components/Checkout/FeedbackForm.svelte index 427c6029..dba5c442 100644 --- a/src/components/Checkout/FeedbackForm.svelte +++ b/src/components/Checkout/FeedbackForm.svelte @@ -8,7 +8,7 @@
-

+

{$t("payment.page-aproved.form-goal.title")}

@@ -35,7 +35,7 @@ type="radio" name="type" value="organization" - class="relative h-6 w-6 appearance-none rounded-full border border-[#855a96] after:absolute after:top-1/2 after:left-1/2 after:hidden after:h-2 after:w-2 after:-translate-x-1/2 after:-translate-y-1/2 after:transform after:rounded-full after:bg-purple-900 after:content-[''] checked:border-teal-400 checked:bg-teal-400 checked:after:block" + class="border-secondary relative h-6 w-6 appearance-none rounded-full border after:absolute after:top-1/2 after:left-1/2 after:hidden after:h-2 after:w-2 after:-translate-x-1/2 after:-translate-y-1/2 after:transform after:rounded-full after:bg-purple-900 after:content-[''] checked:border-teal-400 checked:bg-teal-400 checked:after:block" />
-

+

{$t("payment.page-aproved.form-review.title")}

-

{$t("payment.page-aproved.form-review.description")}

+

{$t("payment.page-aproved.form-review.description")}

@@ -74,7 +74,7 @@ name="messageType" value="public" bind:group={messageType} - class="relative h-6 w-6 appearance-none rounded-full border border-[#855a96] after:absolute after:top-1/2 after:left-1/2 after:hidden after:h-2 after:w-2 after:-translate-x-1/2 after:-translate-y-1/2 after:transform after:rounded-full after:bg-purple-900 after:content-[''] checked:border-teal-400 checked:bg-teal-400 checked:after:block" + class="border-secondary relative h-6 w-6 appearance-none rounded-full border after:absolute after:top-1/2 after:left-1/2 after:hidden after:h-2 after:w-2 after:-translate-x-1/2 after:-translate-y-1/2 after:transform after:rounded-full after:bg-purple-900 after:content-[''] checked:border-teal-400 checked:bg-teal-400 checked:after:block" /> Dejar un mensaje de forma pública @@ -87,7 +87,7 @@