feat: DTF customization #1
@@ -27,13 +27,16 @@ openapi-ts*.log
|
||||
# vscode setting folder
|
||||
.vscode/
|
||||
|
||||
# Claude Code
|
||||
# AI skills files
|
||||
CLAUDE.md
|
||||
AGENTS.md
|
||||
|
||||
#Other
|
||||
yarn.lock
|
||||
.wrangler/
|
||||
|
||||
./graphify-out
|
||||
|
||||
.pnpm-store
|
||||
*storybook.log
|
||||
storybook-static
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Goteo v4 Web
|
||||
# DTF's Goteo v4 Web client
|
||||
|
||||
Frontend for the [Goteo](https://goteo.org) crowdfunding platform — built on Astro 7 + Svelte 5 + TailwindCSS 4, deployed on Cloudflare Workers.
|
||||
Frontend for the [DTF](https://democratictech.fund) crowdfunding site — built on Astro 7 + Svelte 5 + TailwindCSS 4, deployed on Cloudflare Workers.
|
||||
|
||||
> **NOTE**: This application is a client of the [Goteo v4 API](https://github.com/goteo/org.goteo.api). You need a running v4 API instance and an OAuth client registered in it before this web app will work.
|
||||
> **NOTE**: This application is a client of the [Goteo v4 API](https://github.com/goteo/v4-api). You need a running v4 API instance and an OAuth client registered in it before this web app will work.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -11,8 +11,8 @@ This application requires [Node.js](https://nodejs.org/en/download) (v22.12 or l
|
||||
### 1. Clone or download this repository.
|
||||
|
||||
```shell
|
||||
git clone https://github.com/goteo/org.goteo.www
|
||||
cd org.goteo.www
|
||||
git clone https://git.coopcloud.tech/DemocraticTech.Fund/crowd-fund-web
|
||||
cd crowd-fund-web
|
||||
```
|
||||
|
||||
### 2. Install the dependencies.
|
||||
|
||||
@@ -99,6 +99,13 @@ export default defineConfig({
|
||||
|
||||
routeRules,
|
||||
|
||||
/**
|
||||
* Shiki colours code blocks with inline `style` attributes, which the CSP below is not
|
||||
* meant to rely on. No Markdown here has code blocks, so highlighting is off. If that
|
||||
* changes, use `"prism"` (class-based) plus a Prism theme stylesheet.
|
||||
*/
|
||||
markdown: { syntaxHighlight: false },
|
||||
|
||||
security: {
|
||||
/**
|
||||
* On a server-rendered page Astro sends this as a `content-security-policy` response
|
||||
@@ -131,7 +138,7 @@ export default defineConfig({
|
||||
*/
|
||||
"img-src 'self' data: blob: https:",
|
||||
"media-src 'self' data: blob: https:",
|
||||
// Karla is self-hosted through the fonts API — nothing else is needed.
|
||||
// Fonts are self-hosted through the fonts API — nothing else is needed.
|
||||
"font-src 'self'",
|
||||
/**
|
||||
* The tight one, and the reason for the whole exercise: this is what data
|
||||
@@ -177,25 +184,31 @@ export default defineConfig({
|
||||
},
|
||||
|
||||
/**
|
||||
* Karla is downloaded from Google at build time and served from our own origin, so no
|
||||
* Fonts are downloaded from Google at build time and served from our own origin, so no
|
||||
* request reaches a third party while a visitor reads a page.
|
||||
*
|
||||
* Karla is a variable font: the whole `200 800` range travels in a single file, which is
|
||||
* why asking for every weight the interface uses costs no extra request. The previous
|
||||
* `@fontsource/karla` import only shipped weight 400, so the ~360 `font-bold`,
|
||||
* `font-medium` and `font-semibold` usages were being faked by the browser.
|
||||
* Atkinson Hyperlegible Next is variable, so interface emphasis can use a true 600 weight.
|
||||
* Load the full range in upright and italic styles.
|
||||
*
|
||||
* `latin-ext` is not optional here: Catalan needs U+0140 (`ŀ`) for the geminate `l·l`.
|
||||
*/
|
||||
fonts: [
|
||||
{
|
||||
provider: fontProviders.google(),
|
||||
name: "Karla",
|
||||
cssVariable: "--font-karla",
|
||||
name: "Atkinson Hyperlegible Next",
|
||||
cssVariable: "--font-atkinson-hyperlegible",
|
||||
weights: ["200 800"],
|
||||
styles: ["normal", "italic"],
|
||||
subsets: ["latin", "latin-ext"],
|
||||
},
|
||||
{
|
||||
provider: fontProviders.google(),
|
||||
name: "Boldonse",
|
||||
cssVariable: "--font-boldonse",
|
||||
weights: [400],
|
||||
styles: ["normal"],
|
||||
subsets: ["latin", "latin-ext"],
|
||||
},
|
||||
],
|
||||
|
||||
vite: {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS proposed_campaigns (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
date_created INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
|
||||
date_updated INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS proposed_campaign_slots (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
proposal_id INTEGER NOT NULL REFERENCES proposed_campaigns(id) ON DELETE CASCADE,
|
||||
tab TEXT NOT NULL CHECK (tab IN ('ending-soon', 'most-successful')),
|
||||
position INTEGER NOT NULL,
|
||||
project_id TEXT NOT NULL,
|
||||
UNIQUE(proposal_id, tab, position)
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
-- Site-wide settings edited from /admin/customize, one JSON document per key
|
||||
-- (e.g. 'footer'). A missing key means the built-in defaults in code apply.
|
||||
-- Timestamps are milliseconds (Date.getTime()), matching the repository layer.
|
||||
CREATE TABLE
|
||||
IF NOT EXISTS site_settings (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL,
|
||||
date_updated INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS theme_colors (
|
||||
id INTEGER PRIMARY KEY CHECK (id = 1),
|
||||
light_colors TEXT NOT NULL DEFAULT '{}',
|
||||
dark_colors TEXT NOT NULL DEFAULT '{}',
|
||||
date_updated INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
-- Header logo managed from /admin/customize/logo
|
||||
-- Timestamps are milliseconds (Date.getTime()), matching the repository layer.
|
||||
-- The header shows the most recently uploaded logo; when the table is empty it
|
||||
-- falls back to the built-in logo.
|
||||
CREATE TABLE
|
||||
IF NOT EXISTS header_logo (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
media_url TEXT NOT NULL,
|
||||
media_type TEXT NOT NULL,
|
||||
alt_text TEXT NOT NULL DEFAULT 'Goteo',
|
||||
date_created INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
|
||||
);
|
||||
@@ -1,2 +1,2 @@
|
||||
-- Seed data for local development
|
||||
-- Apply with: 'npx wrangler d1 execute goteo-db --local --file=./db/seed.sql' or just 'pnpm db:seed'
|
||||
-- Apply with: 'pnpm db:seed'
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
{
|
||||
"name": "goteo",
|
||||
"name": "dtfcrowd",
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"astro": "astro",
|
||||
"build": "astro build",
|
||||
"build:staging": "CLOUDFLARE_ENV=staging astro build --mode staging",
|
||||
"build:prod": "CLOUDFLARE_ENV=prod astro build --mode prod",
|
||||
"deploy:staging": "pnpm build:staging && pnpm wrangler --env staging d1 migrations apply dtfcrowd-db-staging --remote && wrangler deploy --env staging",
|
||||
"deploy:prod": "pnpm build:prod && pnpm wrangler --env prod d1 migrations apply dtfcrowd-db-prod --remote && wrangler deploy --env prod",
|
||||
"check": "prettier --check . --plugin prettier-plugin-astro --plugin prettier-plugin-svelte",
|
||||
"check:astro": "astro check",
|
||||
"check:svelte": "svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:types": "pnpm check:astro && pnpm check:svelte",
|
||||
"db:migrate": "wrangler d1 migrations apply goteov4web-db --local",
|
||||
"db:rebuild": "wrangler d1 execute goteov4web-db --local --command=\"DELETE FROM d1_migrations\" && wrangler d1 migrations apply goteov4web-db --local",
|
||||
"db:seed": "wrangler d1 execute goteov4web-db --local --file=./db/seed.sql",
|
||||
"db:migrate": "wrangler d1 migrations apply dtfcrowd-db --local",
|
||||
"db:rebuild": "wrangler d1 execute dtfcrowd-db --local --command=\"DELETE FROM d1_migrations\" && wrangler d1 migrations apply dtfcrowd-db --local",
|
||||
"db:seed": "wrangler d1 execute dtfcrowd-db --local --file=./db/seed.sql",
|
||||
"dev": "astro dev",
|
||||
"format": "NODE_OPTIONS=\"--max-old-space-size=4096\" eslint --fix . && prettier --write .",
|
||||
"format:eslint": "eslint --fix . ",
|
||||
@@ -44,6 +48,7 @@
|
||||
"bits-ui": "^2.18.1",
|
||||
"chart.js": "^4.5.1",
|
||||
"csrf": "^3.1.0",
|
||||
"dequal": "^2.0.3",
|
||||
"dexie": "^4.4.2",
|
||||
"dinero.js": "^2.0.2",
|
||||
"dotenv": "^17.4.2",
|
||||
@@ -53,6 +58,8 @@
|
||||
"marked": "^18.0.6",
|
||||
"media-icons": "^1.1.5",
|
||||
"murmurhash-js": "^1.0.0",
|
||||
"observable-slim": "^0.2.2",
|
||||
"polished": "^4.3.1",
|
||||
"stdnum": "^1.12.6",
|
||||
"svelte": "^5.56.6",
|
||||
"tailwind-merge": "^3.6.0",
|
||||
|
||||
@@ -5,3 +5,7 @@ allowBuilds:
|
||||
esbuild: true
|
||||
sharp: false
|
||||
workerd: true
|
||||
|
||||
minimumReleaseAgeExclude:
|
||||
- miniflare@5.20261019.1-beta
|
||||
- wrangler@4.151.3
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 2852 620">
|
||||
<!-- Generator: Adobe Illustrator 30.8.2, SVG Export Plug-In . SVG Version: 2.1.4 Build 7) -->
|
||||
<defs>
|
||||
<linearGradient id="warmGradient" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" stop-color="#FF914D"/><stop offset="48%" stop-color="#FF603A"/><stop offset="100%" stop-color="#CF2626"/></linearGradient>
|
||||
<style>
|
||||
.st0 {
|
||||
fill: url(#warmGradient);
|
||||
}
|
||||
|
||||
.st0, .st1 {
|
||||
fill-rule: evenodd;
|
||||
}
|
||||
|
||||
.st1 {
|
||||
fill: #fff;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<path class="st0" d="M1875.14,178v8l2,2v4l2,2v4l2,2v6l2,2v4l2,2v6l2,2v4l2,2v6l2,2v6l2,2v4l2,2v6l2,2v4l2,2v6l2,2v4l2,2v6l2,2v4l2,2v4l2,2v6l2,2v6l4,6v6l2,2v6l2,2v4l2,2v6l2,2v4l2,2v6l2,2v4l2,2v6l2,2v4l2,2v4l2,2v6l2,2v4l2,2,2,10,4,4h88l2-2h2v-4l2-2v-4l2-2v-6l2-2v-6l2-2v-6l2-2v-6l2-2v-4l2-2v-6l2-2v-6l2-2v-4l2-2v-6l2-2v-4l4-6,2,2v6l2,2v6l2,2v4l2,2v6l2,2v4l2,2v6l2,2v6l2,2v6l2,2v6l2,2v6l2,2v6l6,8h92l4-4v-2l2-2v-4l2-2v-6l2-2v-4l2-2v-4l2-2v-4l2-2v-4l2-2v-6l2-2v-4l2-2v-4l2-2v-4l2-2v-4l2-2v-4l2-2v-4l2-2v-6l2-2v-4l2-2v-4l2-2v-6l2-2v-4l2-2v-4l2-2v-6l2-2v-4l2-2v-4l2-2v-4l2-2v-4l2-2v-6l2-2v-4l2-2v-4l2-2v-6l2-2v-4l2-2v-6l2-2v-4l2-2v-6l2-2v-4l2-2v-4l2-2v-4l2-2-2-2v-2h-96l-4,4v8l-2,2v6l-2,2v6l-2,2v6l-2,2v6l-2,2v8l-2,2v6l-2,2v6l-2,2v6l-2,2v6l-2,2v6l-2,2v6l-2,2-2-2v-4l-2-2v-4l-2-2v-6l-2-2v-6l-2-2v-6l-2-2v-6l-2-2v-6l-2-2v-6l-2-2v-6l-2-2v-6l-2-2v-4l-2-2v-8l-2-2v-6l-4-4h-74l-4,4v6l-2,2v6l-2,2v4l-2,2v8l-2,2v6l-2,2v4l-2,2v6l-2,2v8l-2,2v6l-2,2v4l-2,2v6l-2,2v6l-4,6-2-2v-6l-2-2v-6l-2-2v-6l-2-2v-6l-2-2v-6l-2-2v-8l-2-2v-6l-2-2v-6l-2-2v-8l-2-2v-6l-2-2v-6l-2-2v-6l-2-2h-96l-2,2ZM1877.14,240l-2-2-4-10-4-4v-2l-6-6v-2l-14-14h-2l-4-4h-2l-4-4h-2l-4-4h-2l-6-4h-4l-2-2h-2l-2-2h-4l-2-2h-6l-2-2h-8l-2-2h-12l-2-2h-44l-2,2h-12l-2,2h-8l-2,2h-4l-2,2-10,2-2,2-14,6-4,4h-2l-4,4h-2l-20,20v2l-4,4-2,6-4,4v2l-4,6-2-2v-64h-2l-2-2h-14l-2,2h-6l-2,2h-4l-2,2-10,4-4,4h-2l-14,16-2-2v-22l-2-2v-2h-90v2l-2,2v232l4,4h86l4-4v-100l2-2v-10l2-2,2-10,4-4v-2l10-10h2l6-4h4l2-2h24l2,2v8l-2,2v40l2,2v10l2,2v6l2,2,2,10,2,2,6,14,10,12v2l10,10h2l14,12h2l10,6h4l6,4h4l2,2h6l2,2h8l2,2h14l2,2h44l2-2h14l2-2h6l2-2h6l2-2h4l10-6h4l2-2h2l4-4h2l4-4h2l6-6h2l12-12v-2l6-6v-2l6-8v-2l2-2v-4l4-6v-4l2-2v-6l2-2v-6l2-2v-20l2-2v-8l-2-2v-22l-2-2v-8l-2-2v-6l-2-2-2-10ZM1739.14,248h24l8,6h2l8,8v2l6,10v6l2,2v28l-2,2-2,10-6,8v2l-4,4h-2l-4,4h-2l-2,2h-4l-2,2h-18l-2-2h-4l-2-2h-2l-12-12v-2l-4-6v-6l-2-2v-12l-2-2v-4l2-2v-14l2-2v-4l2-2,2-6,12-12h2l6-4ZM1251.14,186l-4,4-6,2-6,6h-2l-18,18v2l-4,4v2l-4,4v2l-4,6v4l-2,2v2l-2,2v4l-2,2v6l-2,2v6l-2,2v14l-2,2v26l2,2v14l2,2v6l2,2v4l2,2,2,10,2,2,4,10,8,10v2l18,18h2l10,8h2l14,8h4l2,2h4l2,2h4l2,2h8l2,2h12l2,2h42l2-2h12l2-2h6l2-2h6l2-2h4l6-4h4l2-2,6-2,10-8h2l18-18v-2l8-10v-2l6-10v-4l2-2v-4l2-2v-8l2-2v-18l-2-2h-86l-4,4-2,10-2,2-2,6-4,4h-2l-4,4h-2l-2,2h-4l-2,2h-16l-2-2h-4l-2-2-6-2-10-10v-2l-4-6v-4l-2-2v-4l-2-2v-32l2-2v-4l2-2v-4l2-2v-2l10-12h2l10-6h22l2,2h4l12,10v2l6,10v8l2,2v2h88l2-2v-22l-2-2v-6l-2-2v-6l-4-6v-4l-2-2-2-6-4-4v-2l-4-4v-2l-12-12h-2l-6-6-10-4-4-4h-4l-2-2h-2l-2-2h-4l-2-2h-6l-2-2h-6l-2-2h-14l-2-2h-44l-2,2h-14l-2,2h-6l-2,2h-6l-2,2h-4l-6,4h-4l-2,2h-2ZM2519.14,102h-92l-2,2v96l-2,2-12-12h-2l-10-8h-2l-2-2h-4l-6-4h-6l-2-2h-6l-2-2h-30l-2,2h-8l-2,2h-6l-2,2h-4l-2,2-14,6-4,4h-2l-4,4h-2l-14,14v2l-6,6v2l-8,10v4l-4,6v4l-2,2v2l-2,2v4l-2,2v6l-2,2v14l-2,2v38l2,2v10l2,2v8l2,2,2,10,4,6v4l2,2,2,6,4,4,2,6,24,24,6,2,8,6h4l6,4h4l2,2h6l2,2h8l2,2h28l2-2h10l2-2h4l2-2h4l2-2h2l4-4h2l8-6h2l12-12,2,2v20l4,4h90l4-4V106l-4-4ZM2375.14,248h14l2,2h4l8,6h2l10,12v2l2,2v4l2,2v6l2,2v16l-2,2v10l-2,2-6,14-12,10h-2l-2,2h-4l-2,2h-14l-2-2h-4l-2-2-6-2-10-10v-2l-2-2v-4l-2-2v-4l-2-2v-10l-2-2v-6l2-2v-14l2-2v-4l2-2v-2l4-4v-2l8-8h2l6-4h4l2-2Z"/>
|
||||
<path class="st1" d="M1063.14,480l-8,6h-2l-12,12v2l-6,10v6l-2,2v16l2,2v6l2,2v4l6,8v2l8,8h2l4,4h2l6,4h6l2,2h22l2-2h6l2-2,6-2,4-4h2l10-10v-2l4-4v-4l2-2v-4l2-2v-22l-2-2v-6l-2-2-2-6-6-6v-2l-2-2h-2l-6-6h-2l-6-4h-4l-2-2h-28l-2,2h-6ZM1077.14,504h14l2,2h2l6,6v2l2,2v6l2,2v6l-2,2v6l-6,8h-2l-6,4h-10l-2-2h-2l-8-8v-2l-2-2v-18l2-2,2-6,8-6ZM955.14,482l-4,4h-2l-12,12v2l-4,6v4l-2,2v10l-2,2v4l2,2v12l2,2v4l2,2,2,6,12,12h2l10,6h6l2,2h20l2-2h6l2-2h4l2-2h2l4-4h2l10-12v-4l2-2v-6h-28l-8,8h-2l-2,2h-10l-10-6-4-10,2-2h64v-20l-2-2v-6l-2-2v-2l-4-4v-2l-12-12h-2l-6-4h-4l-2-2h-28l-2,2h-4l-2,2h-2ZM961.14,514l2-2,2-6,6-4h16l8,6v4l2,2-2,2h-32l-2-2ZM787.14,480l-8,6h-2l-10,10v2l-6,8v4l-2,2v12l-2,2v4l2,2v10l2,2v4l2,2v2l4,4v2l8,8h2l8,6h4l2,2h4l2,2h22l2-2h6l2-2,10-4,14-14v-2l2-2v-4l2-2v-4l2-2v-22l-2-2v-6l-2-2-2-6-10-12h-2l-4-4h-2l-6-4h-4l-2-2h-30l-2,2h-4ZM803.14,504h12l2,2h2l6,6v2l2,2v8l2,2-2,2v10l-10,10h-4l-2,2h-6l-2-2h-4l-8-8v-4l-2-2v-14l2-2v-4l8-8h2l2-2ZM595.14,480h-34v2l-2,2v4l-2,2v6l-2,2v4l-2,2v4l-2,2v4l-2,2v4l-2,2v2l-2,2v4l-2,2-4-4v-4l-2-2v-4l-2-2-2-10-4-6v-4l-2-2v-4l-2-2v-4l-2-2v-2h-10l-2-2h-8l-2,2h-10v6l4,6v4l6,10v4l6,10v4l4,6v4l4,6v4l6,10v4l2,2v2l2,2v4l2,2v4l-8,8h-14v22h32l2-2h2l8-8v-2l6-8v-4l4-6v-4l4-6v-4l2-2v-2l2-2v-4l4-6,2-10,4-6,2-10,4-6v-4l2-2,2-10,2-2v-2l4-6v-4l2-2ZM875.14,452v2l-2,2v22l-2,2h-12v22l2,2h10l2,2v32l2,2v16l2,2v4l8,8h2l6,4h6l2,2h12l2-2h8l2-2v-22l-2-2-2,2h-8l-8-6v-38l2-2h18v-24h-10l-2-2h-6l-2-2v-22l-2-2h-28ZM651.14,452l-18,18v2l-4,4v2l-4,6v6l-2,2v12l-2,2v12l2,2v10l2,2,2,10,6,8v2l14,14h2l14,8h6l2,2h24l2-2h6l2-2,10-4,6-6,2,2v10h24l2-2v-28l-2-2v-38l-2-2h-58l-2,2v6l2,2v16h26l2,2-2,2v4l-8,8h-2l-2,2h-4l-2,2h-14l-2-2h-4l-2-2h-2l-8-8v-2l-6-8v-30l2-2,2-6,8-10h2l6-4h4l2-2h10l2,2h6l2,2h2l8,8v4l2,2h30l2-2v-4l-2-2v-4l-2-2-2-6-4-4v-2l-10-10h-2l-14-8h-6l-2-2h-30l-2,2h-6l-2,2h-4l-2,2-6,2ZM389.14,444v130h28v-8l2-2,6,6h2l6,4h4l2,2h20l6-4h4l4-4h2l8-8v-2l6-8v-4l2-2v-6l2-2v-18l-2-2v-8l-4-6v-4l-6-6v-2l-2-2h-2l-6-6h-2l-6-4h-10l-2-2h-4l-2,2h-6l-2,2h-4l-12,8-2-2v-42h-30ZM433.14,504h14l2,2h2l8,8v4l2,2v16l-8,10h-2l-2,2h-4l-2,2h-4l-2-2h-4l-2-2h-2l-8-8v-4l-2-2v-10l2-2v-4l4-4v-2l8-6ZM667.14,96v80h70l2,2h4l2,2v232l4,4h104l2-2h2v-234l4-4h82v-44l2-2v-16l-2-2v-16h-276ZM385.14,96l-2,2v30l2,2v66l-2,2,2,2-2,2v70l2,2v18l-2,2,2,2v48l-2,2v66l2,2v2h144l2-2h12l2-2h8l2-2h6l2-2h6l2-2h4l6-4h4l2-2,10-4,4-4,6-2,6-6h2l4-4h2l14-14v-2l10-10v-2l8-10v-2l10-18v-4l2-2v-4l2-2v-8l2-2v-6l2-2v-10l2-2v-50l-2-2v-10l-2-2v-8l-2-2v-6l-2-2-2-10-2-2-10-22-6-6v-2l-4-4v-2l-20-20h-2l-6-6h-2l-10-8h-2l-18-10h-4l-6-4h-6l-2-2h-8l-2-2h-8l-2-2h-158ZM481.14,174h34l2,2h12l2,2h4l2,2,10,4,6,6h2l4,4v2l10,10v2l6,10v4l2,2v6l2,2v12l2,2v14l-2,2v16l-2,2v6l-2,2-8,18-16,16h-2l-4,4h-2l-6,4h-4l-2,2h-4l-2,2h-44l-2-2v-156l2-2ZM1193.14,96h-222l-2-2-2,2h-2v318l2,2h98l2-2v-108l2-2h4l2-2h96l2,2,2-2h2v-78h-16l-2-2h-2l-2,2h-4l-2-2h-60l-2,2h-6l-2-2h-10l-2-2v-42l2-2h122l4-4v-4l-2-2v-4l2-2v-30l-2-2,2-2v-2l-2-2v-26Z"/>
|
||||
<polygon class="st0" points="111.12 581 113.12 579 115.12 579 129.12 565 129.12 563 133.12 557 133.12 553 135.12 551 135.12 545 137.12 543 137.12 423 139.12 421 199.12 481 201.12 481 219.12 499 221.12 499 223.12 501 227.12 501 229.12 503 233.12 503 235.12 505 257.12 505 259.12 503 263.12 503 265.12 501 275.12 497 289.12 483 289.12 481 295.12 471 295.12 467 297.12 465 297.12 443 295.12 441 295.12 437 293.12 435 291.12 429 287.12 425 287.12 423 227.12 363 225.12 363 211.12 347 213.12 345 303.12 345 305.12 343 311.12 343 313.12 341 317.12 341 325.12 335 327.12 335 335.12 327 335.12 325 343.12 315 343.12 311 345.12 309 345.12 299 347.12 297 347.12 291 345.12 289 345.12 283 343.12 281 341.12 271 337.12 267 337.12 265 327.12 255 325.12 255 321.12 251 317.12 251 315.12 249 311.12 249 309.12 247 301.12 247 299.12 245 253.12 245 251.12 247 231.12 247 229.12 245 213.12 245 211.12 243 257.12 197 259.12 197 259.12 195 271.12 183 273.12 183 285.12 171 285.12 169 291.12 163 291.12 161 295.12 155 295.12 151 297.12 149 297.12 125 295.12 123 295.12 119 289.12 111 289.12 109 275.12 95 273.12 95 267.12 91 263.12 91 261.12 89 251.12 89 249.12 87 243.12 87 241.12 89 233.12 89 231.12 91 227.12 91 225.12 93 219.12 95 205.12 109 203.12 109 139.12 173 137.12 171 137.12 63 135.12 61 135.12 55 133.12 53 133.12 49 127.12 41 127.12 39 117.12 29 115.12 29 105.12 23 101.12 23 99.12 21 73.12 21 71.12 23 67.12 23 65.12 25 59.12 27 43.12 43 43.12 45 39.12 51 39.12 57 37.12 59 37.12 551 39.12 553 39.12 557 45.12 565 45.12 567 55.12 577 57.12 577 61.12 581 111.12 581"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 2.1 MiB |
|
After Width: | Height: | Size: 2.8 MiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="801" height="245" viewBox="0 0 801 245" fill="none">
|
||||
<path d="M0.295532 143.456V31.9801H16.543V48.8293L14.5873 44.9179C17.5961 40.3044 21.6078 36.6938 26.6224 34.0862C31.6371 31.4786 37.3538 30.1748 43.7725 30.1748C51.4951 30.1748 58.4153 32.0302 64.5332 35.7411C70.7513 39.4519 75.6156 44.5167 79.1258 50.9354C82.7364 57.3542 84.5416 64.5753 84.5416 72.5987C84.5416 80.6222 82.7364 87.8433 79.1258 94.262C75.6156 100.681 70.8015 105.796 64.6836 109.607C58.5657 113.318 51.5954 115.173 43.7725 115.173C37.4541 115.173 31.6872 113.869 26.472 111.262C21.3571 108.654 17.3955 104.893 14.5873 99.9787L17.2952 96.8195V143.456H0.295532ZM42.1177 99.377C46.9318 99.377 51.1942 98.2236 54.9051 95.9168C58.6159 93.6101 61.5244 90.4509 63.6305 86.4392C65.837 82.3271 66.9402 77.7137 66.9402 72.5987C66.9402 67.4838 65.837 62.9205 63.6305 58.9087C61.5244 54.897 58.6159 51.7378 54.9051 49.4311C51.1942 47.1243 46.9318 45.9709 42.1177 45.9709C37.4039 45.9709 33.1415 47.1243 29.3303 49.4311C25.6195 51.7378 22.6609 54.897 20.4544 58.9087C18.3483 62.9205 17.2952 67.4838 17.2952 72.5987C17.2952 77.7137 18.3483 82.3271 20.4544 86.4392C22.6609 90.4509 25.6195 93.6101 29.3303 95.9168C33.1415 98.2236 37.4039 99.377 42.1177 99.377Z" fill="#141414"/>
|
||||
<path d="M641.82 244.518V133.043H658.068V149.892L656.112 145.98C659.121 141.367 663.132 137.756 668.147 135.149C673.162 132.541 678.878 131.237 685.297 131.237C693.02 131.237 699.94 133.093 706.058 136.804C712.276 140.514 717.14 145.579 720.65 151.998C724.261 158.417 726.066 165.638 726.066 173.661C726.066 181.685 724.261 188.906 720.65 195.325C717.14 201.743 712.326 206.858 706.208 210.669C700.09 214.38 693.12 216.236 685.297 216.236C678.979 216.236 673.212 214.932 667.997 212.324C662.882 209.717 658.92 205.956 656.112 201.041L658.82 197.882V244.518H641.82ZM683.642 200.439C688.456 200.439 692.719 199.286 696.43 196.979C700.14 194.673 703.049 191.513 705.155 187.502C707.362 183.39 708.465 178.776 708.465 173.661C708.465 168.546 707.362 163.983 705.155 159.971C703.049 155.96 700.14 152.8 696.43 150.494C692.719 148.187 688.456 147.033 683.642 147.033C678.928 147.033 674.666 148.187 670.855 150.494C667.144 152.8 664.185 155.96 661.979 159.971C659.873 163.983 658.82 168.546 658.82 173.661C658.82 178.776 659.873 183.39 661.979 187.502C664.185 191.513 667.144 194.673 670.855 196.979C674.666 199.286 678.928 200.439 683.642 200.439Z" fill="#141414"/>
|
||||
<path d="M770.057 216.236C761.733 216.236 754.412 214.18 748.093 210.068C741.875 205.956 737.512 200.439 735.005 193.519L748.093 187.351C750.3 191.965 753.308 195.625 757.119 198.333C761.031 201.041 765.343 202.395 770.057 202.395C774.069 202.395 777.329 201.493 779.836 199.687C782.343 197.882 783.597 195.425 783.597 192.316C783.597 190.31 783.045 188.705 781.942 187.502C780.839 186.198 779.435 185.145 777.73 184.342C776.125 183.54 774.47 182.938 772.765 182.537L759.978 178.927C752.957 176.921 747.692 173.912 744.182 169.9C740.772 165.788 739.067 161.024 739.067 155.608C739.067 150.694 740.32 146.432 742.828 142.821C745.335 139.11 748.795 136.252 753.208 134.246C757.621 132.24 762.585 131.237 768.102 131.237C775.523 131.237 782.143 133.093 787.96 136.804C793.777 140.414 797.889 145.479 800.296 151.998L787.207 158.166C785.603 154.255 783.045 151.145 779.535 148.839C776.125 146.532 772.264 145.379 767.951 145.379C764.24 145.379 761.282 146.281 759.075 148.087C756.869 149.792 755.766 152.048 755.766 154.856C755.766 156.762 756.267 158.367 757.27 159.67C758.273 160.874 759.577 161.877 761.181 162.679C762.786 163.381 764.441 163.983 766.146 164.484L779.385 168.396C786.104 170.301 791.269 173.31 794.88 177.422C798.49 181.434 800.296 186.248 800.296 191.864C800.296 196.678 798.992 200.941 796.384 204.652C793.877 208.262 790.367 211.121 785.853 213.227C781.34 215.233 776.075 216.236 770.057 216.236Z" fill="#141414"/>
|
||||
<path d="M286.863 216.236C278.739 216.236 271.518 214.38 265.199 210.669C258.981 206.858 254.017 201.743 250.306 195.325C246.695 188.906 244.89 181.635 244.89 173.511C244.89 165.487 246.695 158.266 250.306 151.848C253.917 145.429 258.881 140.414 265.199 136.804C271.518 133.093 278.739 131.237 286.863 131.237C292.379 131.237 297.544 132.24 302.358 134.246C307.172 136.152 311.334 138.809 314.844 142.219C318.455 145.629 321.113 149.591 322.818 154.104L307.924 161.024C306.219 156.812 303.461 153.452 299.65 150.945C295.939 148.337 291.677 147.033 286.863 147.033C282.249 147.033 278.087 148.187 274.376 150.494C270.766 152.7 267.907 155.859 265.801 159.971C263.695 163.983 262.642 168.546 262.642 173.661C262.642 178.776 263.695 183.39 265.801 187.502C267.907 191.513 270.766 194.673 274.376 196.979C278.087 199.286 282.249 200.439 286.863 200.439C291.777 200.439 296.04 199.186 299.65 196.678C303.361 194.071 306.119 190.611 307.924 186.298L322.818 193.369C321.213 197.681 318.605 201.593 314.995 205.103C311.485 208.513 307.323 211.221 302.508 213.227C297.694 215.233 292.479 216.236 286.863 216.236Z" fill="#141414"/>
|
||||
<path d="M376.698 216.236C368.875 216.236 361.704 214.38 355.185 210.669C348.766 206.959 343.651 201.894 339.84 195.475C336.029 189.056 334.124 181.785 334.124 173.661C334.124 165.437 336.029 158.166 339.84 151.848C343.651 145.429 348.766 140.414 355.185 136.804C361.604 133.093 368.775 131.237 376.698 131.237C384.721 131.237 391.892 133.093 398.211 136.804C404.63 140.414 409.694 145.429 413.405 151.848C417.216 158.166 419.122 165.437 419.122 173.661C419.122 181.885 417.216 189.207 413.405 195.625C409.594 202.044 404.479 207.109 398.06 210.82C391.642 214.43 384.521 216.236 376.698 216.236ZM376.698 200.439C381.512 200.439 385.775 199.286 389.485 196.979C393.196 194.673 396.105 191.513 398.211 187.502C400.417 183.39 401.521 178.776 401.521 173.661C401.521 168.546 400.417 163.983 398.211 159.971C396.105 155.96 393.196 152.8 389.485 150.494C385.775 148.187 381.512 147.033 376.698 147.033C371.984 147.033 367.722 148.187 363.911 150.494C360.2 152.8 357.241 155.96 355.035 159.971C352.929 163.983 351.876 168.546 351.876 173.661C351.876 178.776 352.929 183.39 355.035 187.502C357.241 191.513 360.2 194.673 363.911 196.979C367.722 199.286 371.984 200.439 376.698 200.439Z" fill="#141414"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M585.897 131.237C593.92 131.237 601.091 133.093 607.409 136.804C613.828 140.414 618.893 145.429 622.604 151.848C626.415 158.166 628.32 165.437 628.32 173.661C628.32 181.885 626.415 189.207 622.604 195.625C618.793 202.044 613.678 207.109 607.259 210.82C600.84 214.43 593.719 216.236 585.897 216.236H475.727C467.904 216.236 460.733 214.38 454.214 210.669C447.795 206.958 442.68 201.894 438.869 195.475C435.058 189.056 433.152 181.785 433.152 173.661C433.152 165.437 435.058 158.166 438.869 151.848C442.68 145.429 447.795 140.414 454.214 136.804C460.633 133.093 467.804 131.237 475.727 131.237H585.897ZM598.684 196.979C594.973 199.286 590.711 200.439 585.897 200.439H475.727C471.013 200.439 466.75 199.286 462.939 196.979C459.228 194.673 456.27 191.513 454.063 187.502C451.957 183.39 450.904 178.776 450.904 173.661C450.904 168.546 451.957 163.983 454.063 159.971C456.27 155.96 459.228 152.8 462.939 150.494C466.75 148.187 471.013 147.033 475.727 147.033H585.897C590.711 147.033 594.973 148.187 598.684 150.494C602.395 152.8 605.303 155.96 607.409 159.971C609.616 163.983 610.719 168.546 610.719 173.661C610.719 178.776 609.616 183.39 607.409 187.502C605.303 191.513 602.395 194.673 598.684 196.979Z" fill="#141414"/>
|
||||
<path d="M121.961 115.268C113.737 115.268 107.568 113.412 103.456 109.701C99.4448 105.991 97.4389 100.324 97.4389 92.7018V0.482422H114.439V91.3478C114.439 97.4657 117.748 100.525 124.368 100.525H125.27V115.268H121.961Z" fill="#141414"/>
|
||||
<path d="M164.752 116.172C159.236 116.172 154.371 115.22 150.159 113.314C146.047 111.308 142.838 108.6 140.531 105.19C138.224 101.68 137.071 97.5681 137.071 92.8544C137.071 88.4415 138.024 84.4799 139.929 80.9697C141.935 77.4594 144.994 74.5008 149.106 72.0937C153.218 69.6867 158.383 67.9817 164.601 66.9788L192.884 62.3152V75.7043L167.911 80.067C163.398 80.8694 160.088 82.3236 157.982 84.4298C155.876 86.4356 154.823 89.0433 154.823 92.2526C154.823 95.3617 155.976 97.9192 158.283 99.925C160.69 101.831 163.749 102.783 167.46 102.783C172.073 102.783 176.085 101.78 179.495 99.7746C183.005 97.7687 185.713 95.111 187.618 91.8013C189.524 88.3913 190.477 84.6304 190.477 80.5184V65.324C190.477 60.1087 188.922 55.9967 185.813 52.9879C182.704 49.8789 178.291 48.3243 172.575 48.3243H145.345V32.9795H173.327C180.447 32.9795 186.515 34.2833 191.53 36.8909C196.645 39.3982 200.556 43.0088 203.264 47.7226C206.072 52.4363 207.476 58.1029 207.476 64.7222V114.367H191.229V99.6242L194.689 100.075C192.784 103.385 190.326 106.243 187.318 108.651C184.409 111.058 181.049 112.913 177.238 114.217C173.527 115.521 169.365 116.172 164.752 116.172Z" fill="#141414"/>
|
||||
<path d="M257.138 115.266C248.613 115.266 241.994 112.859 237.28 108.045C232.566 103.231 230.209 96.4612 230.209 87.7357V48.3206H215.917V32.9758H218.174C221.985 32.9758 224.944 31.8726 227.05 29.6661C229.156 27.4597 230.209 24.4509 230.209 20.6397V14.3213H247.209V32.9758H265.713V48.3206H247.209V86.9835C247.209 89.7917 247.66 92.1987 248.563 94.2046C249.465 96.1102 250.92 97.6146 252.926 98.7178C254.931 99.7207 257.539 100.222 260.748 100.222C261.551 100.222 262.453 100.172 263.456 100.072C264.459 99.9715 265.412 99.8712 266.315 99.7709V114.363C264.911 114.564 263.356 114.765 261.651 114.965C259.946 115.166 258.442 115.266 257.138 115.266Z" fill="#141414"/>
|
||||
<path d="M293.06 114.365V48.3222H278.017V32.9773H293.06V28.765C293.06 22.6472 294.314 17.5322 296.821 13.4202C299.329 9.20791 302.789 5.99853 307.202 3.79209C311.715 1.58564 316.88 0.482422 322.697 0.482422C323.8 0.482422 325.054 0.582714 326.458 0.783297C327.862 0.883594 329.016 1.03403 329.918 1.23462V15.9777C329.116 15.7771 328.213 15.6768 327.21 15.6768C326.207 15.5765 325.405 15.5264 324.803 15.5264C320.29 15.5264 316.679 16.5794 313.972 18.6856C311.264 20.6914 309.91 24.0513 309.91 28.765V32.9773H328.564V48.3222H309.91V114.365H293.06Z" fill="#141414"/>
|
||||
<path d="M376.699 116.169C368.876 116.169 361.705 114.314 355.186 110.603C348.767 106.892 343.652 101.827 339.841 95.4085C336.03 88.9898 334.125 81.7185 334.125 73.5948C334.125 65.3708 336.03 58.0996 339.841 51.7811C343.652 45.3624 348.767 40.3477 355.186 36.7372C361.605 33.0263 368.776 31.1709 376.699 31.1709C384.722 31.1709 391.893 33.0263 398.212 36.7372C404.63 40.3477 409.695 45.3624 413.406 51.7811C417.217 58.0996 419.123 65.3708 419.123 73.5948C419.123 81.8188 417.217 89.1402 413.406 95.559C409.595 101.978 404.48 107.043 398.061 110.753C391.643 114.364 384.522 116.169 376.699 116.169ZM376.699 100.373C381.513 100.373 385.775 99.2197 389.486 96.9129C393.197 94.6062 396.106 91.447 398.212 87.4352C400.418 83.3232 401.521 78.7098 401.521 73.5948C401.521 68.4799 400.418 63.9165 398.212 59.9048C396.106 55.8931 393.197 52.7339 389.486 50.4271C385.775 48.1204 381.513 46.967 376.699 46.967C371.985 46.967 367.723 48.1204 363.912 50.4271C360.201 52.7339 357.242 55.8931 355.036 59.9048C352.929 63.9165 351.876 68.4799 351.876 73.5948C351.876 78.7098 352.929 83.3232 355.036 87.4352C357.242 91.447 360.201 94.6062 363.912 96.9129C367.723 99.2197 371.985 100.373 376.699 100.373Z" fill="#141414"/>
|
||||
<path d="M433.152 114.365V32.9769H449.4V49.3748L447.895 46.9678C449.7 41.6522 452.609 37.8411 456.621 35.5344C460.632 33.1273 465.446 31.9238 471.063 31.9238H476.027V47.4191H468.957C463.34 47.4191 458.777 49.1742 455.267 52.6845C451.857 56.0944 450.152 61.0088 450.152 67.4275V114.365H433.152Z" fill="#141414"/>
|
||||
<path d="M488.621 114.367V32.9795H574.522C581.643 32.9795 587.711 34.2833 592.725 36.8909C597.84 39.3982 601.752 43.0088 604.46 47.7226C607.268 52.4363 608.672 58.1029 608.672 64.7222V114.367H591.672V65.324C591.672 60.1087 590.118 55.9967 587.009 52.9879C584 49.8789 579.838 48.3243 574.522 48.3243H557.071V114.367H540.222V48.3243H505.621V114.367H488.621Z" fill="#141414"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 76 KiB |
@@ -1,125 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.0" id="Livello_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 282.7 181.9" enable-background="new 0 0 282.7 181.9" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#1D1D1B" d="M41.9,49.8v-2.2c0-4.5-3.6-7.7-9.7-7.7c-6.8,0-10.7,4.3-10.3,11.1L5.7,49.3c-0.8-15.4,11.4-24,26.1-24
|
||||
c17.2,0,27,8.9,27,22.8v42.2H42v-6.2c-2.6,4.5-7.9,8.1-15.2,8.1C13.1,92.3,5.5,83,5.5,73.4c0-12,8.1-18.7,24.3-21.4L41.9,49.8z
|
||||
M41.9,64.8v-2.8l-9.8,1.8c-6.1,1.2-9.6,3.2-9.6,7.5c0,3.6,3.1,6.1,7.7,6.1C37.1,77.3,41.9,72.4,41.9,64.8z"/>
|
||||
<path fill="#1D1D1B" d="M71.2,0h18.1v90.3H71.2V0z"/>
|
||||
<path fill="#1D1D1B" d="M146.6,32.8V0h18.1v90.3h-18.1v-5.6c-4.8,5-11,7.5-18.7,7.5c-16.6,0-28.9-14.8-28.9-33.4
|
||||
c0-18.7,12.3-33.6,28.9-33.6C135.6,25.3,141.8,27.7,146.6,32.8z M146.6,58.9c0-9.4-5.9-16.3-14.7-16.3c-8.8,0-14.8,7-14.8,16.3
|
||||
c0,9.4,6.1,16.1,14.8,16.1C140.6,75,146.6,68.1,146.6,58.9z"/>
|
||||
<path fill="#1D1D1B" d="M211.6,49.8v-2.2c0-4.5-3.6-7.7-9.7-7.7c-6.8,0-10.7,4.3-10.3,11.1l-16.1-1.7c-0.8-15.4,11.4-24,26.1-24
|
||||
c17.2,0,27,8.9,27,22.8v42.2h-16.8v-6.2c-2.6,4.5-7.9,8.1-15.2,8.1c-13.7,0-21.3-9.3-21.3-18.8c0-12,8.1-18.7,24.3-21.4
|
||||
L211.6,49.8z M211.6,64.8v-2.8l-9.8,1.8c-6.1,1.2-9.5,3.2-9.5,7.5c0,3.6,3.1,6.1,7.7,6.1C206.8,77.3,211.6,72.4,211.6,64.8z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#FDC608" d="M242.1,9.2l12.4,4.1V0h12v13.3L279,9.2l3.9,11.5l-12.5,4.1l7.7,10.6l-9.7,7.2l-7.9-10.7l-8,10.7l-9.7-7.2
|
||||
l7.9-10.6l-12.5-4.1L242.1,9.2z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#1D1D1B" d="M72.4,155.7v-14.8h10v1.3h-8.6v5.3h7.7v1.3h-7.7v5.6h8.6v1.3H72.4z"/>
|
||||
<path fill="#1D1D1B" d="M92.8,145.6v10.1h-1.4v-1.4c-0.8,1.1-1.9,1.8-3.5,1.8c-2.2,0-3.5-1.4-3.5-3.8v-6.6h1.4v6.3
|
||||
c0,1.9,0.8,2.8,2.5,2.8c1.9,0,3.1-1.4,3.1-3.7v-5.4H92.8z"/>
|
||||
<path fill="#1D1D1B" d="M95.7,155.7v-10.1h1.4v1.2c0.6-1,1.5-1.5,2.7-1.5c1.8,0,3.2,1.4,3.2,3.6l0,0.4l-1.4,0.2c0-0.3,0-0.4,0-0.5
|
||||
c0-1.5-0.8-2.3-2-2.3c-1.5,0-2.5,1.2-2.5,3.3v5.8H95.7z"/>
|
||||
<path fill="#1D1D1B" d="M114.6,150.7c0,3-2.1,5.3-5.2,5.3c-3.1,0-5.2-2.3-5.2-5.3c0-3,2.2-5.4,5.2-5.4
|
||||
C112.5,145.3,114.6,147.6,114.6,150.7z M113.3,150.7c0-2.3-1.6-4.1-3.8-4.1c-2.2,0-3.8,1.8-3.8,4.1c0,2.3,1.6,4,3.8,4
|
||||
C111.7,154.7,113.3,153,113.3,150.7z"/>
|
||||
<path fill="#1D1D1B" d="M116.9,160.5v-14.8h1.4v1.7c0.8-1.3,2.2-2,3.9-2c2.8,0,4.8,2.3,4.8,5.3s-2,5.4-4.8,5.4
|
||||
c-1.7,0-3-0.8-3.9-2.1v6.5H116.9z M125.6,150.6c0-2.3-1.5-4-3.7-4c-2.1,0-3.7,1.7-3.7,4c0,2.3,1.5,4.1,3.7,4.1
|
||||
C124.1,154.7,125.6,152.9,125.6,150.6z"/>
|
||||
<path fill="#1D1D1B" d="M138,149.9v0.8h-8.1c0.1,2.4,1.6,4,3.7,4c1.7,0,3-1.1,3.3-2.8l1.4,0.2c-0.3,2.3-2.2,3.8-4.6,3.8
|
||||
c-3,0-5.1-2.2-5.1-5.3c0-3.1,2-5.4,4.9-5.4C136.2,145.3,138,147.2,138,149.9z M136.6,149.5c0-1.7-1.3-2.9-3.1-2.9
|
||||
c-1.8,0-3.1,1.2-3.5,2.9H136.6z"/>
|
||||
<path fill="#1D1D1B" d="M146.8,149.3v-0.5c0-1.3-0.9-2.2-2.6-2.2c-1.7,0-2.6,1-2.6,2.5l0,0.3l-1.4-0.1c-0.1-2.6,1.6-4,3.9-4
|
||||
c2.6,0,4,1.4,4,3.6v6.8h-1.3v-1.4c-0.7,1.1-1.8,1.7-3.2,1.7c-2.4,0-3.5-1.5-3.5-3c0-1.9,1.3-2.9,3.8-3.3L146.8,149.3z M146.8,151.3
|
||||
v-0.8l-2.7,0.4c-1.8,0.3-2.7,0.9-2.7,2c0,1.1,0.9,1.8,2.4,1.8C145.6,154.7,146.8,153.4,146.8,151.3z"/>
|
||||
<path fill="#1D1D1B" d="M151,155.7v-10.1h1.4v1.4c0.8-1.1,1.9-1.8,3.5-1.8c2.2,0,3.5,1.4,3.5,3.8v6.6H158v-6.3
|
||||
c0-1.9-0.8-2.8-2.5-2.8c-1.9,0-3.1,1.4-3.1,3.7v5.4H151z"/>
|
||||
<path fill="#1D1D1B" d="M166.6,155.7l6.1-14.8h1.6l6.1,14.8h-1.5l-1.9-4.6h-7l-1.9,4.6H166.6z M170.5,149.8h5.9l-3-7.3L170.5,149.8
|
||||
z"/>
|
||||
<path fill="#1D1D1B" d="M182.6,151.7c0.2,1.8,1.4,3,3.1,3c1.6,0,2.6-0.8,2.6-1.9c0-1-0.8-1.6-2.8-1.8c-2.4-0.2-3.6-1.2-3.6-3
|
||||
c0-1.6,1.5-2.7,3.6-2.7c1.9,0,3.4,1.2,3.8,3.1l-1.3,0.4c-0.2-1.4-1.2-2.2-2.5-2.2c-1.3,0-2.2,0.6-2.2,1.4c0,0.9,0.6,1.5,2.4,1.7
|
||||
c2.7,0.3,4,1.3,4,3.1c0,1.9-1.6,3.2-4,3.2c-1.2,0-2.2-0.4-3.1-1.1c-0.8-0.7-1.3-1.7-1.5-2.9L182.6,151.7z"/>
|
||||
<path fill="#1D1D1B" d="M192.4,151.7c0.2,1.8,1.4,3,3.1,3c1.6,0,2.6-0.8,2.6-1.9c0-1-0.8-1.6-2.8-1.8c-2.4-0.2-3.6-1.2-3.6-3
|
||||
c0-1.6,1.5-2.7,3.6-2.7c1.9,0,3.4,1.2,3.8,3.1l-1.3,0.4c-0.2-1.4-1.2-2.2-2.5-2.2c-1.3,0-2.2,0.6-2.2,1.4c0,0.9,0.6,1.5,2.4,1.7
|
||||
c2.7,0.3,4,1.3,4,3.1c0,1.9-1.6,3.2-4,3.2c-1.2,0-2.2-0.4-3.1-1.1c-0.8-0.7-1.3-1.7-1.5-2.9L192.4,151.7z"/>
|
||||
<path fill="#1D1D1B" d="M211.4,150.7c0,3-2.1,5.3-5.2,5.3c-3.1,0-5.2-2.3-5.2-5.3c0-3,2.2-5.4,5.2-5.4
|
||||
C209.3,145.3,211.4,147.6,211.4,150.7z M210,150.7c0-2.3-1.6-4.1-3.8-4.1c-2.2,0-3.8,1.8-3.8,4.1c0,2.3,1.6,4,3.8,4
|
||||
C208.4,154.7,210,153,210,150.7z"/>
|
||||
<path fill="#1D1D1B" d="M222.3,148.7l-1.3,0.4c-0.2-1.5-1.4-2.4-3-2.4c-2.1,0-3.6,1.7-3.6,3.9c0,2.5,1.5,4.2,3.7,4.2
|
||||
c1.8,0,3.2-1.2,3.4-3l1.3,0.3c-0.3,2.3-2.3,4-4.7,4c-3,0-5.1-2.2-5.1-5.3c0-3.1,2-5.4,4.9-5.4C220.2,145.3,221.8,146.6,222.3,148.7
|
||||
z"/>
|
||||
<path fill="#1D1D1B" d="M226.6,142.7c0,0.6-0.5,1.1-1,1.1c-0.6,0-1.1-0.5-1.1-1.1c0-0.6,0.5-1.1,1.1-1.1
|
||||
C226.1,141.6,226.6,142.1,226.6,142.7z M224.8,155.7v-10.1h1.4v10.1H224.8z"/>
|
||||
<path fill="#1D1D1B" d="M235.4,149.3v-0.5c0-1.3-0.9-2.2-2.6-2.2c-1.7,0-2.6,1-2.6,2.5l0,0.3l-1.4-0.1c-0.1-2.6,1.6-4,3.9-4
|
||||
c2.6,0,4,1.4,4,3.6v6.8h-1.3v-1.4c-0.7,1.1-1.8,1.7-3.2,1.7c-2.4,0-3.5-1.5-3.5-3c0-1.9,1.3-2.9,3.8-3.3L235.4,149.3z M235.4,151.3
|
||||
v-0.8l-2.7,0.4c-1.8,0.3-2.7,0.9-2.7,2c0,1.1,0.9,1.8,2.4,1.8C234.1,154.7,235.4,153.4,235.4,151.3z"/>
|
||||
<path fill="#1D1D1B" d="M238.5,146.9v-1.3h2v-3.1h1.4v3.1h5.4v1.3H242v5.4c0,1.6,0.8,2.5,2.3,2.5c1.4,0,2.2-1.1,2.1-2.7l1.4,0.1
|
||||
c0.1,2.4-1.4,3.9-3.4,3.9c-2.3,0-3.7-1.4-3.7-3.8v-5.3H238.5z"/>
|
||||
<path fill="#1D1D1B" d="M251.6,142.7c0,0.6-0.5,1.1-1,1.1c-0.6,0-1.1-0.5-1.1-1.1c0-0.6,0.5-1.1,1.1-1.1
|
||||
C251.1,141.6,251.6,142.1,251.6,142.7z M249.9,155.7v-10.1h1.4v10.1H249.9z"/>
|
||||
<path fill="#1D1D1B" d="M263.8,150.7c0,3-2.1,5.3-5.2,5.3c-3.1,0-5.2-2.3-5.2-5.3c0-3,2.2-5.4,5.2-5.4
|
||||
C261.7,145.3,263.8,147.6,263.8,150.7z M262.5,150.7c0-2.3-1.6-4.1-3.8-4.1c-2.2,0-3.8,1.8-3.8,4.1c0,2.3,1.6,4,3.8,4
|
||||
C260.9,154.7,262.5,153,262.5,150.7z"/>
|
||||
<path fill="#1D1D1B" d="M266.1,155.7v-10.1h1.4v1.4c0.8-1.1,1.9-1.8,3.5-1.8c2.2,0,3.5,1.4,3.5,3.8v6.6h-1.4v-6.3
|
||||
c0-1.9-0.8-2.8-2.5-2.8c-1.9,0-3.1,1.4-3.1,3.7v5.4H266.1z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#1D1D1B" d="M71.2,168v-1.3h2v-1.2c0-2.2,1.5-3.9,3.7-3.9c1.9,0,3.3,1.3,3.4,3.1l-1.3,0.3c0-1.3-0.8-2.1-2-2.1
|
||||
c-1.4,0-2.3,1-2.3,2.6v1.2h5.6v1.3h-5.6v8.8h-1.4V168H71.2z"/>
|
||||
<path fill="#1D1D1B" d="M90.6,171.8c0,3-2.1,5.3-5.2,5.3c-3.1,0-5.2-2.3-5.2-5.3c0-3,2.2-5.4,5.2-5.4
|
||||
C88.5,166.4,90.6,168.8,90.6,171.8z M89.3,171.8c0-2.3-1.6-4.1-3.8-4.1c-2.2,0-3.8,1.8-3.8,4.1c0,2.3,1.6,4,3.8,4
|
||||
C87.7,175.8,89.3,174.2,89.3,171.8z"/>
|
||||
<path fill="#1D1D1B" d="M92.9,176.8v-10.1h1.4v1.2c0.6-1,1.5-1.5,2.7-1.5c1.8,0,3.2,1.4,3.2,3.6l0,0.4l-1.4,0.2c0-0.3,0-0.4,0-0.5
|
||||
c0-1.5-0.8-2.3-2-2.3c-1.5,0-2.5,1.2-2.5,3.3v5.8H92.9z"/>
|
||||
<path fill="#1D1D1B" d="M107.7,176.8V162h1.4v13.5h8.4v1.3H107.7z"/>
|
||||
<path fill="#1D1D1B" d="M128.7,171.8c0,3-2.1,5.3-5.2,5.3c-3.1,0-5.2-2.3-5.2-5.3c0-3,2.2-5.4,5.2-5.4
|
||||
C126.6,166.4,128.7,168.8,128.7,171.8z M127.3,171.8c0-2.3-1.6-4.1-3.8-4.1c-2.2,0-3.8,1.8-3.8,4.1c0,2.3,1.6,4,3.8,4
|
||||
C125.7,175.8,127.3,174.2,127.3,171.8z"/>
|
||||
<path fill="#1D1D1B" d="M139.6,169.8l-1.3,0.4c-0.2-1.5-1.4-2.4-3-2.4c-2.1,0-3.6,1.7-3.6,3.9c0,2.5,1.5,4.2,3.7,4.2
|
||||
c1.8,0,3.2-1.2,3.4-3l1.3,0.3c-0.3,2.3-2.3,4-4.7,4c-3,0-5.1-2.2-5.1-5.3c0-3.1,2-5.4,4.9-5.4C137.5,166.4,139.2,167.8,139.6,169.8
|
||||
z"/>
|
||||
<path fill="#1D1D1B" d="M148.5,170.4v-0.5c0-1.3-0.9-2.2-2.6-2.2c-1.7,0-2.6,1-2.6,2.5l0,0.3l-1.4-0.1c-0.1-2.6,1.6-4,3.9-4
|
||||
c2.6,0,4,1.4,4,3.6v6.8h-1.3v-1.4c-0.7,1.1-1.8,1.7-3.2,1.7c-2.4,0-3.5-1.5-3.5-3c0-1.9,1.3-2.9,3.8-3.3L148.5,170.4z M148.5,172.5
|
||||
v-0.8l-2.7,0.4c-1.8,0.3-2.7,0.9-2.7,2c0,1.1,0.9,1.8,2.4,1.8C147.2,175.9,148.5,174.5,148.5,172.5z"/>
|
||||
<path fill="#1D1D1B" d="M152.7,176.8V162h1.4v14.8H152.7z"/>
|
||||
<path fill="#1D1D1B" d="M162.5,176.8V162h4.9c4.1-0.1,7.1,3.3,7.1,7.4c0.1,4.1-3,7.5-7.1,7.4H162.5z M163.9,175.5h3.5
|
||||
c3.3,0,5.7-2.6,5.7-6c0-3.5-2.4-6.1-5.7-6.1h-3.5V175.5z"/>
|
||||
<path fill="#1D1D1B" d="M185.7,171.1v0.8h-8.1c0.1,2.4,1.6,4,3.7,4c1.7,0,3-1.1,3.3-2.8l1.4,0.2c-0.3,2.3-2.2,3.8-4.6,3.8
|
||||
c-3,0-5.1-2.2-5.1-5.3c0-3.1,2-5.4,4.9-5.4C183.9,166.4,185.7,168.4,185.7,171.1z M184.3,170.6c0-1.7-1.3-2.9-3.1-2.9
|
||||
c-1.8,0-3.1,1.2-3.5,2.9H184.3z"/>
|
||||
<path fill="#1D1D1B" d="M188.2,176.8v-10.1h1.4v1.3c0.6-1,1.5-1.6,2.8-1.6c1.4,0,2.4,0.7,2.8,1.9c0.6-1.2,1.6-1.9,3-1.9
|
||||
c1.9,0,3,1.1,3,3.4l0,7h-1.4v-6.7c0-1.8-0.6-2.5-2-2.5c-1.4,0-2.4,1.1-2.5,3.2l0,6H194v-6.7c0-1.8-0.6-2.5-2-2.5
|
||||
c-1.5,0-2.5,1.2-2.5,3.5v5.6H188.2z"/>
|
||||
<path fill="#1D1D1B" d="M213.7,171.8c0,3-2.1,5.3-5.2,5.3c-3.1,0-5.2-2.3-5.2-5.3c0-3,2.2-5.4,5.2-5.4
|
||||
C211.6,166.4,213.7,168.8,213.7,171.8z M212.4,171.8c0-2.3-1.6-4.1-3.8-4.1c-2.2,0-3.8,1.8-3.8,4.1c0,2.3,1.6,4,3.8,4
|
||||
C210.8,175.8,212.4,174.2,212.4,171.8z"/>
|
||||
<path fill="#1D1D1B" d="M224.6,169.8l-1.3,0.4c-0.2-1.5-1.4-2.4-3-2.4c-2.1,0-3.6,1.7-3.6,3.9c0,2.5,1.5,4.2,3.7,4.2
|
||||
c1.8,0,3.2-1.2,3.4-3l1.3,0.3c-0.3,2.3-2.3,4-4.7,4c-3,0-5.1-2.2-5.1-5.3c0-3.1,2-5.4,4.9-5.4C222.5,166.4,224.2,167.8,224.6,169.8
|
||||
z"/>
|
||||
<path fill="#1D1D1B" d="M227.2,176.8v-10.1h1.4v1.2c0.6-1,1.5-1.5,2.7-1.5c1.8,0,3.2,1.4,3.2,3.6l0,0.4l-1.4,0.2c0-0.3,0-0.4,0-0.5
|
||||
c0-1.5-0.8-2.3-2-2.3c-1.5,0-2.5,1.2-2.5,3.3v5.8H227.2z"/>
|
||||
<path fill="#1D1D1B" d="M242.4,170.4v-0.5c0-1.3-0.9-2.2-2.6-2.2c-1.7,0-2.6,1-2.6,2.5l0,0.3l-1.4-0.1c-0.1-2.6,1.6-4,3.9-4
|
||||
c2.6,0,4,1.4,4,3.6v6.8h-1.3v-1.4c-0.7,1.1-1.8,1.7-3.2,1.7c-2.4,0-3.5-1.5-3.5-3c0-1.9,1.3-2.9,3.8-3.3L242.4,170.4z M242.4,172.5
|
||||
v-0.8l-2.7,0.4c-1.8,0.3-2.7,0.9-2.7,2c0,1.1,0.9,1.8,2.4,1.8C241.2,175.9,242.4,174.5,242.4,172.5z"/>
|
||||
<path fill="#1D1D1B" d="M255.2,169.8l-1.3,0.4c-0.2-1.5-1.4-2.4-3-2.4c-2.1,0-3.6,1.7-3.6,3.9c0,2.5,1.5,4.2,3.7,4.2
|
||||
c1.8,0,3.2-1.2,3.4-3l1.3,0.3c-0.3,2.3-2.3,4-4.7,4c-3,0-5.1-2.2-5.1-5.3c0-3.1,2-5.4,4.9-5.4C253.2,166.4,254.8,167.8,255.2,169.8
|
||||
z"/>
|
||||
<path fill="#1D1D1B" d="M258.3,177.3c-0.1,1.1,0.2,1.9,0.8,2.5c0.6,0.6,1.4,0.9,2.4,0.9c2.1,0,3.6-1.5,3.6-3.9v-1.9
|
||||
c-0.7,1.1-2,1.8-3.6,1.8c-2.3,0-3.7-1.5-3.7-3.8l0-6.1h1.4v5.7c0,1.9,0.9,2.9,2.7,2.9c1.9,0,3.2-1.5,3.2-3.8v-4.8h1.4v9.9
|
||||
c0,3-2,5.2-5,5.2c-2.6,0-4.6-1.7-4.5-4.4L258.3,177.3z"/>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#FDC608" d="M4,144.3l12.4,4.1v-13.3h12v13.3l12.5-4.1l3.9,11.5l-12.5,4.1l7.7,10.6l-9.7,7.2L22.5,167l-8,10.7
|
||||
l-9.7-7.2l7.9-10.6l-12.5-4.1L4,144.3z"/>
|
||||
</g>
|
||||
<path fill="none" stroke="#1D1D1B" stroke-width="1.0383" stroke-miterlimit="10" d="M271.9,49.1c0,0,24.6,69.2-51.8,73.6
|
||||
c-76.4,4.4-185.4-36.1-197.6,1.5"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 163 KiB |
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
width="170"
|
||||
height="58"
|
||||
viewBox="0 0 170 58"
|
||||
sodipodi:docname="eCommons.svg"
|
||||
xml:space="preserve"
|
||||
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:serif="http://www.serif.com/"><defs
|
||||
id="defs1" /><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="2.0205882"
|
||||
inkscape:cx="74.483263"
|
||||
inkscape:cy="86.360992"
|
||||
inkscape:window-width="1374"
|
||||
inkscape:window-height="831"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g1" /><g
|
||||
inkscape:groupmode="layer"
|
||||
inkscape:label="Image"
|
||||
id="g1"><text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.0258px;font-family:Sans;-inkscape-font-specification:Sans;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;fill:#ffffff;stroke-width:1.75215"
|
||||
x="53.296333"
|
||||
y="35.925053"
|
||||
id="text2"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan2"
|
||||
x="53.296333"
|
||||
y="35.925053"
|
||||
style="fill:#000000;stroke-width:1.75215">eCommons</tspan></text><g
|
||||
style="clip-rule:evenodd;fill-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5"
|
||||
id="g2"
|
||||
transform="matrix(0.08310294,0,0,0.08310294,3.2792928,2.166006)"><g
|
||||
id="g1-5"><path
|
||||
id="C-version-rounded-edges"
|
||||
serif:id="C version rounded edges"
|
||||
d="m 443.83,369.168 159.462,79.731 C 553.094,557.222 443.369,632.433 316.217,632.433 141.692,632.433 0,490.741 0,316.216 0,141.691 141.692,-0.001 316.217,-0.001 c 127.153,0 236.877,75.211 287.075,183.534 l -159.537,79.769 c -20.816,-50.023 -70.181,-85.23 -127.705,-85.23 -76.304,0 -138.253,61.949 -138.253,138.253 0,76.304 61.949,138.253 138.253,138.253 57.593,0 107.008,-35.292 127.78,-85.411 z m 17.361,58.992 c -33.519,43.43 -86.088,71.42 -145.14,71.42 -101.14,0 -183.253,-82.113 -183.253,-183.253 0,-101.14 82.113,-183.253 183.253,-183.253 58.981,0 111.494,27.922 145.019,71.262 l 79.869,-39.934 C 492.152,92.382 409.677,45.002 316.218,45.002 166.529,45.002 45.001,166.53 45.001,316.219 c 0,149.689 121.528,271.217 271.217,271.217 93.459,0 175.934,-47.38 224.721,-119.4 l -79.747,-39.874 z" /><g
|
||||
id="e-motion-1"
|
||||
serif:id="e-motion 1"><path
|
||||
d="M 564.967,177.536 172.986,377.989"
|
||||
style="fill:none;stroke:#000000;stroke-width:45px"
|
||||
id="path1" /></g></g></g></g></svg>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,162 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="svg4866"
|
||||
viewBox="0 0 228.57361 45.902503"
|
||||
height="12.954706mm"
|
||||
width="64.508553mm"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="FKI_Logo18_TranspBkgr.svg">
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1280"
|
||||
inkscape:window-height="653"
|
||||
id="namedview15"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.2468631"
|
||||
inkscape:cx="17.644279"
|
||||
inkscape:cy="22.951251"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="21"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg4866" />
|
||||
<defs
|
||||
id="defs4868" />
|
||||
<metadata
|
||||
id="metadata4871">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
transform="translate(-150.70028,-465.37214)"
|
||||
id="layer1">
|
||||
<g
|
||||
transform="translate(128.69674,346.22326)"
|
||||
style="font-style:normal;font-weight:normal;font-size:39.35404587px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#009245;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
id="flowRoot4472-8">
|
||||
<path
|
||||
d="m 70.266322,143.6056 -1.51513,0 c -1.928349,0 -2.754783,1.188 -2.754783,3.06469 l 0,2.13496 -1.136348,0 0,1.61843 1.136348,0 0,6.09496 1.928348,0 0,-6.09496 1.342956,0 0,-1.61843 -1.342956,0 0,-2.25548 c 0.03443,-0.67148 0.189391,-1.13635 0.809217,-1.13635 l 1.532348,0 0,-1.80782 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666"
|
||||
id="path4144" />
|
||||
<path
|
||||
d="m 76.02375,150.80247 0.637043,-1.63566 c -0.447652,-0.396 -1.101913,-0.53374 -1.325739,-0.53374 -1.050261,0 -1.738957,0.396 -2.186609,1.25687 l 0,-1.08469 -1.876696,0 0,7.71339 1.876696,0 0,-3.97722 c 0.03444,-1.25687 0.619826,-2.01443 1.807826,-2.01443 0.309913,0 0.757566,0.12052 1.067479,0.27548 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666"
|
||||
id="path4146" />
|
||||
<path
|
||||
d="m 81.351818,148.63307 c -2.289913,0 -4.02887,1.79061 -4.02887,4.06331 0,2.25548 1.825044,4.01165 4.114957,4.01165 1.463478,-0.0172 2.789218,-0.61982 3.529566,-1.70452 l -1.222435,-1.01583 c -0.568174,0.63705 -1.291305,1.01583 -2.221044,1.01583 l -0.06887,0 c -1.188,0 -2.152174,-0.94696 -2.152174,-2.01444 l 5.836697,0 0,-0.70591 c 0,-2.25548 -1.515131,-3.65009 -3.70174,-3.65009 l -0.08609,0 z m 1.842261,2.87531 -3.718957,0 c 0.137739,-0.46487 1.015826,-1.11913 1.893913,-1.11913 0.878087,0 1.65287,0.29269 1.825044,1.11913 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666"
|
||||
id="path4148" />
|
||||
<path
|
||||
d="m 90.894382,148.63307 c -2.289913,0 -4.02887,1.79061 -4.02887,4.06331 0,2.25548 1.825044,4.01165 4.114957,4.01165 1.463479,-0.0172 2.789218,-0.61982 3.529566,-1.70452 L 93.2876,153.98768 c -0.568174,0.63705 -1.291304,1.01583 -2.221044,1.01583 l -0.06887,0 c -1.188,0 -2.152174,-0.94696 -2.152174,-2.01444 l 5.836696,0 0,-0.70591 c 0,-2.25548 -1.515131,-3.65009 -3.70174,-3.65009 l -0.08609,0 z m 1.842262,2.87531 -3.718958,0 c 0.13774,-0.46487 1.015827,-1.11913 1.893914,-1.11913 0.878087,0 1.65287,0.29269 1.825044,1.11913 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666"
|
||||
id="path4150" />
|
||||
<path
|
||||
d="m 96.872944,143.6056 0,12.91304 1.876696,0 0,-3.44348 3.40904,3.44348 2.28992,0 -4.18383,-4.20104 4.01165,-3.51235 -2.25547,0 -3.27131,2.80643 0,-8.00608 -1.876696,0 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.21739388px;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#009245;fill-opacity:1"
|
||||
id="path4152" />
|
||||
<path
|
||||
d="m 113.25808,152.00768 c 0,-2.23826 -1.0847,-3.37461 -3.08192,-3.37461 -0.92974,0 -1.60121,0.41322 -2.13495,1.25687 l 0,-1.05026 -1.92835,0 0,7.67896 1.92835,0 0,-4.23548 c 0.0344,-1.06748 0.68869,-1.75617 1.85947,-1.75617 0.84366,0.0172 1.23966,0.53374 1.23966,1.51513 l 0,4.47652 2.11774,0 0,-4.51096 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.21739388px;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#009245;fill-opacity:1"
|
||||
id="path4154" />
|
||||
<path
|
||||
d="m 119.47445,148.63307 c -2.28991,0 -4.14939,1.79061 -4.14939,4.06331 0,2.25548 1.85948,4.01165 4.14939,4.01165 2.2727,0 4.09774,-1.75617 4.09774,-4.02887 0,-2.27269 -1.82504,-4.04609 -4.09774,-4.04609 z m 0.0172,1.75618 c 1.10192,0 1.99722,1.08469 1.99722,2.30713 0,1.23965 -0.8953,2.25548 -1.99722,2.25548 -1.11913,0 -2.01443,-1.01583 -2.01443,-2.25548 0,-1.22244 0.8953,-2.30713 2.01443,-2.30713 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.21739388px;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#009245;fill-opacity:1"
|
||||
id="path4156" />
|
||||
<path
|
||||
d="m 132.49655,156.69081 3.85669,-7.88556 -2.01443,0 -1.96279,4.08052 -2.06608,-4.08052 -1.99722,4.08052 -1.96278,-4.08052 -1.99722,0 3.85669,7.88556 0.20661,0 1.89392,-4.28713 1.96278,4.28713 0.22383,0 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.21739388px;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#009245;fill-opacity:1"
|
||||
id="path4158" />
|
||||
<path
|
||||
d="m 138.06969,143.6056 0,12.91304 1.92835,0 0,-12.91304 -1.92835,0 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.21739388px;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#009245;fill-opacity:1"
|
||||
id="path4160" />
|
||||
<path
|
||||
d="m 146.19936,148.63307 c -2.28992,0 -4.02887,1.79061 -4.02887,4.06331 0,2.25548 1.82504,4.01165 4.11495,4.01165 1.46348,-0.0172 2.78922,-0.61982 3.52957,-1.70452 l -1.22243,-1.01583 c -0.56818,0.63705 -1.29131,1.01583 -2.22105,1.01583 l -0.0689,0 c -1.188,0 -2.15217,-0.94696 -2.15217,-2.01444 l 5.83669,0 0,-0.70591 c 0,-2.25548 -1.51513,-3.65009 -3.70174,-3.65009 l -0.0861,0 z m 1.84226,2.87531 -3.71896,0 c 0.13774,-0.46487 1.01583,-1.11913 1.89392,-1.11913 0.87808,0 1.65287,0.29269 1.82504,1.11913 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.21739388px;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#009245;fill-opacity:1"
|
||||
id="path4162" />
|
||||
<path
|
||||
d="m 157.56696,149.85551 c -0.44765,-0.91252 -1.17078,-1.22244 -2.11774,-1.22244 l -0.0344,0 c -1.91113,0 -3.58121,1.41183 -3.59843,3.82227 0.0172,2.73756 1.49791,4.25269 3.63287,4.25269 0.99861,0 1.6873,-0.43043 2.11774,-1.25687 l 0,1.06748 1.89391,0 0,-12.91304 -1.89391,0 0,6.24991 z m -3.4607,2.59983 c 0,-1.32574 0.63705,-1.92835 1.61844,-1.92835 1.15356,0 1.84226,0.67148 1.84226,2.0833 0,1.39461 -0.6887,2.25548 -1.84226,2.25548 l -0.0517,0 c -1.10192,0 -1.56679,-1.03304 -1.56679,-2.41043 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.21739388px;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#009245;fill-opacity:1"
|
||||
id="path4164" />
|
||||
<path
|
||||
d="m 167.35891,152.74803 c 0,1.37739 -0.65426,2.11774 -1.77339,2.11774 -1.03304,0 -1.584,-0.77478 -1.584,-2.15217 0,-1.37739 0.58539,-2.18661 1.584,-2.18661 1.13635,0 1.77339,0.87808 1.77339,2.22104 z m 2.03165,3.71896 0,-7.66174 -2.03165,0 0,1.10191 c -0.44765,-0.87809 -1.10191,-1.27409 -2.04887,-1.27409 -2.16939,0 -3.59843,1.65287 -3.59843,4.08053 0,2.35878 1.48069,3.99443 3.59843,3.99443 0.94696,0 1.63565,-0.41322 2.04887,-1.11913 l 0,1.01583 c 0,1.27408 -0.74035,1.87669 -2.06609,1.87669 -0.77478,0 -1.41182,-0.36156 -1.7906,-0.8953 l -1.44627,1.20522 c 0.75757,1.17078 2.30714,1.60121 3.40905,1.60121 2.54817,-0.0344 3.92556,-1.30852 3.92556,-3.92556 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.21739388px;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#009245;fill-opacity:1"
|
||||
id="path4166" />
|
||||
<path
|
||||
d="m 175.60048,148.63307 c -2.28991,0 -4.02887,1.79061 -4.02887,4.06331 0,2.25548 1.82504,4.01165 4.11496,4.01165 1.46348,-0.0172 2.78922,-0.61982 3.52956,-1.70452 l -1.22243,-1.01583 c -0.56818,0.63705 -1.29131,1.01583 -2.22105,1.01583 l -0.0689,0 c -1.188,0 -2.15218,-0.94696 -2.15218,-2.01444 l 5.8367,0 0,-0.70591 c 0,-2.25548 -1.51513,-3.65009 -3.70174,-3.65009 l -0.0861,0 z m 1.84226,2.87531 -3.71895,0 c 0.13773,-0.46487 1.01582,-1.11913 1.89391,-1.11913 0.87809,0 1.65287,0.29269 1.82504,1.11913 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.21739388px;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#009245;fill-opacity:1"
|
||||
id="path4168" />
|
||||
<path
|
||||
d="m 181.57904,148.80525 0,7.71339 1.91114,0 0,-7.71339 -1.91114,0 z m 0.96418,-4.08052 c -0.6887,0 -1.22244,0.51652 -1.22244,1.188 0,0.67147 0.53374,1.188 1.22244,1.188 0.68869,0 1.22243,-0.51653 1.22243,-1.188 0,-0.67148 -0.53374,-1.188 -1.22243,-1.188 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666;fill-opacity:1"
|
||||
id="path4170" />
|
||||
<path
|
||||
d="m 193.2563,152.00768 c 0,-2.23826 -1.0847,-3.37461 -3.08191,-3.37461 -0.92974,0 -1.60122,0.41322 -2.13496,1.25687 l 0,-1.05026 -1.92835,0 0,7.67896 1.92835,0 0,-4.23548 c 0.0344,-1.06748 0.68869,-1.75617 1.85948,-1.75617 0.84365,0.0172 1.23965,0.53374 1.23965,1.51513 l 0,4.47652 2.11774,0 0,-4.51096 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666;fill-opacity:1"
|
||||
id="path4172" />
|
||||
<path
|
||||
d="m 201.40103,150.28594 c -0.60261,-0.96417 -1.56678,-1.65287 -2.72035,-1.65287 l -0.0861,0 c -1.84226,0 -2.94417,1.06748 -2.94417,2.376 0,1.34296 1.13635,1.99722 2.23826,2.23827 0.77478,0.17217 1.82504,0.48208 1.82504,1.03304 l 0,0.0172 c 0,0.43043 -0.61982,0.65426 -1.32573,0.65426 -0.5854,0 -1.06748,-0.27548 -1.53235,-0.98139 l -1.46348,1.17078 c 0.87809,1.2913 2.0833,1.60122 2.99583,1.60122 1.60121,0 3.13356,-0.89531 3.18521,-2.44487 -0.0172,-1.30853 -0.94695,-2.04887 -2.11774,-2.34157 -0.68869,-0.15496 -1.89391,-0.46487 -1.91113,-0.96417 0,-0.55096 0.396,-0.77479 1.03305,-0.792 0.65426,0 1.27408,0.70591 1.51513,1.03304 l 1.30852,-0.94696 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666;fill-opacity:1"
|
||||
id="path4174" />
|
||||
<path
|
||||
d="m 206.14182,145.75777 -1.85948,0 0,3.04748 -0.98139,0 0,1.60122 0.98139,0 0,6.11217 1.85948,0 0,-6.11217 0.96417,0 0,-1.60122 -0.96417,0 0,-3.04748 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666;fill-opacity:1"
|
||||
id="path4176" />
|
||||
<path
|
||||
d="m 209.22383,148.80525 0,7.71339 1.91113,0 0,-7.71339 -1.91113,0 z m 0.96417,-4.08052 c -0.68869,0 -1.22243,0.51652 -1.22243,1.188 0,0.67147 0.53374,1.188 1.22243,1.188 0.6887,0 1.22244,-0.51653 1.22244,-1.188 0,-0.67148 -0.53374,-1.188 -1.22244,-1.188 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666;fill-opacity:1"
|
||||
id="path4178" />
|
||||
<path
|
||||
d="m 216.0802,145.75777 -1.85947,0 0,3.04748 -0.9814,0 0,1.60122 0.9814,0 0,6.11217 1.85947,0 0,-6.11217 0.96418,0 0,-1.60122 -0.96418,0 0,-3.04748 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666;fill-opacity:1"
|
||||
id="path4180" />
|
||||
<path
|
||||
d="m 219.05891,153.35064 c 0,2.23826 1.63565,3.35739 3.61565,3.35739 l 0.0861,0 c 2.0833,0 3.46069,-1.27409 3.46069,-3.35739 l 0,-4.54539 -2.10052,0 0,4.26991 c -0.0172,1.23965 -0.43043,1.79061 -1.44626,1.79061 -0.8953,0 -1.54956,-0.58539 -1.54956,-1.56678 l 0,-4.49374 -2.06609,0 0,4.54539 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666;fill-opacity:1"
|
||||
id="path4182" />
|
||||
<path
|
||||
d="m 231.09638,145.75777 -1.85948,0 0,3.04748 -0.98139,0 0,1.60122 0.98139,0 0,6.11217 1.85948,0 0,-6.11217 0.96417,0 0,-1.60122 -0.96417,0 0,-3.04748 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666;fill-opacity:1"
|
||||
id="path4184" />
|
||||
<path
|
||||
d="m 237.54062,148.63307 c -2.28991,0 -4.02887,1.79061 -4.02887,4.06331 0,2.25548 1.82504,4.01165 4.11496,4.01165 1.46348,-0.0172 2.78922,-0.61982 3.52956,-1.70452 l -1.22243,-1.01583 c -0.56818,0.63705 -1.29131,1.01583 -2.22105,1.01583 l -0.0689,0 c -1.18801,0 -2.15218,-0.94696 -2.15218,-2.01444 l 5.8367,0 0,-0.70591 c 0,-2.25548 -1.51513,-3.65009 -3.70174,-3.65009 l -0.0861,0 z m 1.84226,2.87531 -3.71896,0 c 0.13774,-0.46487 1.01583,-1.11913 1.89392,-1.11913 0.87809,0 1.65287,0.29269 1.82504,1.11913 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Universalis ADF Std';-inkscape-font-specification:'Universalis ADF Std Bold';letter-spacing:0.26131234px;fill:#666666;fill-opacity:1"
|
||||
id="path4186" />
|
||||
</g>
|
||||
<g
|
||||
transform="translate(110.9422,-16.855578)"
|
||||
id="g4522">
|
||||
<path
|
||||
id="path4484-9"
|
||||
d="m 62.920803,490.8298 a 14.922076,14.922076 0 0 0 -0.216893,0.0106 l 0,5.84398 a 9.0742365,9.0742365 0 0 1 0.216893,-0.008 9.0742365,9.0742365 0 0 1 9.074614,9.07463 9.0742365,9.0742365 0 0 1 -9.074614,9.07461 9.0742365,9.0742365 0 0 1 -9.074614,-9.07461 9.0742365,9.0742365 0 0 1 0.0015,-0.0303 l -5.847006,0 a 14.922076,14.922076 0 0 0 -0.0015,0.0303 14.922076,14.922076 0 0 0 14.921622,14.92206 14.922076,14.922076 0 0 0 14.923134,-14.92165 14.922076,14.922076 0 0 0 -14.923136,-14.9216 z"
|
||||
style="opacity:1;fill:#666666;fill-opacity:1;stroke:none;stroke-width:3.29999995;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<circle
|
||||
style="opacity:1;fill:#009245;fill-opacity:1;stroke:none;stroke-width:3.29999995;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="circle4488-60"
|
||||
cx="54.405663"
|
||||
cy="496.78735"
|
||||
r="4.2579489" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 200 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="140" height="125" viewBox="0 0 140 125">
|
||||
|
||||
<path d="M18 74 C22 38, 44 17, 70 17 C96 17,118 38,122 74" fill="none" stroke="#FF4D9A" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M37 73 C40 51,52 39,70 39 C88 39,100 51,103 73" fill="none" stroke="#FF4D9A" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M55 74 C56 63,62 57,70 57 C78 57,84 63,85 74" fill="none" stroke="#FF4D9A" stroke-width="8" stroke-linecap="round"/>
|
||||
<text x="70" y="108" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="16" font-weight="800" fill="#F2F2F7">ARCHICARE</text>
|
||||
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 630 B |
@@ -0,0 +1,11 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="140" height="150" viewBox="0 0 140 150">
|
||||
|
||||
<g fill="none" stroke="#2EE6F6" stroke-width="7" stroke-linejoin="round">
|
||||
<path d="M70 12 L118 36 L70 60 L22 36 Z"/>
|
||||
<path d="M22 54 L70 78 L118 54"/>
|
||||
<path d="M22 72 L70 96 L118 72"/>
|
||||
</g>
|
||||
<text x="70" y="120" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="13" font-weight="800" fill="#F2F2F7">DISTRIBUTED</text>
|
||||
<text x="70" y="137" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="13" font-weight="800" fill="#F2F2F7">INFRASTRUCTURES</text>
|
||||
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 594 B |
@@ -0,0 +1,93 @@
|
||||
import { ActionError, defineAction } from "astro:actions";
|
||||
import { z } from "zod";
|
||||
|
||||
import { labels } from "../i18n/locales";
|
||||
import { footerRepository } from "../repositories/footer";
|
||||
import { FOOTER_SECTIONS, FOOTER_SOCIAL_NETWORKS } from "../types/footer";
|
||||
|
||||
import type { ActionAPIContext } from "astro:actions";
|
||||
|
||||
const defaultLocale = import.meta.env.PUBLIC_DEFAULT_LANGUAGE as keyof typeof labels;
|
||||
|
||||
// Site paths, anchors and http(s)/mailto URLs only: anything else (javascript:, data:)
|
||||
// would end up as a clickable link on every page.
|
||||
const href = z
|
||||
.string()
|
||||
.trim()
|
||||
.refine((value) => {
|
||||
if (value.startsWith("/") || value.startsWith("#")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
return ["http:", "https:", "mailto:"].includes(new URL(value).protocol);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}, "pages.admin.customize.footer.errors.invalidUrl");
|
||||
|
||||
// The default locale is required, so every visitor gets a text through the fallback.
|
||||
const localizedText = z
|
||||
.object(
|
||||
Object.fromEntries(
|
||||
Object.keys(labels).map((locale) => [locale, z.string().trim().optional()]),
|
||||
),
|
||||
)
|
||||
.refine((text) => !!text[defaultLocale], "pages.admin.customize.footer.errors.missingText");
|
||||
|
||||
const link = z.object({ label: localizedText, href });
|
||||
|
||||
const partner = z.object({
|
||||
src: z.string().trim().min(1, "pages.admin.customize.footer.errors.missingImage"),
|
||||
alt: z.string().trim().min(1, "system.constraint.text.notEmpty"),
|
||||
href: z.union([z.literal(""), href]).optional(),
|
||||
});
|
||||
|
||||
const footerSchema = z.object({
|
||||
hidden: z.record(z.enum(FOOTER_SECTIONS), z.boolean()),
|
||||
partnerGroups: z.array(z.object({ title: localizedText, partners: z.array(partner) })),
|
||||
navColumns: z.array(z.object({ title: localizedText, links: z.array(link) })),
|
||||
legalLinks: z.array(link),
|
||||
social: z.array(z.object({ network: z.enum(FOOTER_SOCIAL_NETWORKS), href })),
|
||||
});
|
||||
|
||||
/**
|
||||
* Actions are posted to /_actions/*, which the /admin firewall rule does not
|
||||
* match, so the role has to be checked here.
|
||||
* @param context The action context
|
||||
*/
|
||||
function assertAdmin({ locals: { session, t } }: ActionAPIContext) {
|
||||
if (!session?.user.roles?.includes("ROLE_ADMIN")) {
|
||||
throw new ActionError({
|
||||
code: "FORBIDDEN",
|
||||
message: t("pages.admin.customize.footer.errors.forbidden"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const saveFooter = defineAction({
|
||||
input: z.object({ config: z.string() }),
|
||||
handler: async ({ config }, context) => {
|
||||
assertAdmin(context);
|
||||
|
||||
const { t } = context.locals;
|
||||
|
||||
let parsed: unknown;
|
||||
|
||||
try {
|
||||
parsed = JSON.parse(config);
|
||||
} catch {
|
||||
parsed = undefined;
|
||||
}
|
||||
|
||||
const result = footerSchema.safeParse(parsed);
|
||||
|
||||
if (!result.success) {
|
||||
const [issue] = result.error.issues;
|
||||
|
||||
throw new ActionError({ code: "BAD_REQUEST", message: t(issue.message) });
|
||||
}
|
||||
|
||||
await footerRepository.save(result.data);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,83 @@
|
||||
import { ActionError, defineAction } from "astro:actions";
|
||||
import { z } from "zod";
|
||||
|
||||
import { headerLogoRepository } from "../repositories/headerLogo";
|
||||
|
||||
const LOGO_MEDIA_TYPES = ["image/png", "image/jpeg", "image/webp"] as const;
|
||||
|
||||
const mediaUrl = z.string().refine((value) => {
|
||||
if (value.startsWith("/")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL(value);
|
||||
|
||||
return url.protocol === "http:" || url.protocol === "https:";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}, "system.constraint.text.expectedUrl");
|
||||
|
||||
const logoInputSchema = z.object({
|
||||
mediaUrl,
|
||||
mediaType: z.enum(LOGO_MEDIA_TYPES),
|
||||
altText: z.string().trim().min(1, "system.constraint.text.notEmpty"),
|
||||
});
|
||||
|
||||
/**
|
||||
* The header is public, but its management lives under /admin/customize. Actions
|
||||
* are posted to /_actions/*, which the /admin firewall rule does not match, so
|
||||
* the role has to be checked here.
|
||||
*/
|
||||
function assertAdmin(session: App.Locals["session"], t: App.Locals["t"]): void {
|
||||
if (!session?.user.roles?.includes("ROLE_ADMIN")) {
|
||||
throw new ActionError({
|
||||
code: "FORBIDDEN",
|
||||
message: t("pages.admin.customize.logo.errors.forbidden"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const createHeaderLogo = defineAction({
|
||||
accept: "form",
|
||||
input: logoInputSchema,
|
||||
handler: async (input, context) => {
|
||||
const { session, t } = context.locals;
|
||||
|
||||
assertAdmin(session, t);
|
||||
|
||||
await headerLogoRepository.create({
|
||||
mediaUrl: input.mediaUrl,
|
||||
mediaType: input.mediaType,
|
||||
altText: input.altText,
|
||||
dateCreated: new Date(),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export const getHeaderLogoData = defineAction({
|
||||
handler: async (_input, context) => {
|
||||
const { session, t } = context.locals;
|
||||
|
||||
assertAdmin(session, t);
|
||||
|
||||
return {
|
||||
logos: await headerLogoRepository.getAll(),
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export const deleteHeaderLogo = defineAction({
|
||||
accept: "form",
|
||||
input: z.object({
|
||||
id: z.coerce.number().int().positive(),
|
||||
}),
|
||||
handler: async (input, context) => {
|
||||
const { session, t } = context.locals;
|
||||
|
||||
assertAdmin(session, t);
|
||||
|
||||
await headerLogoRepository.delete(input.id);
|
||||
},
|
||||
});
|
||||
@@ -1,6 +1,8 @@
|
||||
import { deleteBanner, saveBanner } from "./banners";
|
||||
import { saveBlogPost, setBlogPostPublished } from "./blog";
|
||||
import { saveFeaturedUsers } from "./featuredUsers";
|
||||
import { saveFooter } from "./footer";
|
||||
import { createHeaderLogo, deleteHeaderLogo, getHeaderLogoData } from "./headerLogo";
|
||||
import { createHomeHero, deleteHomeHero, getHomeHeroData, updateHomeHero } from "./hero";
|
||||
import { deleteHighlights, saveHighlights } from "./highlights";
|
||||
import { payment } from "./payment";
|
||||
@@ -10,8 +12,10 @@ import {
|
||||
updateReviewAreaRisk,
|
||||
updateReviewProjectStatus,
|
||||
} from "./projectReview";
|
||||
import { saveProposedCampaigns } from "./proposedCampaigns";
|
||||
import { updatePublicProfile } from "./publicProfile";
|
||||
import { register } from "./register";
|
||||
import { resetThemeColors, saveThemeColors } from "./themeColors";
|
||||
|
||||
export const server = {
|
||||
register,
|
||||
@@ -21,15 +25,22 @@ export const server = {
|
||||
saveBlogPost,
|
||||
setBlogPostPublished,
|
||||
createHomeHero,
|
||||
createHeaderLogo,
|
||||
deleteHeaderLogo,
|
||||
deleteHomeHero,
|
||||
getHeaderLogoData,
|
||||
getHomeHeroData,
|
||||
updateHomeHero,
|
||||
saveHighlights,
|
||||
deleteHighlights,
|
||||
saveFeaturedUsers,
|
||||
saveFooter,
|
||||
updatePublicProfile,
|
||||
updatePersonalProfile,
|
||||
updateReviewAreaRisk,
|
||||
updateReviewProjectStatus,
|
||||
sendReviewAreaComment,
|
||||
saveProposedCampaigns,
|
||||
saveThemeColors,
|
||||
resetThemeColors,
|
||||
};
|
||||
|
||||
@@ -1,25 +1,35 @@
|
||||
import { ActionError, defineAction } from "astro:actions";
|
||||
import { z } from "zod";
|
||||
|
||||
import { setSession } from "../auth/session.ts";
|
||||
import {
|
||||
apiUsersIdOrHandleGet,
|
||||
apiUsersIdorganizationPatch,
|
||||
apiUsersIdPatch,
|
||||
apiUsersIdpersonGet,
|
||||
apiUsersIdpersonPatch,
|
||||
type UserUserUpdationDto,
|
||||
type OrganizationJsonMergePatch,
|
||||
type PersonJsonMergePatch,
|
||||
type UserUserUpdationDtoJsonMergePatch,
|
||||
} from "../openapi/client/index.ts";
|
||||
import { zPersonalProfileForm } from "../validation/personalProfileValidation.ts";
|
||||
|
||||
const TERRITORY_FIELDS = ["country", "subLvl1", "subLvl2"];
|
||||
|
||||
/**
|
||||
* Saves the private part of the profile: the `Person` record, the `Territory` on the `User` and
|
||||
* the identity row (avatar, bio, social networks) that this section shares with the public one.
|
||||
* Saves the private part of the profile: the `Person` and `Organization` records, the `Territory`
|
||||
* and the private flags on the `User`, and the identity row (avatar, bio, social networks) that this section shares with the public one.
|
||||
* The email is deliberately left out: changing it needs a confirmation flow the API does not
|
||||
* expose here.
|
||||
*/
|
||||
export const updatePersonalProfile = defineAction({
|
||||
accept: "json",
|
||||
input: zPersonalProfileForm,
|
||||
handler: async (input, context) => {
|
||||
input: z.object({
|
||||
form: zPersonalProfileForm,
|
||||
// Fields the user edited since the last save, tracked by the form
|
||||
changed: z.array(zPersonalProfileForm.keyof()),
|
||||
}),
|
||||
handler: async ({ form: input, changed: changedFields }, context) => {
|
||||
const { t, session } = context.locals;
|
||||
|
||||
if (!session) {
|
||||
@@ -33,77 +43,96 @@ export const updatePersonalProfile = defineAction({
|
||||
const headers = session.token.asHttpHeaders;
|
||||
const isOrganization = input.type === "organization";
|
||||
|
||||
try {
|
||||
const userPatch: Partial<UserUserUpdationDto> = input;
|
||||
// Only send what the user edited: the API re-validates every field it gets, and rejects
|
||||
// an unchanged handle as already in use
|
||||
const changed = new Set<string>(changedFields);
|
||||
// Switching type moves the tax id to the other record, send all of its fields
|
||||
const typeChanged = changed.has("type");
|
||||
const pick = <T extends object>(values: T, all = false) =>
|
||||
Object.fromEntries(
|
||||
Object.entries(values).filter(([key]) => all || changed.has(key)),
|
||||
) as Partial<T>;
|
||||
const hasFields = (values: object) => Object.keys(values).length > 0;
|
||||
|
||||
if (input.country) {
|
||||
const currentTerritory = session.user.territory;
|
||||
const newTerritory = {
|
||||
try {
|
||||
const userPatch: UserUserUpdationDtoJsonMergePatch = pick({
|
||||
handle: input.handle,
|
||||
type: input.type,
|
||||
shareLocation: input.shareLocation,
|
||||
referralSource: input.referralSource || null,
|
||||
});
|
||||
|
||||
if (input.country && TERRITORY_FIELDS.some((field) => changed.has(field))) {
|
||||
userPatch.territory = {
|
||||
country: input.country,
|
||||
subLvl1: input.subLvl1 || null,
|
||||
subLvl2: input.subLvl2 || null,
|
||||
address: input.address.trim() || null,
|
||||
// The API replaces the whole Territory, keep the address this form does not edit
|
||||
address: session.user.territory?.address ?? null,
|
||||
};
|
||||
if (
|
||||
!currentTerritory ||
|
||||
currentTerritory.country !== newTerritory.country ||
|
||||
(currentTerritory.subLvl1 ?? null) !== newTerritory.subLvl1 ||
|
||||
(currentTerritory.subLvl2 ?? null) !== newTerritory.subLvl2 ||
|
||||
(currentTerritory.address ?? null) !== newTerritory.address
|
||||
) {
|
||||
userPatch.territory = newTerritory;
|
||||
}
|
||||
} else if (session.user.territory?.country) {
|
||||
// Country cleared in the form: do not send territory at all
|
||||
userPatch.territory = undefined;
|
||||
}
|
||||
|
||||
let userError: unknown;
|
||||
if (Object.keys(userPatch).length > 0) {
|
||||
if (hasFields(userPatch)) {
|
||||
const { error } = await apiUsersIdPatch({
|
||||
path: { id },
|
||||
headers,
|
||||
body: userPatch as UserUserUpdationDto,
|
||||
body: userPatch,
|
||||
});
|
||||
userError = error;
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
if (userError) {
|
||||
throw userError;
|
||||
const organizationPatch: OrganizationJsonMergePatch = pick(
|
||||
{
|
||||
legalName: input.legalName.trim(),
|
||||
businessName: input.businessName.trim(),
|
||||
taxId: input.taxId.trim(),
|
||||
taxIdType: input.taxIdType || null,
|
||||
legalForm: input.legalForm || null,
|
||||
publicEntity: input.publicEntity,
|
||||
},
|
||||
typeChanged,
|
||||
);
|
||||
|
||||
if (isOrganization && hasFields(organizationPatch)) {
|
||||
const { error } = await apiUsersIdorganizationPatch({
|
||||
path: { id },
|
||||
headers,
|
||||
body: organizationPatch,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
let personError: unknown;
|
||||
if (!isOrganization) {
|
||||
const currentPerson = await apiUsersIdpersonGet({ path: { id }, headers }).then(
|
||||
(r) => r.data,
|
||||
);
|
||||
const personPatch: Record<string, unknown> = {};
|
||||
const firstNameTrim = input.firstName.trim();
|
||||
if ((currentPerson?.firstName ?? "") !== firstNameTrim) {
|
||||
personPatch.firstName = firstNameTrim;
|
||||
}
|
||||
const lastNameTrim = input.lastName.trim();
|
||||
if ((currentPerson?.lastName ?? "") !== lastNameTrim) {
|
||||
personPatch.lastName = lastNameTrim;
|
||||
}
|
||||
const taxIdTrim = input.taxId.trim();
|
||||
if ((currentPerson?.taxId ?? "") !== taxIdTrim) {
|
||||
personPatch.taxId = taxIdTrim;
|
||||
}
|
||||
if (Object.keys(personPatch).length > 0) {
|
||||
const { error } = await apiUsersIdpersonPatch({
|
||||
path: { id },
|
||||
headers,
|
||||
body: personPatch as any,
|
||||
});
|
||||
personError = error;
|
||||
}
|
||||
} else {
|
||||
personError = null;
|
||||
}
|
||||
const personPatch: PersonJsonMergePatch = {
|
||||
...pick({ firstName: input.firstName.trim(), lastName: input.lastName.trim() }),
|
||||
// On organizations the tax id belongs to the Organization record
|
||||
...(!isOrganization &&
|
||||
pick(
|
||||
{
|
||||
taxId: input.taxId.trim(),
|
||||
taxIdType: input.taxIdType || null,
|
||||
birthYear: input.birthYear ? Number(input.birthYear) : null,
|
||||
gender: input.gender || null,
|
||||
},
|
||||
typeChanged,
|
||||
)),
|
||||
};
|
||||
|
||||
if (personError) {
|
||||
throw personError;
|
||||
if (hasFields(personPatch)) {
|
||||
const { error } = await apiUsersIdpersonPatch({
|
||||
path: { id },
|
||||
headers,
|
||||
body: personPatch,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// The names feed the display name, refresh the cookie so the header stays in sync
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { ActionError, defineAction } from "astro:actions";
|
||||
import { z } from "zod";
|
||||
|
||||
import { proposedCampaignsRepository } from "../repositories/proposedCampaigns";
|
||||
|
||||
export const saveProposedCampaigns = defineAction({
|
||||
accept: "json",
|
||||
input: z.object({
|
||||
"ending-soon": z.array(z.number().int().positive()),
|
||||
"most-successful": z.array(z.number().int().positive()),
|
||||
}),
|
||||
handler: async (input, context) => {
|
||||
const { session, t } = context.locals;
|
||||
|
||||
if (!session?.user.roles?.includes("ROLE_ADMIN")) {
|
||||
throw new ActionError({
|
||||
code: "FORBIDDEN",
|
||||
message: t("pages.admin.comm.banners.errors.forbidden"),
|
||||
});
|
||||
}
|
||||
|
||||
await proposedCampaignsRepository.save({
|
||||
"ending-soon": input["ending-soon"],
|
||||
"most-successful": input["most-successful"],
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ActionError, defineAction } from "astro:actions";
|
||||
import { z } from "zod";
|
||||
|
||||
import { setSession } from "../auth/session.ts";
|
||||
import { apiUsersIdOrHandleGet, apiUsersIdPatch } from "../openapi/client/index.ts";
|
||||
@@ -7,8 +8,12 @@ import { zProfileForm } from "../validation/publicProfileValidation.ts";
|
||||
|
||||
export const updatePublicProfile = defineAction({
|
||||
accept: "json",
|
||||
input: zProfileForm,
|
||||
handler: async (input, context) => {
|
||||
input: z.object({
|
||||
form: zProfileForm,
|
||||
// Fields the user edited since the last save, tracked by the form
|
||||
changed: z.array(zProfileForm.keyof()),
|
||||
}),
|
||||
handler: async ({ form: input, changed: changedFields }, context) => {
|
||||
const { t, session } = context.locals;
|
||||
|
||||
if (!session) {
|
||||
@@ -32,20 +37,23 @@ export const updatePublicProfile = defineAction({
|
||||
}),
|
||||
];
|
||||
|
||||
try {
|
||||
// User first: switching to `organization` makes the API create the Organization record
|
||||
const { error: userError } = await apiUsersIdPatch({
|
||||
path: { id },
|
||||
headers,
|
||||
body: {
|
||||
avatar: input.avatar,
|
||||
description: input.description.trim(),
|
||||
links,
|
||||
},
|
||||
});
|
||||
// Only send what the user edited: the API re-validates every field it gets
|
||||
const changed = new Set<string>(changedFields);
|
||||
const userPatch = Object.fromEntries(
|
||||
Object.entries({
|
||||
avatar: input.avatar,
|
||||
description: input.description.trim(),
|
||||
links,
|
||||
}).filter(([key]) => changed.has(key)),
|
||||
);
|
||||
|
||||
if (userError) {
|
||||
throw userError;
|
||||
try {
|
||||
if (Object.keys(userPatch).length > 0) {
|
||||
const { error } = await apiUsersIdPatch({ path: { id }, headers, body: userPatch });
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Keep the session cookie in sync so header and profile pages show fresh data
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { ActionError, defineAction } from "astro:actions";
|
||||
import { z } from "zod";
|
||||
|
||||
import { themeColorsRepository } from "../repositories/themeColors";
|
||||
import { DARK_THEME_COLOR_TOKENS, THEME_COLOR_TOKENS, isHexColor } from "../utils/themeColors";
|
||||
|
||||
const hexColorSchema = z
|
||||
.string()
|
||||
.refine(isHexColor, "Colors must use #RRGGBB or #RRGGBBAA notation");
|
||||
|
||||
function assertAdmin(
|
||||
session: { user: { roles?: string[] } } | undefined,
|
||||
t: (key: string) => string,
|
||||
) {
|
||||
if (!session?.user.roles?.includes("ROLE_ADMIN")) {
|
||||
throw new ActionError({
|
||||
code: "FORBIDDEN",
|
||||
message: t("pages.admin.customize.colors.errors.forbidden"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const saveThemeColors = defineAction({
|
||||
accept: "json",
|
||||
input: z.object({
|
||||
lightColors: z.record(z.enum(THEME_COLOR_TOKENS), hexColorSchema),
|
||||
darkColors: z.record(z.enum(DARK_THEME_COLOR_TOKENS), hexColorSchema),
|
||||
}),
|
||||
handler: async (input, context) => {
|
||||
assertAdmin(context.locals.session, context.locals.t);
|
||||
|
||||
await themeColorsRepository.save(input.lightColors, input.darkColors);
|
||||
},
|
||||
});
|
||||
|
||||
export const resetThemeColors = defineAction({
|
||||
accept: "json",
|
||||
input: z.object({}),
|
||||
handler: async (_input, context) => {
|
||||
assertAdmin(context.locals.session, context.locals.t);
|
||||
|
||||
await themeColorsRepository.reset();
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,45 @@
|
||||
import { writable, type Writable } from "svelte/store";
|
||||
import { get, writable, type Writable } from "svelte/store";
|
||||
|
||||
import type { Session } from "./types";
|
||||
|
||||
export const session: Writable<Session | undefined> = writable();
|
||||
|
||||
let pendingRefresh: Promise<Session | undefined> | undefined;
|
||||
|
||||
/**
|
||||
* Re-reads the session from the server. `/api/session` refreshes an expired access
|
||||
* token before returning it, which keeps long-lived tabs signed in instead of
|
||||
* sending a token the API will reject.
|
||||
*
|
||||
* Concurrent callers share the same request: several API calls can notice the stale
|
||||
* token at once (the project preview fetches the owner and the accounting in parallel).
|
||||
*/
|
||||
export function refreshSession(): Promise<Session | undefined> {
|
||||
pendingRefresh ??= (async () => {
|
||||
try {
|
||||
const response = await fetch("/api/session", {
|
||||
headers: { Accept: "application/json" },
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return get(session);
|
||||
}
|
||||
|
||||
const data = (await response.json()) as Session | null;
|
||||
const current = data ? { ...data, expires_at: new Date(data.expires_at) } : undefined;
|
||||
|
||||
session.set(current);
|
||||
|
||||
return current;
|
||||
} catch (error) {
|
||||
console.error("Session refresh failed:", error);
|
||||
|
||||
return get(session);
|
||||
}
|
||||
})().finally(() => {
|
||||
pendingRefresh = undefined;
|
||||
});
|
||||
|
||||
return pendingRefresh;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import { locale, t } from "../../i18n/store";
|
||||
import { apiAddressesIdPatch, apiAddressesPost } from "../../openapi/client";
|
||||
import { getCountries } from "../../utils/countries";
|
||||
import { useFormDraft, restoreFields } from "../../utils/forms/useFormDraft.svelte";
|
||||
import Select from "../library/inputs/Select.svelte";
|
||||
import TextInput from "../library/inputs/TextInput.svelte";
|
||||
|
||||
@@ -18,10 +19,13 @@
|
||||
let {
|
||||
address,
|
||||
userIri,
|
||||
draftId = "address",
|
||||
}: {
|
||||
/** Address to edit. Absent, a new one is created. */
|
||||
address?: Address;
|
||||
userIri: string;
|
||||
/** Identifies the draft of this form, so two of them do not write over each other. */
|
||||
draftId?: string;
|
||||
} = $props();
|
||||
|
||||
// Seeded once: parents mount a fresh form for every address they edit.
|
||||
@@ -42,6 +46,26 @@
|
||||
|
||||
let countries = $derived(getCountries($locale));
|
||||
|
||||
/**
|
||||
* Addresses hold nothing sensitive, so all of it can be kept.
|
||||
*/
|
||||
const { restored } = useFormDraft(
|
||||
untrack(() => draftId),
|
||||
() => ({
|
||||
firstName: form.firstName,
|
||||
lastName: form.lastName,
|
||||
line1: form.line1,
|
||||
line2: form.line2,
|
||||
city: form.city,
|
||||
postCode: form.postCode,
|
||||
country: form.country,
|
||||
}),
|
||||
);
|
||||
|
||||
if (restored) {
|
||||
restoreFields(form, restored);
|
||||
}
|
||||
|
||||
/** Saves the Address. Resolves to it, or to `undefined` with the errors shown. */
|
||||
export async function save(): Promise<Address | undefined> {
|
||||
error = undefined;
|
||||
|
||||
@@ -38,34 +38,48 @@
|
||||
|
||||
function navItemClass(item: AdminSidebarItem): string {
|
||||
return twMerge(
|
||||
"hover:bg-variant1 flex content-center items-center w-fit gap-2 rounded-lg px-4 py-2 text-base font-bold whitespace-nowrap transition-colors duration-300 text-secondary",
|
||||
"hover:bg-variant1 flex h-10 items-center gap-3 rounded-lg px-3 text-base font-bold whitespace-nowrap transition-colors duration-300 text-secondary",
|
||||
isActive(item) && "bg-variant2 hover:bg-variant3",
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Desktop sidebar -->
|
||||
<aside
|
||||
class={twMerge(
|
||||
"bg-purple-soft z-30 hidden min-w-58 shrink-0 flex-col rounded-2xl py-10 pr-10 pl-5 shadow-sm lg:sticky lg:top-(--sticky-top) lg:flex lg:max-h-[calc(100vh-var(--sticky-top)-1rem)]",
|
||||
classes,
|
||||
)}
|
||||
>
|
||||
<nav class="flex min-h-0 w-full flex-1 flex-col gap-2 overflow-x-hidden overflow-y-auto">
|
||||
{#each navItems as item (item.href)}
|
||||
<a
|
||||
href={`/${$locale}${item.href}`}
|
||||
class={navItemClass(item)}
|
||||
aria-current={isActive(item) ? "page" : undefined}
|
||||
>
|
||||
{#if item.icon}
|
||||
<item.icon class="size-5 shrink-0" />
|
||||
{/if}
|
||||
<span>{$t(item.label)}</span>
|
||||
</a>
|
||||
{/each}
|
||||
</nav>
|
||||
</aside>
|
||||
<!--
|
||||
Desktop sidebar: collapsed to one letter (or icon) per item, it opens over the content
|
||||
on hover or keyboard focus. The outer box keeps the collapsed width in the layout so
|
||||
opening it never moves the page.
|
||||
-->
|
||||
<div class="relative z-30 hidden w-18 shrink-0 self-start lg:sticky lg:top-(--sticky-top) lg:block">
|
||||
<aside
|
||||
class={twMerge(
|
||||
"group bg-purple-soft absolute top-0 left-0 flex max-h-[calc(100vh-var(--sticky-top)-1rem)] w-18 flex-col overflow-hidden rounded-2xl p-3 py-6 shadow-sm transition-[width] duration-200 focus-within:w-58 hover:w-58 hover:shadow-lg",
|
||||
classes,
|
||||
)}
|
||||
>
|
||||
<nav class="flex min-h-0 w-full flex-1 flex-col gap-2 overflow-x-hidden overflow-y-auto">
|
||||
{#each navItems as item (item.href)}
|
||||
<a
|
||||
href={`/${$locale}${item.href}`}
|
||||
class={navItemClass(item)}
|
||||
aria-current={isActive(item) ? "page" : undefined}
|
||||
>
|
||||
{#if item.icon}
|
||||
<item.icon class="size-6 shrink-0" />
|
||||
{:else}
|
||||
<span aria-hidden="true" class="w-6 shrink-0 text-center">
|
||||
{$t(item.label).charAt(0)}
|
||||
</span>
|
||||
{/if}
|
||||
<span
|
||||
class="opacity-0 transition-opacity duration-200 group-focus-within:opacity-100 group-hover:opacity-100"
|
||||
>
|
||||
{$t(item.label)}
|
||||
</span>
|
||||
</a>
|
||||
{/each}
|
||||
</nav>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<svelte:window onkeydown={(event) => event.key === "Escape" && closeMobile()} />
|
||||
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
import { t } from "../../i18n/store";
|
||||
import AnnotationIcon from "../icons/Comments.svelte";
|
||||
|
||||
const { id } = $props<{ id: string }>();
|
||||
interface Props {
|
||||
id: string;
|
||||
}
|
||||
|
||||
const { id }: Props = $props();
|
||||
|
||||
let date = $state<string | null>(null);
|
||||
let time = $state<string | null>(null);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
export interface DetailsField {
|
||||
label: string;
|
||||
value: string | number | undefined;
|
||||
value?: string | number;
|
||||
/** Custom content painted instead of `value`, for fields that are not plain text. */
|
||||
snippet?: Snippet;
|
||||
/** Hover text; defaults to the value. */
|
||||
|
||||
@@ -8,6 +8,15 @@
|
||||
import Spinner from "../icons/status/Spinner.svelte";
|
||||
import Button from "../library/buttons/Button.svelte";
|
||||
|
||||
interface Props {
|
||||
endpoint?: string;
|
||||
queryParams?: Record<string, unknown>;
|
||||
filenamePrefix?: string;
|
||||
totalItems?: number;
|
||||
size?: "sm" | "md";
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
let {
|
||||
endpoint = "/v4/gateway_charges",
|
||||
queryParams = {},
|
||||
@@ -15,14 +24,7 @@
|
||||
totalItems = undefined,
|
||||
size = "sm",
|
||||
disabled = false,
|
||||
} = $props<{
|
||||
endpoint?: string;
|
||||
queryParams?: Record<string, unknown>;
|
||||
filenamePrefix?: string;
|
||||
totalItems?: number;
|
||||
size?: "sm" | "md";
|
||||
disabled?: boolean;
|
||||
}>();
|
||||
}: Props = $props();
|
||||
|
||||
const iconSize = $derived(size === "md" ? "24" : "16");
|
||||
|
||||
|
||||
@@ -15,17 +15,14 @@
|
||||
const dateRegex =
|
||||
/^(dateCreated|dateUpdated)\[(after|before|strictly_after|strictly_before)\]$/;
|
||||
|
||||
let {
|
||||
title,
|
||||
filters,
|
||||
onCloseFilter,
|
||||
resource = undefined,
|
||||
} = $props<{
|
||||
interface Props {
|
||||
title: string;
|
||||
filters?: Record<string, any>;
|
||||
onCloseFilter: (filters: Record<string, any>) => void;
|
||||
resource?: FilterResource;
|
||||
}>();
|
||||
}
|
||||
|
||||
let { title, filters, onCloseFilter, resource = undefined }: Props = $props();
|
||||
|
||||
let tags: FilterTag[] = $state([]);
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
import type { Gateway } from "../../openapi/client";
|
||||
|
||||
const { gateways } = $props<{
|
||||
interface Props {
|
||||
gateways: Gateway[];
|
||||
}>();
|
||||
}
|
||||
|
||||
const { gateways }: Props = $props();
|
||||
</script>
|
||||
|
||||
<div class="flex flex-wrap gap-2">
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
|
||||
interface Props {
|
||||
children: Snippet;
|
||||
text?: string;
|
||||
duration?: number;
|
||||
tooltipClass?: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const {
|
||||
children,
|
||||
text = "¡Tooltip!",
|
||||
duration = 1000,
|
||||
tooltipClass,
|
||||
className = "",
|
||||
} = $props<{
|
||||
children: Snippet;
|
||||
text?: string;
|
||||
duration?: number;
|
||||
tooltipClass?: string;
|
||||
className?: string;
|
||||
}>();
|
||||
}: Props = $props();
|
||||
|
||||
const baseClasses =
|
||||
"text-white text-sm px-2 rounded z-[9999] backdrop-blur-sm whitespace-nowrap";
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import LanguagesDropdown from "../header/LanguagesDropdown.svelte";
|
||||
import Trash from "../icons/actions/Trash.svelte";
|
||||
import Button from "../library/buttons/Button.svelte";
|
||||
import DropdownMenu from "../library/dropdown/DropdownMenu.svelte";
|
||||
import DropdownSearch from "../library/dropdown/DropdownSearch.svelte";
|
||||
import DeleteModal from "../library/feedback/DeleteModal.svelte";
|
||||
import Title from "../library/typography/Title.svelte";
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
|
||||
let isAddModalOpen = $state(false);
|
||||
let languageSearch = $state("");
|
||||
let candidateOptions = $state<DropdownOption[]>([]);
|
||||
let selectedLanguageOption = $state<DropdownOption[]>([]);
|
||||
let isRemoveModalOpen = $state(false);
|
||||
let isRemoveAllModalOpen = $state(false);
|
||||
@@ -61,31 +60,24 @@
|
||||
function openAddModal() {
|
||||
languageSearch = "";
|
||||
selectedLanguageOption = [];
|
||||
refreshLanguageOptions();
|
||||
isAddModalOpen = true;
|
||||
}
|
||||
|
||||
function refreshLanguageOptions(query = "") {
|
||||
function searchLanguages(query: string): DropdownOption[] {
|
||||
// Once an option is picked its label fills the search; it must not filter the list.
|
||||
const search = query.trim().toLowerCase();
|
||||
const search = query.toLowerCase();
|
||||
const selectedLabel = ALL_LANGUAGE_OPTIONS.find(
|
||||
(option) => option.id === selectedLanguageOption[0]?.id,
|
||||
)?.label.toLowerCase();
|
||||
const needle = search && search !== selectedLabel ? search : "";
|
||||
|
||||
candidateOptions = ALL_LANGUAGE_OPTIONS.filter(
|
||||
return ALL_LANGUAGE_OPTIONS.filter(
|
||||
(option) =>
|
||||
!languages.includes(option.id) &&
|
||||
(!needle ||
|
||||
option.label.toLowerCase().includes(needle) ||
|
||||
option.id.includes(needle)),
|
||||
).map((option) => ({ ...option, selected: selectedLanguageOption[0]?.id === option.id }));
|
||||
}
|
||||
|
||||
function handleAddLanguageChange(option: DropdownOption) {
|
||||
selectedLanguageOption = [option];
|
||||
languageSearch = option.label;
|
||||
refreshLanguageOptions(option.label);
|
||||
);
|
||||
}
|
||||
|
||||
function confirmAddLanguage() {
|
||||
@@ -148,7 +140,7 @@
|
||||
|
||||
<Modal
|
||||
bind:open={isAddModalOpen}
|
||||
closeBtnClass="top-3 end-3 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
closeBtnClass="top-10 end-12 p-1.5 [&_svg]:size-7 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="backdrop:bg-overlay fixed top-1/2 left-1/2 mx-2 flex w-full max-w-178 -translate-x-1/2 -translate-y-1/2 flex-col gap-4 overflow-visible rounded-3xl border-b-0 bg-white p-6 shadow-lg backdrop:backdrop-blur-[5px] sm:mx-4 lg:mx-0"
|
||||
headerClass="border-b-0 md:p-0 p-0"
|
||||
bodyClass="md:p-0 p-0 overflow-y-visible border-b-0"
|
||||
@@ -165,16 +157,14 @@
|
||||
{$t("domain.translationLanguages.addModal.description")}
|
||||
</p>
|
||||
|
||||
<DropdownMenu
|
||||
<DropdownSearch
|
||||
variant="basic"
|
||||
singleSelect
|
||||
hasSearch
|
||||
bind:searchValue={languageSearch}
|
||||
bind:options={candidateOptions}
|
||||
search={searchLanguages}
|
||||
debounceMs={0}
|
||||
bind:value={languageSearch}
|
||||
bind:selected={selectedLanguageOption}
|
||||
onSearch={(query) => refreshLanguageOptions(query)}
|
||||
onChange={handleAddLanguageChange}
|
||||
searchPlaceholder={$t("domain.translationLanguages.addModal.searchPlaceholder")}
|
||||
placeholder={$t("domain.translationLanguages.addModal.searchPlaceholder")}
|
||||
itemClass="text-start"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { AdminSidebarItem } from "./AdminSidebar.svelte";
|
||||
|
||||
export interface AdminLink {
|
||||
/** i18n key, resolved via t() at render time */
|
||||
labelKey: string;
|
||||
@@ -33,6 +35,11 @@ export const ADMIN_SECTIONS: AdminSection[] = [
|
||||
labelKey: "pages.admin.nav.users",
|
||||
descriptionKey: "pages.admin.users.description",
|
||||
},
|
||||
{
|
||||
href: "/admin/categorization",
|
||||
labelKey: "pages.admin.nav.categorization",
|
||||
descriptionKey: "pages.admin.categorization.description",
|
||||
},
|
||||
{
|
||||
href: "/admin/comm",
|
||||
labelKey: "pages.admin.nav.comm",
|
||||
@@ -49,8 +56,37 @@ export const ADMIN_SECTIONS: AdminSection[] = [
|
||||
subSections: [
|
||||
{ href: "/admin/home/hero", labelKey: "pages.admin.home.tabs.hero" },
|
||||
{ href: "/admin/home/highlights", labelKey: "pages.admin.home.tabs.highlights" },
|
||||
{ href: "/admin/home/proposed", labelKey: "pages.admin.home.tabs.proposed" },
|
||||
{ href: "/admin/home/featured-users", labelKey: "pages.admin.home.tabs.featuredUsers" },
|
||||
{ href: "/admin/home/banners", labelKey: "pages.admin.home.tabs.banners" },
|
||||
],
|
||||
},
|
||||
{
|
||||
href: "/admin/customize",
|
||||
labelKey: "pages.admin.nav.customize",
|
||||
descriptionKey: "pages.admin.customize.description",
|
||||
subSections: [
|
||||
{ href: "/admin/customize/logo", labelKey: "pages.admin.customize.tabs.logo" },
|
||||
{ href: "/admin/customize/colors", labelKey: "pages.admin.customize.tabs.colors" },
|
||||
{ href: "/admin/customize/footer", labelKey: "pages.admin.customize.tabs.footer" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Sidebar entries for the sub-sections of a section, in the shape `WithSidebar` expects.
|
||||
*
|
||||
* Read out of the registry so that a sub-section is declared once: every page of a section
|
||||
* shares the very same sidebar, instead of each page folder carrying a copy of the list that
|
||||
* has to be kept in sync by hand.
|
||||
*
|
||||
* @param sectionHref the `href` of the section, e.g. "/admin/home"
|
||||
*/
|
||||
export function getSubSections(sectionHref: string): AdminSidebarItem[] {
|
||||
const section = ADMIN_SECTIONS.find((section) => section.href === sectionHref);
|
||||
|
||||
return (section?.subSections ?? []).map(({ labelKey, href }) => ({
|
||||
label: labelKey,
|
||||
href,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
<script lang="ts">
|
||||
import CategorizationTable, {
|
||||
type CategorizationRow,
|
||||
type CategorizationType,
|
||||
} from "./CategorizationTable.svelte";
|
||||
import CreateEditCategorizationModal from "./CreateEditCategorizationModal.svelte";
|
||||
import { session } from "../../../auth/store";
|
||||
import { locale, t } from "../../../i18n/store";
|
||||
import {
|
||||
apiCategoriesGetCollection,
|
||||
apiCategoriesIdDelete,
|
||||
apiThemesGetCollection,
|
||||
apiThemesIdDelete,
|
||||
type Category,
|
||||
type Theme,
|
||||
} from "../../../openapi/client/index.ts";
|
||||
import { toCollectionItems } from "../../../utils/hydra";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import DeleteModal from "../../library/feedback/DeleteModal.svelte";
|
||||
import Title from "../../library/typography/Title.svelte";
|
||||
|
||||
function authHeaders(): Record<string, string> {
|
||||
return Object.assign(
|
||||
{ Accept: "application/ld+json" },
|
||||
($session?.token.asHttpHeaders as Record<string, string>) ?? {},
|
||||
);
|
||||
}
|
||||
|
||||
let categories = $state<Category[]>([]);
|
||||
let themes = $state<Theme[]>([]);
|
||||
let isLoading = $state(true);
|
||||
|
||||
let modalOpen = $state(false);
|
||||
let modalMode = $state<"create" | "edit">("create");
|
||||
let modalType = $state<CategorizationType>("category");
|
||||
let editingItem = $state<Category | Theme | null>(null);
|
||||
|
||||
let deleteOpen = $state(false);
|
||||
let deleteRow = $state<CategorizationRow | null>(null);
|
||||
|
||||
const rows = $derived<CategorizationRow[]>([
|
||||
...categories.map((item) => ({ type: "category" as const, item })),
|
||||
...themes.map((item) => ({ type: "theme" as const, item })),
|
||||
]);
|
||||
|
||||
async function loadAll() {
|
||||
isLoading = true;
|
||||
try {
|
||||
const headers = { ...authHeaders(), "Accept-Language": $locale };
|
||||
|
||||
const [categoriesResponse, themesResponse] = await Promise.all([
|
||||
apiCategoriesGetCollection({ baseUrl: "/api/relay", headers }),
|
||||
apiThemesGetCollection({ baseUrl: "/api/relay", headers }),
|
||||
]);
|
||||
|
||||
if (categoriesResponse.error || themesResponse.error) {
|
||||
console.error(
|
||||
"Failed to load categories/themes:",
|
||||
categoriesResponse.error ?? themesResponse.error,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
categories = toCollectionItems<Category>(categoriesResponse.data);
|
||||
themes = toCollectionItems<Theme>(themesResponse.data);
|
||||
} catch (error) {
|
||||
console.error("Failed to load categories/themes:", error);
|
||||
} finally {
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
$locale;
|
||||
void loadAll();
|
||||
});
|
||||
|
||||
function openCreate(type: CategorizationType) {
|
||||
modalType = type;
|
||||
modalMode = "create";
|
||||
editingItem = null;
|
||||
modalOpen = true;
|
||||
}
|
||||
|
||||
function openEdit(row: CategorizationRow) {
|
||||
modalType = row.type;
|
||||
modalMode = "edit";
|
||||
editingItem = row.item;
|
||||
modalOpen = true;
|
||||
}
|
||||
|
||||
function openDelete(row: CategorizationRow) {
|
||||
deleteRow = row;
|
||||
deleteOpen = true;
|
||||
}
|
||||
|
||||
function typeKey(type: CategorizationType): string {
|
||||
return type === "category"
|
||||
? "pages.admin.categorization.table.types.category"
|
||||
: "pages.admin.categorization.table.types.theme";
|
||||
}
|
||||
|
||||
async function confirmDelete() {
|
||||
if (!deleteRow) return;
|
||||
|
||||
const { type, item } = deleteRow;
|
||||
const id = item.id;
|
||||
|
||||
if (!id) return;
|
||||
|
||||
try {
|
||||
const headers = authHeaders();
|
||||
|
||||
if (type === "category") {
|
||||
await apiCategoriesIdDelete({ baseUrl: "/api/relay", path: { id }, headers });
|
||||
} else {
|
||||
await apiThemesIdDelete({ baseUrl: "/api/relay", path: { id }, headers });
|
||||
}
|
||||
|
||||
deleteOpen = false;
|
||||
deleteRow = null;
|
||||
await loadAll();
|
||||
} catch (error) {
|
||||
console.error("Failed to delete categorization item:", error);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="wrapper">
|
||||
<div class="flex w-full flex-col gap-8 py-10">
|
||||
<header class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between sm:gap-6">
|
||||
<div class="flex flex-col gap-4">
|
||||
<Title level={2} variant="headline" weight="bold" color="default">
|
||||
{$t("pages.admin.categorization.title")}
|
||||
</Title>
|
||||
<p class="text-content">
|
||||
{$t("pages.admin.categorization.description")}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex shrink-0 flex-wrap items-center gap-2">
|
||||
<Button kind="secondary" onclick={() => openCreate("category")}>
|
||||
{$t("pages.admin.categorization.actions.createCategory")}
|
||||
</Button>
|
||||
<Button onclick={() => openCreate("theme")}>
|
||||
{$t("pages.admin.categorization.actions.createTheme")}
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<CategorizationTable {rows} {isLoading} onEdit={openEdit} onDelete={openDelete} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CreateEditCategorizationModal
|
||||
bind:open={modalOpen}
|
||||
mode={modalMode}
|
||||
type={modalType}
|
||||
item={editingItem}
|
||||
onSaved={loadAll}
|
||||
/>
|
||||
|
||||
<DeleteModal
|
||||
bind:open={deleteOpen}
|
||||
title={$t("pages.admin.categorization.delete.title", {
|
||||
type: deleteRow ? $t(typeKey(deleteRow.type)) : "",
|
||||
})}
|
||||
description={$t("pages.admin.categorization.delete.description", {
|
||||
name: deleteRow?.item.name ?? "",
|
||||
})}
|
||||
onclick={confirmDelete}
|
||||
/>
|
||||
@@ -0,0 +1,102 @@
|
||||
<script lang="ts" module>
|
||||
import type { Category, Theme } from "../../../openapi/client/index.ts";
|
||||
|
||||
export type CategorizationType = "category" | "theme";
|
||||
|
||||
export interface CategorizationRow {
|
||||
type: CategorizationType;
|
||||
item: Category | Theme;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { TableBodyCell } from "flowbite-svelte";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { t } from "../../../i18n/store";
|
||||
import { getLanguageDisplayName } from "../../../utils/lang";
|
||||
import Edit from "../../icons/actions/Edit.svelte";
|
||||
import Trash from "../../icons/actions/Trash.svelte";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import DataTable from "../../library/tables/DataTable.svelte";
|
||||
import Tag from "../../library/tags/Tag.svelte";
|
||||
|
||||
import type { DataTableHeader } from "../../library/tables/DataTable.svelte";
|
||||
|
||||
let {
|
||||
rows = [],
|
||||
isLoading = false,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: {
|
||||
rows: CategorizationRow[];
|
||||
isLoading: boolean;
|
||||
onEdit: (row: CategorizationRow) => void;
|
||||
onDelete: (row: CategorizationRow) => void;
|
||||
} = $props();
|
||||
|
||||
const headers: DataTableHeader[] = [
|
||||
{ key: "pages.admin.categorization.table.headers.name" },
|
||||
{ key: "pages.admin.categorization.table.headers.slug" },
|
||||
{ key: "pages.admin.categorization.table.headers.locales" },
|
||||
{ key: "pages.admin.categorization.table.headers.type" },
|
||||
{ key: "", class: "w-24" },
|
||||
];
|
||||
</script>
|
||||
|
||||
<DataTable
|
||||
{headers}
|
||||
{rows}
|
||||
{isLoading}
|
||||
emptyMessage="pages.admin.categorization.empty"
|
||||
currentPage={1}
|
||||
totalItems={rows.length}
|
||||
itemsPerPage={rows.length || 10}
|
||||
>
|
||||
{#snippet children(row: CategorizationRow)}
|
||||
<TableBodyCell class="border-variant1 rounded-l-md border-t border-b border-l p-4">
|
||||
<span class="text-content font-medium">{row.item.name}</span>
|
||||
</TableBodyCell>
|
||||
<TableBodyCell class="border-variant1 border-t border-b p-4">
|
||||
<span class="text-secondary text-sm">{row.item.slug ?? "—"}</span>
|
||||
</TableBodyCell>
|
||||
<TableBodyCell class="border-variant1 border-t border-b p-4">
|
||||
{(row.item.locales ?? [])
|
||||
.map((code: string) => getLanguageDisplayName(code) ?? code)
|
||||
.join(", ") || "—"}
|
||||
</TableBodyCell>
|
||||
<TableBodyCell class="border-variant1 border-t border-b p-4">
|
||||
<Tag
|
||||
variant="bold"
|
||||
class={twMerge(
|
||||
"text-secondary w-fit",
|
||||
row.type === "category" ? "bg-variant1" : "bg-variant2",
|
||||
)}
|
||||
>
|
||||
{row.type === "category"
|
||||
? $t("pages.admin.categorization.table.types.category")
|
||||
: $t("pages.admin.categorization.table.types.theme")}
|
||||
</Tag>
|
||||
</TableBodyCell>
|
||||
<TableBodyCell class="border-variant1 rounded-r-md border-t border-r border-b p-2">
|
||||
<div class="flex items-center justify-end gap-1">
|
||||
<Button
|
||||
kind="ghost"
|
||||
size="sm"
|
||||
class="rounded-full p-2.5"
|
||||
onclick={() => onEdit(row)}
|
||||
>
|
||||
<Edit class="size-5" />
|
||||
</Button>
|
||||
<Button
|
||||
kind="ghost"
|
||||
size="sm"
|
||||
class="text-tertiary inset-ring-tertiary rounded-full p-3"
|
||||
onclick={() => onDelete(row)}
|
||||
>
|
||||
<Trash class="size-4 text-current" />
|
||||
</Button>
|
||||
</div>
|
||||
</TableBodyCell>
|
||||
{/snippet}
|
||||
</DataTable>
|
||||
@@ -0,0 +1,323 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from "flowbite-svelte";
|
||||
|
||||
import { session } from "../../../auth/store";
|
||||
import { t } from "../../../i18n/store";
|
||||
import {
|
||||
apiCategoriesIdDelete,
|
||||
apiCategoriesIdOrSlugGet,
|
||||
apiCategoriesIdPatch,
|
||||
apiCategoriesPost,
|
||||
apiThemesIdDelete,
|
||||
apiThemesIdOrSlugGet,
|
||||
apiThemesIdPatch,
|
||||
apiThemesPost,
|
||||
type Category,
|
||||
type Theme,
|
||||
} from "../../../openapi/client/index.ts";
|
||||
import { getDefaultLanguage } from "../../../utils/consts";
|
||||
import {
|
||||
getLanguageDisplayName,
|
||||
primaryLanguage as pickPrimaryLanguage,
|
||||
} from "../../../utils/lang";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import TextInput from "../../library/inputs/TextInput.svelte";
|
||||
import Title from "../../library/typography/Title.svelte";
|
||||
import TranslationLanguages from "../TranslationLanguages.svelte";
|
||||
|
||||
let {
|
||||
open = $bindable(false),
|
||||
mode = "create",
|
||||
type = "category",
|
||||
item = null,
|
||||
onSaved,
|
||||
}: {
|
||||
open: boolean;
|
||||
mode: "create" | "edit";
|
||||
type: "category" | "theme";
|
||||
item?: Category | Theme | null;
|
||||
onSaved?: () => Promise<void> | void;
|
||||
} = $props();
|
||||
|
||||
const defaultLanguage = getDefaultLanguage();
|
||||
|
||||
interface Texts {
|
||||
name: string;
|
||||
}
|
||||
|
||||
const emptyTexts = (): Texts => ({ name: "" });
|
||||
|
||||
let languages = $state<string[]>([defaultLanguage]);
|
||||
let selectedLanguage = $state(defaultLanguage);
|
||||
let texts = $state<Record<string, Texts>>({ [defaultLanguage]: emptyTexts() });
|
||||
|
||||
let originalLocales = $state<string[]>([]);
|
||||
let originalId = $state<string | null>(null);
|
||||
let originalSlug = $state<string | null>(null);
|
||||
|
||||
let isLoading = $state(false);
|
||||
let isSubmitting = $state(false);
|
||||
let errorMessage = $state("");
|
||||
|
||||
const active = $derived(texts[selectedLanguage] ?? emptyTexts());
|
||||
|
||||
let requestId = 0;
|
||||
|
||||
function authHeaders(): Record<string, string> {
|
||||
return Object.assign(
|
||||
{ Accept: "application/ld+json" },
|
||||
($session?.token.asHttpHeaders as Record<string, string>) ?? {},
|
||||
);
|
||||
}
|
||||
|
||||
function initCreate() {
|
||||
requestId++;
|
||||
languages = [defaultLanguage];
|
||||
selectedLanguage = defaultLanguage;
|
||||
texts = { [defaultLanguage]: emptyTexts() };
|
||||
originalLocales = [];
|
||||
originalId = null;
|
||||
originalSlug = null;
|
||||
isLoading = false;
|
||||
isSubmitting = false;
|
||||
errorMessage = "";
|
||||
}
|
||||
|
||||
async function initEdit(target: Category | Theme) {
|
||||
const locales = target.locales?.length ? [...target.locales] : [defaultLanguage];
|
||||
const token = ++requestId;
|
||||
|
||||
originalLocales = locales;
|
||||
originalId = target.id ?? null;
|
||||
originalSlug = target.slug ?? null;
|
||||
languages = locales;
|
||||
selectedLanguage = locales[0];
|
||||
texts = Object.fromEntries(
|
||||
locales.map((code) => [code, { name: code === locales[0] ? (target.name ?? "") : "" }]),
|
||||
);
|
||||
isSubmitting = false;
|
||||
errorMessage = "";
|
||||
isLoading = Boolean(target.id);
|
||||
|
||||
if (!target.id) return;
|
||||
|
||||
try {
|
||||
let failed = false;
|
||||
|
||||
const names = await Promise.all(
|
||||
locales.map(async (code): Promise<[string, string]> => {
|
||||
const options = {
|
||||
baseUrl: "/api/relay",
|
||||
path: { idOrSlug: target.id! },
|
||||
headers: { ...authHeaders(), "Accept-Language": code },
|
||||
};
|
||||
const { data, error } =
|
||||
type === "category"
|
||||
? await apiCategoriesIdOrSlugGet(options)
|
||||
: await apiThemesIdOrSlugGet(options);
|
||||
|
||||
if (error) {
|
||||
failed = true;
|
||||
console.error(`Failed to load ${type} translation "${code}":`, error);
|
||||
return [code, ""];
|
||||
}
|
||||
|
||||
return [code, data?.name ?? ""];
|
||||
}),
|
||||
);
|
||||
|
||||
if (token !== requestId) return;
|
||||
|
||||
texts = Object.fromEntries(names.map(([code, name]) => [code, { name }]));
|
||||
|
||||
if (failed) {
|
||||
errorMessage = $t("pages.admin.categorization.errors.loadFailed");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to load ${type} translations:`, error);
|
||||
|
||||
if (token === requestId) {
|
||||
errorMessage = $t("pages.admin.categorization.errors.loadFailed");
|
||||
}
|
||||
} finally {
|
||||
if (token === requestId) isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (!open) return;
|
||||
|
||||
if (mode === "create") {
|
||||
initCreate();
|
||||
} else if (item) {
|
||||
void initEdit(item);
|
||||
}
|
||||
});
|
||||
|
||||
function textFor(code: string): string {
|
||||
return texts[code]?.name.trim() ?? "";
|
||||
}
|
||||
|
||||
async function saveTranslation(id: string, code: string, name: string): Promise<void> {
|
||||
const options = {
|
||||
baseUrl: "/api/relay",
|
||||
path: { id },
|
||||
body: { name },
|
||||
headers: { ...authHeaders(), "Content-Language": code },
|
||||
};
|
||||
|
||||
if (type === "category") {
|
||||
await apiCategoriesIdPatch(options);
|
||||
} else {
|
||||
await apiThemesIdPatch(options);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteTranslation(id: string, code: string): Promise<void> {
|
||||
const options = {
|
||||
baseUrl: "/api/relay",
|
||||
path: { id },
|
||||
headers: { ...authHeaders(), "Content-Language": code },
|
||||
};
|
||||
|
||||
if (type === "category") {
|
||||
await apiCategoriesIdDelete(options);
|
||||
} else {
|
||||
await apiThemesIdDelete(options);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
errorMessage = "";
|
||||
|
||||
const missing = languages.filter((code) => !textFor(code));
|
||||
|
||||
if (missing.length > 0) {
|
||||
selectedLanguage = missing[0];
|
||||
errorMessage = $t("pages.admin.categorization.errors.incompleteLanguages", {
|
||||
languages: missing.map((code) => getLanguageDisplayName(code) ?? code).join(", "),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
isSubmitting = true;
|
||||
|
||||
try {
|
||||
const primary = pickPrimaryLanguage(languages, defaultLanguage);
|
||||
const translations = languages.filter((code) => code !== primary);
|
||||
|
||||
if (mode === "create") {
|
||||
const { data, error } =
|
||||
type === "category"
|
||||
? await apiCategoriesPost({
|
||||
baseUrl: "/api/relay",
|
||||
body: { name: textFor(primary) },
|
||||
headers: { ...authHeaders(), "Content-Language": primary },
|
||||
})
|
||||
: await apiThemesPost({
|
||||
baseUrl: "/api/relay",
|
||||
body: { name: textFor(primary) },
|
||||
headers: { ...authHeaders(), "Content-Language": primary },
|
||||
});
|
||||
|
||||
if (error || !data?.id) {
|
||||
throw error ?? new Error("The resource was created without an identifier");
|
||||
}
|
||||
|
||||
for (const code of translations) {
|
||||
await saveTranslation(data.id, code, textFor(code));
|
||||
}
|
||||
} else if (originalId) {
|
||||
for (const code of languages) {
|
||||
await saveTranslation(originalId, code, textFor(code));
|
||||
}
|
||||
|
||||
for (const code of originalLocales.filter((code) => !languages.includes(code))) {
|
||||
await deleteTranslation(originalId, code);
|
||||
}
|
||||
}
|
||||
|
||||
await onSaved?.();
|
||||
open = false;
|
||||
} catch (error) {
|
||||
console.error("Failed to save categorization item:", error);
|
||||
errorMessage = $t("pages.admin.categorization.errors.saveFailed");
|
||||
} finally {
|
||||
isSubmitting = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
bind:open
|
||||
closeBtnClass="top-3 end-3 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="backdrop:bg-overlay fixed top-1/2 left-1/2 mx-2 flex w-full max-w-2xl -translate-x-1/2 -translate-y-1/2 flex-col gap-4 overflow-visible rounded-3xl border-b-0 bg-white p-6 shadow-lg backdrop:backdrop-blur-[5px] sm:mx-4 lg:mx-0"
|
||||
headerClass="border-b-0 md:p-0 p-0"
|
||||
bodyClass="md:p-0 p-0 overflow-y-visible border-b-0"
|
||||
footerClass="md:p-0 p-0 flex items-center justify-end gap-4 border-b-0"
|
||||
>
|
||||
{#snippet header()}
|
||||
<Title level={2} variant="subsection">
|
||||
{mode === "create"
|
||||
? type === "category"
|
||||
? $t("pages.admin.categorization.modal.createCategory")
|
||||
: $t("pages.admin.categorization.modal.createTheme")
|
||||
: type === "category"
|
||||
? $t("pages.admin.categorization.modal.editCategory")
|
||||
: $t("pages.admin.categorization.modal.editTheme")}
|
||||
</Title>
|
||||
{/snippet}
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<TranslationLanguages
|
||||
bind:languages
|
||||
bind:selected={selectedLanguage}
|
||||
onAdd={(code) => (texts[code] = emptyTexts())}
|
||||
onRemove={(code) => delete texts[code]}
|
||||
onSelect={() => (errorMessage = "")}
|
||||
/>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<span class="text-content text-sm font-medium">
|
||||
{$t("pages.admin.categorization.modal.name")}
|
||||
</span>
|
||||
<TextInput
|
||||
bind:value={() => active.name, (value) => (active.name = String(value))}
|
||||
placeholder={$t("pages.admin.categorization.modal.name")}
|
||||
disabled={isLoading || isSubmitting}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{#if mode === "edit" && (originalSlug || originalId)}
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-content text-sm font-medium">
|
||||
{$t("pages.admin.categorization.modal.slug")}
|
||||
</span>
|
||||
<span class="text-secondary text-sm">{originalSlug ?? "—"}</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-content text-sm font-medium">
|
||||
{$t("pages.admin.categorization.modal.locales")}
|
||||
</span>
|
||||
<span class="text-secondary text-sm">
|
||||
{originalLocales.join(", ") || "—"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if errorMessage}
|
||||
<p class="text-tertiary text-sm">{errorMessage}</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#snippet footer()}
|
||||
<Button kind="ghost" onclick={() => (open = false)} class="w-fit" disabled={isSubmitting}>
|
||||
{$t("pages.admin.categorization.modal.cancel")}
|
||||
</Button>
|
||||
<Button onclick={handleSubmit} class="w-fit" disabled={isLoading || isSubmitting}>
|
||||
{$t("pages.admin.categorization.modal.save")}
|
||||
</Button>
|
||||
{/snippet}
|
||||
</Modal>
|
||||
@@ -16,8 +16,10 @@
|
||||
initialFormState,
|
||||
initialFiscal,
|
||||
type CreateChargeForm,
|
||||
type CreateChargeFormFiscal,
|
||||
type DonorType,
|
||||
} from "../../../types/admin-charge";
|
||||
import { useFormDraft, restoreFields } from "../../../utils/forms/useFormDraft.svelte";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import Title from "../../library/typography/Title.svelte";
|
||||
|
||||
@@ -50,6 +52,98 @@
|
||||
let submitState = $state<"idle" | "submitting" | "error">("idle");
|
||||
let submitError = $state<string | null>(null);
|
||||
|
||||
/**
|
||||
* The fiscal data of the donor, without the tax ids.
|
||||
*
|
||||
* They are fiscal data and are left out on purpose: whoever fills the form in types them
|
||||
* again.
|
||||
*/
|
||||
type FiscalDraft =
|
||||
| { kind: "organization"; legalName: string; repFirstName: string; repLastName: string }
|
||||
| { kind: "individual"; firstName: string; lastName: string };
|
||||
|
||||
function fiscalDraft(fiscal: CreateChargeFormFiscal): FiscalDraft {
|
||||
if (fiscal.kind === "organization") {
|
||||
return {
|
||||
kind: "organization",
|
||||
legalName: fiscal.legalName,
|
||||
repFirstName: fiscal.repFirstName,
|
||||
repLastName: fiscal.repLastName,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
kind: "individual",
|
||||
firstName: fiscal.firstName,
|
||||
lastName: fiscal.lastName,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the fiscal data of the donor, with the tax ids empty because they are not
|
||||
* kept. The kind comes with it, so the effect that keeps both in step leaves it alone.
|
||||
*/
|
||||
function fiscalFromDraft(draft: FiscalDraft): CreateChargeFormFiscal {
|
||||
if (draft.kind === "organization") {
|
||||
return {
|
||||
kind: "organization",
|
||||
legalName: draft.legalName,
|
||||
taxId: "",
|
||||
repFirstName: draft.repFirstName,
|
||||
repLastName: draft.repLastName,
|
||||
repTaxId: "",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
kind: "individual",
|
||||
firstName: draft.firstName,
|
||||
lastName: draft.lastName,
|
||||
taxId: "",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The password of the donor is left out on purpose, it is a credential.
|
||||
*/
|
||||
type ChargeDraft = {
|
||||
currentStep: StepKey;
|
||||
existingUser: CreateChargeForm["existingUser"];
|
||||
user: Pick<CreateChargeForm["user"], "type" | "email">;
|
||||
fiscal: FiscalDraft;
|
||||
charge: CreateChargeForm["charge"];
|
||||
};
|
||||
|
||||
const { restored } = useFormDraft<ChargeDraft>("admin-create-charge", () => ({
|
||||
currentStep,
|
||||
existingUser: form.existingUser,
|
||||
user: { type: form.user.type, email: form.user.email },
|
||||
fiscal: fiscalDraft(form.fiscal),
|
||||
charge: form.charge,
|
||||
}));
|
||||
|
||||
/**
|
||||
* Puts back what was kept before the language switch.
|
||||
*/
|
||||
function restoreCharge(draft: Partial<ChargeDraft>) {
|
||||
currentStep = draft.currentStep ?? "user";
|
||||
form.existingUser = draft.existingUser ?? null;
|
||||
|
||||
restoreFields(form.user, draft.user, ["type", "email"]);
|
||||
|
||||
if (draft.charge) {
|
||||
form.charge = draft.charge;
|
||||
}
|
||||
|
||||
if (draft.fiscal) {
|
||||
form.fiscal = fiscalFromDraft(draft.fiscal);
|
||||
}
|
||||
}
|
||||
|
||||
if (restored) {
|
||||
restoreCharge(restored);
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
submitting = submitState === "submitting";
|
||||
});
|
||||
@@ -255,7 +349,7 @@
|
||||
<span
|
||||
class={`flex size-7 shrink-0 items-center justify-center rounded-full text-xs font-bold transition-colors ${
|
||||
done
|
||||
? "bg-primary text-secondary"
|
||||
? "bg-primary text-on-primary"
|
||||
: active
|
||||
? "bg-secondary text-white"
|
||||
: "bg-grey text-secondary"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
} from "flowbite-svelte";
|
||||
|
||||
import { t } from "../../../i18n/store";
|
||||
import { useFormDraft } from "../../../utils/forms/useFormDraft.svelte";
|
||||
import PlusIcon from "../../icons/actions/PlusIcon.svelte";
|
||||
import FiltersIcon from "../../icons/filters/Filters.svelte";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
@@ -88,6 +89,38 @@
|
||||
|
||||
let isSubmitting = $state(false);
|
||||
|
||||
/**
|
||||
* The newsletter holds no sensitive data, so the whole form can be kept.
|
||||
*/
|
||||
const { restored } = useFormDraft("admin-newsletter", () => ({
|
||||
selectedTemplate,
|
||||
recipientBlocks,
|
||||
selectedRecipients,
|
||||
isTest,
|
||||
onlySpanish,
|
||||
}));
|
||||
if (restored) {
|
||||
if (restored.selectedTemplate !== undefined) {
|
||||
selectedTemplate = restored.selectedTemplate;
|
||||
}
|
||||
|
||||
if (restored.recipientBlocks) {
|
||||
recipientBlocks = restored.recipientBlocks;
|
||||
}
|
||||
|
||||
if (restored.selectedRecipients) {
|
||||
selectedRecipients = restored.selectedRecipients;
|
||||
}
|
||||
|
||||
if (restored.isTest !== undefined) {
|
||||
isTest = restored.isTest;
|
||||
}
|
||||
|
||||
if (restored.onlySpanish !== undefined) {
|
||||
onlySpanish = restored.onlySpanish;
|
||||
}
|
||||
}
|
||||
|
||||
const recipientOptions = $derived([
|
||||
{ value: "all", label: $t("pages.admin.newsletter.send.recipients.all") },
|
||||
{ value: "promoters", label: $t("pages.admin.newsletter.send.recipients.promoters") },
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { locale, t } from "../../../../i18n/store";
|
||||
import { BLOG_SECTIONS } from "../../../../utils/blog";
|
||||
import { getDefaultLanguage } from "../../../../utils/consts";
|
||||
import { useFormDraft, restoreFields } from "../../../../utils/forms/useFormDraft.svelte";
|
||||
import {
|
||||
getLanguageDisplayName,
|
||||
primaryLanguage as pickPrimaryLanguage,
|
||||
@@ -50,6 +51,8 @@
|
||||
const contentId = $props.id();
|
||||
let publishedAt = $state(initial?.publishedAt ?? new Date());
|
||||
let section = $state<BlogSection>(initial?.section ?? "news");
|
||||
let author = $state(initial?.author ?? "");
|
||||
let videoUrl = $state(initial?.videoUrl ?? "");
|
||||
|
||||
// Only URL and type are stored, so rebuild what FileUpload needs to list the current header.
|
||||
let header = $state<UploadedObject[]>(
|
||||
@@ -71,25 +74,24 @@
|
||||
const defaultLanguage = getDefaultLanguage();
|
||||
|
||||
// Every language's texts live here, the base one included, and are saved together.
|
||||
let texts = $state<Record<string, Texts>>(
|
||||
initial
|
||||
? Object.fromEntries(
|
||||
initial.languages.map((code) => {
|
||||
const stored =
|
||||
code === initial.language ? initial : initial.translations[code];
|
||||
const initialTexts: Record<string, Texts> = initial
|
||||
? Object.fromEntries(
|
||||
initial.languages.map((code) => {
|
||||
const stored = code === initial.language ? initial : initial.translations[code];
|
||||
|
||||
return [
|
||||
code,
|
||||
{
|
||||
title: stored?.title ?? "",
|
||||
subtitle: stored?.subtitle ?? "",
|
||||
content: stored?.content ?? "",
|
||||
},
|
||||
];
|
||||
}),
|
||||
)
|
||||
: { [defaultLanguage]: emptyTexts() },
|
||||
);
|
||||
return [
|
||||
code,
|
||||
{
|
||||
title: stored?.title ?? "",
|
||||
subtitle: stored?.subtitle ?? "",
|
||||
content: stored?.content ?? "",
|
||||
},
|
||||
];
|
||||
}),
|
||||
)
|
||||
: { [defaultLanguage]: emptyTexts() };
|
||||
|
||||
let texts = $state<Record<string, Texts>>(initialTexts);
|
||||
let languages = $state<string[]>(initial?.languages ?? [defaultLanguage]);
|
||||
let selectedLanguage = $state(untrack(() => languages[0]));
|
||||
const active = $derived(texts[selectedLanguage]);
|
||||
@@ -103,6 +105,59 @@
|
||||
fieldErrors = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Nothing in this form is sensitive, so all of it can be kept. The header is kept by URL
|
||||
* and type, the way it is sent to the API.
|
||||
*/
|
||||
const { restored } = useFormDraft("admin-comm-blog", () => ({
|
||||
texts,
|
||||
languages,
|
||||
selectedLanguage,
|
||||
publishedAt: publishedAt.toISOString(),
|
||||
section,
|
||||
author,
|
||||
videoUrl,
|
||||
header: header.map(({ url, type }) => ({ url, type })),
|
||||
}));
|
||||
|
||||
if (restored) {
|
||||
restoreFields(texts, restored.texts);
|
||||
|
||||
if (restored.languages) {
|
||||
languages = restored.languages;
|
||||
}
|
||||
|
||||
if (restored.selectedLanguage) {
|
||||
selectedLanguage = restored.selectedLanguage;
|
||||
}
|
||||
|
||||
if (restored.publishedAt) {
|
||||
publishedAt = new Date(restored.publishedAt);
|
||||
}
|
||||
|
||||
if (restored.section) {
|
||||
section = restored.section;
|
||||
}
|
||||
|
||||
if (restored.author !== undefined) {
|
||||
author = restored.author;
|
||||
}
|
||||
|
||||
if (restored.videoUrl !== undefined) {
|
||||
videoUrl = restored.videoUrl;
|
||||
}
|
||||
|
||||
if (restored.header) {
|
||||
header = restored.header.map(({ url, type }) => ({
|
||||
id: url,
|
||||
url,
|
||||
type,
|
||||
size: 0,
|
||||
name: url.split("/").pop() ?? "",
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
async function submit(publish: boolean) {
|
||||
fieldErrors = {};
|
||||
|
||||
@@ -242,7 +297,7 @@
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<TextInput
|
||||
name="author"
|
||||
value={post?.author ?? ""}
|
||||
bind:value={author}
|
||||
placeholder={$t("pages.admin.comm.blog.form.authorPlaceholder")}
|
||||
/>
|
||||
<DateInput
|
||||
@@ -294,7 +349,7 @@
|
||||
</Title>
|
||||
<TextInput
|
||||
name="videoUrl"
|
||||
value={post?.videoUrl ?? ""}
|
||||
bind:value={videoUrl}
|
||||
placeholder={$t("pages.admin.comm.blog.form.videoPlaceholder")}
|
||||
error={fieldErrors.videoUrl && $t(fieldErrors.videoUrl)}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
<script lang="ts">
|
||||
import { actions } from "astro:actions";
|
||||
import { untrack } from "svelte";
|
||||
|
||||
import { t } from "../../../i18n/store";
|
||||
import {
|
||||
MINIMUM_CONTRAST_RATIO,
|
||||
validateThemeColorContrast,
|
||||
} from "../../../utils/colorContrast";
|
||||
import {
|
||||
DARK_THEME_COLOR_DEFAULTS,
|
||||
DARK_THEME_COLOR_TOKENS,
|
||||
GENERIC_THEME_COLOR_TOKENS,
|
||||
LIGHT_THEME_COLOR_TOKENS,
|
||||
THEME_COLOR_DEFAULTS,
|
||||
THEME_COLOR_TOKENS,
|
||||
isHexColor,
|
||||
} from "../../../utils/themeColors";
|
||||
import ActionableButton from "../../library/buttons/ActionableButton.svelte";
|
||||
import Toast from "../../library/feedback/Toast.svelte";
|
||||
import ColorInput from "../../library/inputs/ColorInput.svelte";
|
||||
import Tabs from "../../library/layout/Tabs.svelte";
|
||||
import Title from "../../library/typography/Title.svelte";
|
||||
|
||||
import type { ContrastWarning } from "../../../utils/colorContrast";
|
||||
import type {
|
||||
DarkThemeColors,
|
||||
DarkThemeColorToken,
|
||||
GenericThemeColorToken,
|
||||
ThemeColors,
|
||||
ThemeColorToken,
|
||||
} from "../../../utils/themeColors";
|
||||
|
||||
interface Props {
|
||||
config: {
|
||||
lightColors: ThemeColors;
|
||||
darkColors: DarkThemeColors;
|
||||
};
|
||||
}
|
||||
|
||||
let { config }: Props = $props();
|
||||
|
||||
const initialConfig = untrack(() => config);
|
||||
let lightColors = $state<ThemeColors>({ ...initialConfig.lightColors });
|
||||
let darkColors = $state<DarkThemeColors>({ ...initialConfig.darkColors });
|
||||
let activeTheme = $state<"generic" | "light" | "dark">("generic");
|
||||
let showError = $state(false);
|
||||
let errorMessage = $state("");
|
||||
let showSuccess = $state(false);
|
||||
let successMessage = $state("");
|
||||
|
||||
const tabs = $derived([
|
||||
{ id: "generic", label: $t("pages.admin.customize.colors.themes.generic") },
|
||||
{ id: "light", label: $t("pages.admin.customize.colors.themes.light") },
|
||||
{ id: "dark", label: $t("pages.admin.customize.colors.themes.dark") },
|
||||
]);
|
||||
const contrastWarnings = $derived(validateThemeColorContrast(lightColors, darkColors));
|
||||
const hasInvalidColors = $derived(
|
||||
!THEME_COLOR_TOKENS.every((token) => isHexColor(lightColors[token])) ||
|
||||
!DARK_THEME_COLOR_TOKENS.every((token) => isHexColor(darkColors[token])),
|
||||
);
|
||||
|
||||
function tokenLabel(token: ThemeColorToken): string {
|
||||
return $t(`pages.admin.customize.colors.tokens.${token}`);
|
||||
}
|
||||
|
||||
function warningMessage(warning: ContrastWarning, includeTheme = false): string {
|
||||
return $t(
|
||||
includeTheme
|
||||
? "pages.admin.customize.colors.contrast.warningWithTheme"
|
||||
: "pages.admin.customize.colors.contrast.warning",
|
||||
{
|
||||
theme: $t(`pages.admin.customize.colors.themes.${warning.theme}`),
|
||||
text: tokenLabel(warning.textToken),
|
||||
background: tokenLabel(warning.backgroundToken),
|
||||
ratio: warning.ratio,
|
||||
minimum: MINIMUM_CONTRAST_RATIO,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function warningsFor(
|
||||
theme: "light" | "dark",
|
||||
token: ThemeColorToken | DarkThemeColorToken,
|
||||
): string[] {
|
||||
return contrastWarnings
|
||||
.filter((warning) => warning.theme === theme && warning.textToken === token)
|
||||
.map((warning) => warningMessage(warning));
|
||||
}
|
||||
|
||||
function genericWarningsFor(token: GenericThemeColorToken): string[] {
|
||||
return contrastWarnings
|
||||
.filter((warning) => warning.textToken === token)
|
||||
.map((warning) => warningMessage(warning, true));
|
||||
}
|
||||
|
||||
function showFailure(message: string): never {
|
||||
errorMessage = message;
|
||||
showError = true;
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
if (hasInvalidColors) {
|
||||
showFailure($t("pages.admin.customize.colors.errors.invalid"));
|
||||
}
|
||||
|
||||
const { error } = await actions.saveThemeColors({ lightColors, darkColors });
|
||||
|
||||
if (error) showFailure(error.message);
|
||||
|
||||
successMessage = $t("pages.admin.customize.colors.feedback.saved");
|
||||
showSuccess = true;
|
||||
}
|
||||
|
||||
async function handleReset() {
|
||||
if (!window.confirm($t("pages.admin.customize.colors.reset.confirm"))) return;
|
||||
|
||||
const { error } = await actions.resetThemeColors({});
|
||||
|
||||
if (error) showFailure(error.message);
|
||||
|
||||
lightColors = { ...THEME_COLOR_DEFAULTS };
|
||||
darkColors = { ...DARK_THEME_COLOR_DEFAULTS };
|
||||
successMessage = $t("pages.admin.customize.colors.feedback.reset");
|
||||
showSuccess = true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-10">
|
||||
<header class="flex flex-col justify-between gap-6 lg:flex-row lg:items-start">
|
||||
<div class="flex max-w-2xl flex-col gap-2">
|
||||
<Title level={2} variant="headline">
|
||||
{$t("pages.admin.customize.colors.title")}
|
||||
</Title>
|
||||
<p class="text-content text-base">
|
||||
{$t("pages.admin.customize.colors.description")}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex shrink-0 flex-col gap-3 sm:flex-row">
|
||||
<ActionableButton action={handleReset} autoreset={2000} kind="ghost" class="w-fit px-6">
|
||||
{$t("pages.admin.customize.colors.reset.button")}
|
||||
</ActionableButton>
|
||||
<ActionableButton
|
||||
action={handleSave}
|
||||
autoreset={2000}
|
||||
class="w-fit px-6"
|
||||
disabled={hasInvalidColors}
|
||||
>
|
||||
{$t("pages.admin.customize.colors.save")}
|
||||
</ActionableButton>
|
||||
</div>
|
||||
</header>
|
||||
<section
|
||||
class="bg-purple-soft border-grey flex flex-col gap-3 rounded-xl border p-4 shadow-sm"
|
||||
aria-label={$t("pages.admin.customize.colors.contrast.title")}
|
||||
>
|
||||
<Title level={3} variant="subsection">
|
||||
{$t("pages.admin.customize.colors.contrast.title")}
|
||||
</Title>
|
||||
<p class="text-content text-sm">
|
||||
{$t("pages.admin.customize.colors.contrast.description", {
|
||||
minimum: MINIMUM_CONTRAST_RATIO,
|
||||
})}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<Tabs
|
||||
{tabs}
|
||||
activeTab={activeTheme}
|
||||
alignment="left"
|
||||
useDataAttributes={false}
|
||||
onTabChange={(tab) => (activeTheme = tab as "generic" | "light" | "dark")}
|
||||
/>
|
||||
|
||||
{#if activeTheme === "generic"}
|
||||
<section class="flex flex-col gap-6">
|
||||
<div>
|
||||
<Title level={3} variant="subsection">
|
||||
{$t("pages.admin.customize.colors.themes.generic")}
|
||||
</Title>
|
||||
<p class="text-content text-sm">
|
||||
{$t("pages.admin.customize.colors.themes.genericDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 items-start gap-6 md:grid-cols-2 xl:grid-cols-3">
|
||||
{#each GENERIC_THEME_COLOR_TOKENS as token}
|
||||
<ColorInput
|
||||
bind:value={lightColors[token]}
|
||||
labelText={tokenLabel(token)}
|
||||
helperText={`--color-${token}`}
|
||||
pickerLabel={$t("pages.admin.customize.colors.picker", {
|
||||
color: tokenLabel(token),
|
||||
})}
|
||||
error={!isHexColor(lightColors[token])
|
||||
? $t("pages.admin.customize.colors.errors.hex")
|
||||
: undefined}
|
||||
contrastWarnings={genericWarningsFor(token)}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
</section>
|
||||
{:else if activeTheme === "light"}
|
||||
<section class="flex flex-col gap-6">
|
||||
<div>
|
||||
<Title level={3} variant="subsection">
|
||||
{$t("pages.admin.customize.colors.themes.light")}
|
||||
</Title>
|
||||
<p class="text-content text-sm">
|
||||
{$t("pages.admin.customize.colors.themes.lightDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 items-start gap-6 md:grid-cols-2 xl:grid-cols-3">
|
||||
{#each LIGHT_THEME_COLOR_TOKENS as token}
|
||||
<ColorInput
|
||||
bind:value={lightColors[token]}
|
||||
labelText={tokenLabel(token)}
|
||||
helperText={`--color-${token}`}
|
||||
pickerLabel={$t("pages.admin.customize.colors.picker", {
|
||||
color: tokenLabel(token),
|
||||
})}
|
||||
error={!isHexColor(lightColors[token])
|
||||
? $t("pages.admin.customize.colors.errors.hex")
|
||||
: undefined}
|
||||
contrastWarnings={warningsFor("light", token)}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
</section>
|
||||
{:else}
|
||||
<section class="flex flex-col gap-6">
|
||||
<div>
|
||||
<Title level={3} variant="subsection">
|
||||
{$t("pages.admin.customize.colors.themes.dark")}
|
||||
</Title>
|
||||
<p class="text-content text-sm">
|
||||
{$t("pages.admin.customize.colors.themes.darkDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 items-start gap-6 md:grid-cols-2 xl:grid-cols-3">
|
||||
{#each DARK_THEME_COLOR_TOKENS as token}
|
||||
<ColorInput
|
||||
bind:value={darkColors[token]}
|
||||
labelText={tokenLabel(token)}
|
||||
helperText={`--color-${token}`}
|
||||
pickerLabel={$t("pages.admin.customize.colors.picker", {
|
||||
color: tokenLabel(token),
|
||||
})}
|
||||
error={!isHexColor(darkColors[token])
|
||||
? $t("pages.admin.customize.colors.errors.hex")
|
||||
: undefined}
|
||||
contrastWarnings={warningsFor("dark", token)}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<Toast floating variant="error" bind:showToast={showError}>{errorMessage}</Toast>
|
||||
<Toast floating variant="success" bind:showToast={showSuccess}>{successMessage}</Toast>
|
||||
@@ -0,0 +1,486 @@
|
||||
<script lang="ts">
|
||||
import { actions } from "astro:actions";
|
||||
import { Modal } from "flowbite-svelte";
|
||||
import { tick, untrack } from "svelte";
|
||||
|
||||
import { languagesList, type Locale } from "../../../../i18n/locales";
|
||||
import { t } from "../../../../i18n/store";
|
||||
import { localized } from "../../../../layouts/footer-data";
|
||||
import { FOOTER_SOCIAL_NETWORKS } from "../../../../types/footer";
|
||||
import { getDefaultLanguage } from "../../../../utils/consts";
|
||||
import FooterView from "../../../footer/FooterView.svelte";
|
||||
import Trash from "../../../icons/actions/Trash.svelte";
|
||||
import Chevron from "../../../icons/navigation/Chevron.svelte";
|
||||
import ActionableButton from "../../../library/buttons/ActionableButton.svelte";
|
||||
import Button from "../../../library/buttons/Button.svelte";
|
||||
import Toast from "../../../library/feedback/Toast.svelte";
|
||||
import Checkbox from "../../../library/inputs/Checkbox.svelte";
|
||||
import ImageUploadModal from "../../../library/inputs/ImageUploadModal.svelte";
|
||||
import Select from "../../../library/inputs/Select.svelte";
|
||||
import TextInput from "../../../library/inputs/TextInput.svelte";
|
||||
import TabNavigation from "../../../library/layout/TabNavigation.svelte";
|
||||
import Title from "../../../library/typography/Title.svelte";
|
||||
|
||||
import type {
|
||||
FooterConfig,
|
||||
FooterSection,
|
||||
FooterLinkItem,
|
||||
FooterPartner,
|
||||
LocalizedText,
|
||||
} from "../../../../types/footer";
|
||||
import type { UploadedObject } from "../../../../utils/media/objectStorage.types";
|
||||
|
||||
interface Props {
|
||||
config: FooterConfig;
|
||||
}
|
||||
|
||||
let { config: initial }: Props = $props();
|
||||
|
||||
const defaultLanguage = getDefaultLanguage() as Locale;
|
||||
|
||||
// Own copy, sent whole on save. `$state.snapshot` because Astro hydrates props as a
|
||||
// `$state` proxy, which `structuredClone` cannot copy.
|
||||
let config = $state<FooterConfig>($state.snapshot(untrack(() => initial)));
|
||||
const languageTabs = Object.entries(languagesList).map(([id, label]) => ({ id, label }));
|
||||
let language = $state<Locale>(defaultLanguage);
|
||||
|
||||
let errorMessage = $state("");
|
||||
let showError = $state(false);
|
||||
let showSaved = $state(false);
|
||||
|
||||
// The partner list and position the upload modal fills; `index` past the end adds one.
|
||||
let uploadTarget = $state<{ list: FooterPartner[]; index: number } | null>(null);
|
||||
let isUploadOpen = $state(false);
|
||||
|
||||
function move<T>(list: T[], index: number, delta: number) {
|
||||
const target = index + delta;
|
||||
|
||||
if (target < 0 || target >= list.length) return;
|
||||
|
||||
[list[index], list[target]] = [list[target], list[index]];
|
||||
}
|
||||
|
||||
function openUpload(list: FooterPartner[], index: number) {
|
||||
uploadTarget = { list, index };
|
||||
isUploadOpen = true;
|
||||
}
|
||||
|
||||
function handleUpload([file]: UploadedObject[]) {
|
||||
if (!file || !uploadTarget) return;
|
||||
|
||||
const { list, index } = uploadTarget;
|
||||
|
||||
if (index < list.length) {
|
||||
list[index].src = file.url;
|
||||
} else {
|
||||
list.push({ src: file.url, alt: "", href: "" });
|
||||
}
|
||||
|
||||
uploadTarget = null;
|
||||
}
|
||||
|
||||
let form: HTMLFormElement;
|
||||
|
||||
// The `.wrapper` max width: the preview is drawn at that size and zoomed into its box.
|
||||
const PREVIEW_WIDTH = 1440;
|
||||
let previewWidth = $state(0);
|
||||
|
||||
// The navigation column or logo group being edited in the modal.
|
||||
type EditableList = "navColumns" | "partnerGroups";
|
||||
|
||||
let editing = $state<{ list: EditableList; index: number } | null>(null);
|
||||
let isEditOpen = $state(false);
|
||||
|
||||
function edit(list: EditableList, index: number) {
|
||||
editing = { list, index };
|
||||
isEditOpen = true;
|
||||
}
|
||||
|
||||
function addColumn() {
|
||||
config.navColumns.push({ title: {}, links: [{ label: {}, href: "" }] });
|
||||
edit("navColumns", config.navColumns.length - 1);
|
||||
}
|
||||
|
||||
function addGroup() {
|
||||
config.partnerGroups.push({ title: {}, partners: [] });
|
||||
edit("partnerGroups", config.partnerGroups.length - 1);
|
||||
}
|
||||
|
||||
// A row is highlighted while any of its fields has focus (`focus-within`).
|
||||
const rowClass =
|
||||
"focus-within:ring-primary flex items-center gap-3 rounded-lg focus-within:ring-2";
|
||||
|
||||
/**
|
||||
* Clicking an element of the preview focuses its row in the form, matched through the
|
||||
* `data-edit` path the preview puts on it. The preview's own links never navigate.
|
||||
*/
|
||||
async function focusField(event: MouseEvent) {
|
||||
event.preventDefault();
|
||||
|
||||
const path = (event.target as Element).closest<HTMLElement>("[data-edit]")?.dataset.edit;
|
||||
|
||||
if (!path) return;
|
||||
|
||||
// Columns and logo groups are edited in a modal: open it and wait until it has rendered.
|
||||
// ponytail: two frames, because the dialog grabs focus itself when its intro starts.
|
||||
const [list, index] = path.split(".");
|
||||
|
||||
if (list === "navColumns" || list === "partnerGroups") {
|
||||
edit(list, Number(index));
|
||||
await tick();
|
||||
await new Promise((resolve) =>
|
||||
requestAnimationFrame(() => requestAnimationFrame(resolve)),
|
||||
);
|
||||
}
|
||||
|
||||
const row = form.querySelector(`[data-field="${path}"]`);
|
||||
|
||||
row?.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
row?.querySelector<HTMLElement>("input, select, button")?.focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
async function save() {
|
||||
const { error } = await actions.saveFooter({ config: JSON.stringify(config) });
|
||||
|
||||
if (error) {
|
||||
errorMessage =
|
||||
error.code === "INTERNAL_SERVER_ERROR" ? $t("system.error.unknown") : error.message;
|
||||
showError = true;
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
showSaved = true;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#snippet rowControls(list: unknown[], index: number)}
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="text-secondary cursor-pointer p-1 disabled:opacity-30"
|
||||
aria-label={$t("pages.admin.customize.footer.actions.moveUp")}
|
||||
disabled={index === 0}
|
||||
onclick={() => move(list, index, -1)}
|
||||
>
|
||||
<Chevron direction="up" width="20" height="20" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="text-secondary cursor-pointer p-1 disabled:opacity-30"
|
||||
aria-label={$t("pages.admin.customize.footer.actions.moveDown")}
|
||||
disabled={index === list.length - 1}
|
||||
onclick={() => move(list, index, 1)}
|
||||
>
|
||||
<Chevron direction="down" width="20" height="20" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="text-tertiary cursor-pointer p-1"
|
||||
aria-label={$t("common.remove")}
|
||||
onclick={() => list.splice(index, 1)}
|
||||
>
|
||||
<Trash width="18" height="20" />
|
||||
</button>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
{#snippet localizedInput(text: LocalizedText, placeholder: string)}
|
||||
<div class="flex-1">
|
||||
<TextInput
|
||||
bind:value={() => text[language] ?? "", (value) => (text[language] = String(value))}
|
||||
placeholder={language === defaultLanguage
|
||||
? placeholder
|
||||
: text[defaultLanguage] || placeholder}
|
||||
/>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
{#snippet linkList(links: FooterLinkItem[], path: string)}
|
||||
<ul class="space-y-3">
|
||||
{#each links as link, index (link)}
|
||||
<li class={rowClass} data-field="{path}.{index}">
|
||||
{@render localizedInput(
|
||||
link.label,
|
||||
$t("pages.admin.customize.footer.fields.labelPlaceholder"),
|
||||
)}
|
||||
<div class="flex-1">
|
||||
<TextInput
|
||||
bind:value={link.href}
|
||||
placeholder={$t("pages.admin.customize.footer.fields.hrefPlaceholder")}
|
||||
/>
|
||||
</div>
|
||||
{@render rowControls(links, index)}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
<Button
|
||||
kind="ghost"
|
||||
size="sm"
|
||||
class="w-fit"
|
||||
onclick={() => links.push({ label: {}, href: "" })}
|
||||
>
|
||||
{$t("pages.admin.customize.footer.actions.addLink")}
|
||||
</Button>
|
||||
{/snippet}
|
||||
|
||||
{#snippet partnerList(partners: FooterPartner[], path: string)}
|
||||
<ul class="space-y-3">
|
||||
{#each partners as partner, index (partner)}
|
||||
<li class={rowClass} data-field="{path}.{index}">
|
||||
<button
|
||||
type="button"
|
||||
class="bg-grey flex h-14 w-24 shrink-0 cursor-pointer items-center justify-center rounded-lg p-1"
|
||||
aria-label={$t("pages.admin.customize.footer.actions.changeImage")}
|
||||
onclick={() => openUpload(partners, index)}
|
||||
>
|
||||
<img src={partner.src} alt="" class="max-h-full max-w-full object-contain" />
|
||||
</button>
|
||||
<div class="flex-1">
|
||||
<TextInput
|
||||
bind:value={partner.alt}
|
||||
placeholder={$t("pages.admin.customize.footer.fields.altPlaceholder")}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<TextInput
|
||||
bind:value={
|
||||
() => partner.href ?? "", (value) => (partner.href = String(value))
|
||||
}
|
||||
placeholder={$t(
|
||||
"pages.admin.customize.footer.fields.partnerHrefPlaceholder",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
{@render rowControls(partners, index)}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
<Button
|
||||
kind="ghost"
|
||||
size="sm"
|
||||
class="w-fit"
|
||||
onclick={() => openUpload(partners, partners.length)}
|
||||
>
|
||||
{$t("pages.admin.customize.footer.actions.addPartner")}
|
||||
</Button>
|
||||
{/snippet}
|
||||
|
||||
<!-- One language for the whole editor: the form and the modal switch it together. -->
|
||||
{#snippet languageTabsNav()}
|
||||
<TabNavigation
|
||||
tabs={languageTabs}
|
||||
currentTab={language}
|
||||
onTabClick={(id) => (language = id as Locale)}
|
||||
/>
|
||||
{/snippet}
|
||||
|
||||
{#snippet sectionHeader(section: FooterSection, titleKey: string)}
|
||||
<div class="flex flex-wrap items-center justify-between gap-4">
|
||||
<Title level={3} variant="subsection">{$t(titleKey)}</Title>
|
||||
<Checkbox
|
||||
bind:checked={config.hidden[section]}
|
||||
label={$t("pages.admin.customize.footer.hideSection")}
|
||||
/>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
{#snippet summaryCard(list: EditableList, title: LocalizedText, count: string, index: number)}
|
||||
<li class="border-grey flex items-center gap-3 rounded-2xl border p-4">
|
||||
<div class="flex-1">
|
||||
<p class="text-secondary font-bold">
|
||||
{localized(title, language) ||
|
||||
$t("pages.admin.customize.footer.fields.titlePlaceholder")}
|
||||
</p>
|
||||
<p class="text-content text-sm">{count}</p>
|
||||
</div>
|
||||
<Button kind="ghost" size="sm" onclick={() => edit(list, index)}>
|
||||
{$t("common.edit")}
|
||||
</Button>
|
||||
{@render rowControls(config[list], index)}
|
||||
</li>
|
||||
{/snippet}
|
||||
|
||||
<section class="mb-10 space-y-3">
|
||||
<Title level={3} variant="subsection">
|
||||
{$t("pages.admin.customize.footer.sections.preview")}
|
||||
</Title>
|
||||
<p class="text-content text-sm">{$t("pages.admin.customize.footer.previewHelp")}</p>
|
||||
<!-- Mouse shortcut only: every field is reachable from the form below. -->
|
||||
<div
|
||||
role="presentation"
|
||||
class="[&_[data-edit]:hover]:outline-primary overflow-hidden rounded-b-3xl **:data-edit:cursor-pointer **:data-edit:rounded-sm [&_[data-edit]:hover]:outline-2 [&_[data-edit]:hover]:outline-offset-2"
|
||||
onclick={focusField}
|
||||
bind:clientWidth={previewWidth}
|
||||
>
|
||||
<!-- Laid out as on a 1440px window (1360px of content), then zoomed to fit. -->
|
||||
<div
|
||||
class="w-360"
|
||||
style:zoom={previewWidth ? Math.min(1, previewWidth / PREVIEW_WIDTH) : undefined}
|
||||
>
|
||||
<FooterView {config} lang={language} t={$t} idPrefix="footer-preview" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<form
|
||||
bind:this={form}
|
||||
class="space-y-10"
|
||||
onsubmit={(event) => {
|
||||
event.preventDefault();
|
||||
}}
|
||||
>
|
||||
<div class="space-y-2">
|
||||
{@render languageTabsNav()}
|
||||
<p class="text-content text-sm">
|
||||
{$t("pages.admin.customize.footer.languageHelp", {
|
||||
language: languagesList[defaultLanguage],
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-10 xl:grid-cols-2">
|
||||
<section class="space-y-6">
|
||||
{@render sectionHeader("partners", "pages.admin.customize.footer.sections.partners")}
|
||||
|
||||
<ul class="space-y-3">
|
||||
{#each config.partnerGroups as group, index (group)}
|
||||
{@render summaryCard(
|
||||
"partnerGroups",
|
||||
group.title,
|
||||
$t("pages.admin.customize.footer.logoCount", {
|
||||
count: group.partners.length,
|
||||
}),
|
||||
index,
|
||||
)}
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
<Button kind="secondary" size="sm" class="w-fit" onclick={addGroup}>
|
||||
{$t("pages.admin.customize.footer.actions.addGroup")}
|
||||
</Button>
|
||||
</section>
|
||||
|
||||
<section class="space-y-6">
|
||||
{@render sectionHeader(
|
||||
"navigation",
|
||||
"pages.admin.customize.footer.sections.navigation",
|
||||
)}
|
||||
|
||||
<ul class="space-y-3">
|
||||
{#each config.navColumns as column, index (column)}
|
||||
{@render summaryCard(
|
||||
"navColumns",
|
||||
column.title,
|
||||
$t("pages.admin.customize.footer.linkCount", {
|
||||
count: column.links.length,
|
||||
}),
|
||||
index,
|
||||
)}
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
<Button kind="secondary" size="sm" class="w-fit" onclick={addColumn}>
|
||||
{$t("pages.admin.customize.footer.actions.addColumn")}
|
||||
</Button>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- Inside the form so `focusField` finds its rows; Enter is already prevented. -->
|
||||
<Modal
|
||||
bind:open={isEditOpen}
|
||||
closeBtnClass="top-7 end-7 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="backdrop:bg-overlay fixed top-1/2 left-1/2 mx-2 flex max-h-[90vh] w-full max-w-200 -translate-x-1/2 -translate-y-1/2 divide-y-0 overflow-y-auto rounded-3xl bg-white shadow-lg backdrop:backdrop-blur-[5px] sm:mx-4 lg:mx-0"
|
||||
bodyClass="p-8"
|
||||
>
|
||||
{#if editing && config[editing.list][editing.index]}
|
||||
{@const { list, index } = editing}
|
||||
<div class="space-y-6">
|
||||
<Title level={2} variant="subsection">
|
||||
{$t(
|
||||
list === "navColumns"
|
||||
? "pages.admin.customize.footer.editColumn"
|
||||
: "pages.admin.customize.footer.editGroup",
|
||||
)}
|
||||
</Title>
|
||||
{@render languageTabsNav()}
|
||||
<div class={rowClass} data-field="{list}.{index}">
|
||||
{@render localizedInput(
|
||||
config[list][index].title,
|
||||
$t("pages.admin.customize.footer.fields.titlePlaceholder"),
|
||||
)}
|
||||
</div>
|
||||
{#if list === "navColumns"}
|
||||
{@render linkList(config.navColumns[index].links, `navColumns.${index}.links`)}
|
||||
{:else}
|
||||
{@render partnerList(
|
||||
config.partnerGroups[index].partners,
|
||||
`partnerGroups.${index}.partners`,
|
||||
)}
|
||||
{/if}
|
||||
<div class="flex justify-end">
|
||||
<Button class="w-fit" onclick={() => (isEditOpen = false)}>
|
||||
{$t("common.close")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</Modal>
|
||||
|
||||
<div class="grid gap-10 xl:grid-cols-2">
|
||||
<section class="space-y-4">
|
||||
{@render sectionHeader("legal", "pages.admin.customize.footer.sections.legal")}
|
||||
{@render linkList(config.legalLinks, "legalLinks")}
|
||||
</section>
|
||||
|
||||
<section class="space-y-4">
|
||||
{@render sectionHeader("social", "pages.admin.customize.footer.sections.social")}
|
||||
<ul class="space-y-3">
|
||||
{#each config.social as link, index (link)}
|
||||
<li class={rowClass} data-field="social.{index}">
|
||||
<Select bind:value={link.network} class="w-48">
|
||||
{#each FOOTER_SOCIAL_NETWORKS as network (network)}
|
||||
<option value={network}>
|
||||
{$t(`common.footer.a11y.social.${network}`)}
|
||||
</option>
|
||||
{/each}
|
||||
</Select>
|
||||
<div class="flex-1">
|
||||
<TextInput
|
||||
bind:value={link.href}
|
||||
placeholder={$t(
|
||||
"pages.admin.customize.footer.fields.socialPlaceholder",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
{@render rowControls(config.social, index)}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
<Button
|
||||
kind="ghost"
|
||||
size="sm"
|
||||
class="w-fit"
|
||||
onclick={() => config.social.push({ network: "instagram", href: "" })}
|
||||
>
|
||||
{$t("pages.admin.customize.footer.actions.addSocial")}
|
||||
</Button>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<ActionableButton action={save} autoreset={2000} class="w-fit">
|
||||
{$t("common.save")}
|
||||
</ActionableButton>
|
||||
</form>
|
||||
|
||||
<ImageUploadModal
|
||||
bind:open={isUploadOpen}
|
||||
accept={["image/png", "image/jpeg", "image/webp"]}
|
||||
recommendedSize="300x120px"
|
||||
onConfirm={handleUpload}
|
||||
/>
|
||||
|
||||
<Toast floating variant="error" bind:showToast={showError}>{errorMessage}</Toast>
|
||||
<Toast floating variant="success" bind:showToast={showSaved}>
|
||||
{$t("pages.admin.customize.footer.saved")}
|
||||
</Toast>
|
||||
@@ -0,0 +1,85 @@
|
||||
<script lang="ts">
|
||||
import { actions } from "astro:actions";
|
||||
import { untrack } from "svelte";
|
||||
|
||||
import LogoForm from "./LogoForm.svelte";
|
||||
import LogoHistory from "./LogoHistory.svelte";
|
||||
import LogoTabs from "./LogoTabs.svelte";
|
||||
import { t } from "../../../../i18n/store";
|
||||
import Toast from "../../../library/feedback/Toast.svelte";
|
||||
import Title from "../../../library/typography/Title.svelte";
|
||||
|
||||
import type { HeaderLogoRecord } from "../../../../repositories/headerLogo";
|
||||
|
||||
interface Props {
|
||||
logos: HeaderLogoRecord[];
|
||||
}
|
||||
|
||||
let { logos }: Props = $props();
|
||||
|
||||
let currentSubtab = $state("new");
|
||||
let showError = $state(false);
|
||||
let errorMessage = $state("");
|
||||
let logosList = $state(untrack(() => logos));
|
||||
|
||||
function handleTabChange(tabId: string) {
|
||||
currentSubtab = tabId;
|
||||
|
||||
// Re-fetch every time the history is opened, so it always shows the
|
||||
// latest logos regardless of when they were saved.
|
||||
if (tabId === "history") {
|
||||
refreshLogos();
|
||||
}
|
||||
}
|
||||
|
||||
// The list is passed in once by the page; after a save it must be refreshed
|
||||
// so the history shows the new logo without a full page reload.
|
||||
async function refreshLogos() {
|
||||
try {
|
||||
const { data, error } = await actions.getHeaderLogoData();
|
||||
|
||||
if (error) {
|
||||
errorMessage = error.message;
|
||||
showError = true;
|
||||
return;
|
||||
}
|
||||
|
||||
logosList = data?.logos ?? logosList;
|
||||
} catch (e) {
|
||||
errorMessage = e instanceof Error ? e.message : String(e);
|
||||
showError = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSaved() {
|
||||
await refreshLogos();
|
||||
currentSubtab = "history";
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<Title level={2} variant="headline">
|
||||
{$t("pages.admin.customize.logo.title")}
|
||||
</Title>
|
||||
<p class="text-content text-base font-normal">
|
||||
{$t("pages.admin.customize.logo.description")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Toast floating variant="error" bind:showToast={showError}>{errorMessage}</Toast>
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<LogoTabs currentTab={currentSubtab} onTabChange={handleTabChange} />
|
||||
{#if currentSubtab === "new"}
|
||||
<LogoForm onSaved={handleSaved} />
|
||||
{:else if currentSubtab === "history"}
|
||||
<LogoHistory
|
||||
rows={logosList}
|
||||
onError={(message: string) => {
|
||||
errorMessage = message;
|
||||
showError = true;
|
||||
}}
|
||||
onSaved={refreshLogos}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,175 @@
|
||||
<script lang="ts">
|
||||
import { actions, isInputError } from "astro:actions";
|
||||
|
||||
import { t } from "../../../../i18n/store";
|
||||
import ActionableButton from "../../../library/buttons/ActionableButton.svelte";
|
||||
import Button from "../../../library/buttons/Button.svelte";
|
||||
import Toast from "../../../library/feedback/Toast.svelte";
|
||||
import ImageUploadModal from "../../../library/inputs/ImageUploadModal.svelte";
|
||||
import TextInput from "../../../library/inputs/TextInput.svelte";
|
||||
import Title from "../../../library/typography/Title.svelte";
|
||||
|
||||
import type { UploadedObject } from "../../../../utils/media/objectStorage.types";
|
||||
|
||||
interface Props {
|
||||
onSaved?: () => void;
|
||||
}
|
||||
|
||||
let { onSaved }: Props = $props();
|
||||
|
||||
type FieldErrors = Partial<Record<"altText", string>>;
|
||||
|
||||
let formElement: HTMLFormElement;
|
||||
|
||||
let media = $state<UploadedObject>();
|
||||
let altText = $state("Goteo");
|
||||
let isUploadOpen = $state(false);
|
||||
|
||||
let fieldErrors: FieldErrors = $state({});
|
||||
let mediaError = $state("");
|
||||
let errorMessage = $state("");
|
||||
let showError = $state(false);
|
||||
|
||||
function handleUpload(files: UploadedObject[]) {
|
||||
media = files[0];
|
||||
mediaError = "";
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
fieldErrors = {};
|
||||
mediaError = "";
|
||||
|
||||
if (!media) {
|
||||
mediaError = $t("pages.admin.customize.logo.errors.mediaRequired");
|
||||
return;
|
||||
}
|
||||
|
||||
const data = new FormData(formElement);
|
||||
|
||||
// The uploaded object is not a form field: hand the asset over explicitly.
|
||||
data.set("mediaUrl", media.url);
|
||||
data.set("mediaType", media.type);
|
||||
data.set("altText", altText.trim());
|
||||
|
||||
try {
|
||||
const { error } = await actions.createHeaderLogo(data);
|
||||
|
||||
if (error) {
|
||||
if (!isInputError(error)) {
|
||||
errorMessage = error.message;
|
||||
showError = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fieldErrors = Object.fromEntries(
|
||||
Object.entries(error.fields).map(([field, issues]) => [field, issues?.[0]]),
|
||||
) as FieldErrors;
|
||||
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
// The action call itself threw (e.g. a network failure); do not
|
||||
// let ActionableButton swallow it silently.
|
||||
errorMessage = e instanceof Error ? e.message : String(e);
|
||||
showError = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
media = undefined;
|
||||
altText = "Goteo";
|
||||
|
||||
onSaved?.();
|
||||
}
|
||||
|
||||
async function handleSubmit(event: SubmitEvent) {
|
||||
event.preventDefault();
|
||||
await submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
<form bind:this={formElement} onsubmit={handleSubmit} class="flex max-w-167 flex-col gap-10">
|
||||
<div class="flex flex-col gap-6">
|
||||
<Title level={3} variant="subsection">
|
||||
{$t("pages.admin.customize.logo.fields.mediaTitle")}
|
||||
</Title>
|
||||
|
||||
<div
|
||||
class="border-grey flex w-full flex-col gap-6 rounded-2xl border bg-white p-6 shadow-sm sm:max-w-138"
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
<p class="text-secondary text-base font-bold">
|
||||
{$t("pages.admin.customize.logo.fields.mediaLabel")}
|
||||
</p>
|
||||
|
||||
{#if media}
|
||||
<p class="text-content truncate text-base font-normal">{media.name}</p>
|
||||
{:else}
|
||||
<p class="text-content text-base font-normal">
|
||||
{$t("pages.admin.customize.logo.fields.mediaHint")}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if media}
|
||||
<div class="flex items-center justify-center rounded-lg bg-gray-50 p-6">
|
||||
<img
|
||||
src={media.url}
|
||||
alt={altText || media.name}
|
||||
class="max-h-24 w-auto max-w-full object-contain"
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if mediaError}
|
||||
<p class="text-tertiary text-sm">{mediaError}</p>
|
||||
{/if}
|
||||
|
||||
<div class="flex flex-wrap gap-4">
|
||||
<Button
|
||||
kind="secondary"
|
||||
size="sm"
|
||||
class="w-fit"
|
||||
onclick={() => (isUploadOpen = true)}
|
||||
>
|
||||
{$t("pages.admin.customize.logo.fields.mediaAdd")}
|
||||
</Button>
|
||||
|
||||
{#if media}
|
||||
<Button
|
||||
kind="ghost"
|
||||
size="sm"
|
||||
class="w-fit"
|
||||
onclick={() => (media = undefined)}
|
||||
>
|
||||
{$t("common.remove")}
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TextInput
|
||||
bind:value={altText}
|
||||
required
|
||||
labelText={$t("pages.admin.customize.logo.fields.altTextLabel")}
|
||||
placeholder={$t("pages.admin.customize.logo.fields.altTextPlaceholder")}
|
||||
error={fieldErrors.altText && $t(fieldErrors.altText)}
|
||||
class="sm:max-w-138"
|
||||
/>
|
||||
|
||||
<ActionableButton action={submit} autoreset={2000} class="w-fit px-6">
|
||||
{$t("common.save")}
|
||||
</ActionableButton>
|
||||
</form>
|
||||
|
||||
<Toast floating variant="error" bind:showToast={showError}>{errorMessage}</Toast>
|
||||
|
||||
<ImageUploadModal
|
||||
bind:open={isUploadOpen}
|
||||
accept={["image/png", "image/jpeg", "image/webp"]}
|
||||
multiple={false}
|
||||
recommendedSize="480x120px"
|
||||
onConfirm={handleUpload}
|
||||
/>
|
||||
@@ -0,0 +1,197 @@
|
||||
<script lang="ts">
|
||||
import { actions } from "astro:actions";
|
||||
import { Modal, TableBodyCell } from "flowbite-svelte";
|
||||
import { tick, untrack } from "svelte";
|
||||
|
||||
import { t } from "../../../../i18n/store";
|
||||
import Eye from "../../../icons/media/Eye.svelte";
|
||||
import Close from "../../../icons/navigation/Close.svelte";
|
||||
import DeleteModal from "../../../library/feedback/DeleteModal.svelte";
|
||||
import DataTable from "../../../library/tables/DataTable.svelte";
|
||||
import Title from "../../../library/typography/Title.svelte";
|
||||
|
||||
import type { HeaderLogoRecord } from "../../../../repositories/headerLogo";
|
||||
import type { DataTableHeader } from "../../../library/tables/DataTable.svelte";
|
||||
|
||||
interface Props {
|
||||
rows: HeaderLogoRecord[];
|
||||
onError?: (message: string) => void;
|
||||
onSaved?: () => void;
|
||||
}
|
||||
|
||||
let { rows, onError, onSaved }: Props = $props();
|
||||
|
||||
let list = $state(untrack(() => rows));
|
||||
|
||||
// rows is refreshed after a save; keep the local list in sync, while the
|
||||
// local deletions below continue to apply on top of the incoming list.
|
||||
$effect(() => {
|
||||
list = rows;
|
||||
});
|
||||
|
||||
// Same rule as the repository's getActive(): rows come newest first, so
|
||||
// the first one is the one the header shows.
|
||||
const activeId = $derived(list[0]?.id);
|
||||
|
||||
type Status = "active" | "past";
|
||||
|
||||
function statusOf(row: HeaderLogoRecord): Status {
|
||||
return row.id === activeId ? "active" : "past";
|
||||
}
|
||||
|
||||
const STATUS_BADGES: Record<Status, string> = {
|
||||
active: "bg-green-100 text-green-800",
|
||||
past: "bg-gray-100 text-gray-500",
|
||||
};
|
||||
|
||||
const headers: DataTableHeader[] = [
|
||||
{ key: "pages.admin.customize.logo.history.headers.id", sortable: false, class: "w-16" },
|
||||
{ key: "pages.admin.customize.logo.history.headers.image", sortable: false },
|
||||
{ key: "pages.admin.customize.logo.history.headers.altText", sortable: false },
|
||||
{ key: "pages.admin.customize.logo.history.headers.status", sortable: false },
|
||||
{ key: "", sortable: false, class: "w-24" },
|
||||
];
|
||||
|
||||
const itemsPerPage = 10;
|
||||
let currentPage = $state(1);
|
||||
|
||||
const paginatedRows = $derived(
|
||||
list.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage),
|
||||
);
|
||||
|
||||
let isDeleteModalOpen = $state(false);
|
||||
let rowToDelete = $state<HeaderLogoRecord | null>(null);
|
||||
|
||||
function openDeleteModal(row: HeaderLogoRecord) {
|
||||
rowToDelete = row;
|
||||
isDeleteModalOpen = true;
|
||||
}
|
||||
|
||||
async function confirmDelete() {
|
||||
const logo = rowToDelete;
|
||||
|
||||
if (!logo) return;
|
||||
|
||||
const formData = new FormData();
|
||||
formData.set("id", String(logo.id));
|
||||
|
||||
const { error } = await actions.deleteHeaderLogo(formData);
|
||||
|
||||
isDeleteModalOpen = false;
|
||||
rowToDelete = null;
|
||||
|
||||
if (error) {
|
||||
onError?.(error.message);
|
||||
return;
|
||||
}
|
||||
|
||||
list = list.filter((item) => item.id !== logo.id);
|
||||
|
||||
// The parent list is also refreshed so the header statuses follow.
|
||||
onSaved?.();
|
||||
|
||||
// Let the updated rows reach the table before clamping.
|
||||
await tick();
|
||||
|
||||
// Deleting the last row of the last page would leave an empty table.
|
||||
if (currentPage > 1 && (currentPage - 1) * itemsPerPage >= list.length) {
|
||||
currentPage -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
let isPreviewOpen = $state(false);
|
||||
let previewRow = $state<HeaderLogoRecord | null>(null);
|
||||
|
||||
function openPreview(row: HeaderLogoRecord) {
|
||||
previewRow = row;
|
||||
isPreviewOpen = true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<Title level={3} variant="subsection">
|
||||
{$t("pages.admin.customize.logo.history.title")}
|
||||
</Title>
|
||||
<p class="text-content">{$t("pages.admin.customize.logo.history.description")}</p>
|
||||
</div>
|
||||
|
||||
<DataTable
|
||||
{headers}
|
||||
rows={paginatedRows}
|
||||
isLoading={false}
|
||||
emptyMessage="pages.admin.customize.logo.history.noData"
|
||||
{currentPage}
|
||||
totalItems={list.length}
|
||||
{itemsPerPage}
|
||||
onPageChange={(page) => (currentPage = page)}
|
||||
>
|
||||
{#snippet children(row)}
|
||||
<TableBodyCell class="border-variant1 w-16 rounded-l-md border-t border-b border-l p-4">
|
||||
{row.id}
|
||||
</TableBodyCell>
|
||||
<TableBodyCell class="border-variant1 border-t border-b p-4">
|
||||
<img
|
||||
src={row.mediaUrl}
|
||||
alt={row.altText}
|
||||
class="max-h-10 w-auto max-w-40 object-contain"
|
||||
/>
|
||||
</TableBodyCell>
|
||||
<TableBodyCell class="border-variant1 max-w-80 truncate border-t border-b p-4">
|
||||
{row.altText}
|
||||
</TableBodyCell>
|
||||
<TableBodyCell class="border-variant1 border-t border-b p-4">
|
||||
{@const status = statusOf(row)}
|
||||
<span
|
||||
class="flex w-fit items-center gap-1.5 rounded-full px-3 py-1 text-xs font-semibold whitespace-nowrap {STATUS_BADGES[
|
||||
status
|
||||
]}"
|
||||
>
|
||||
<span class="size-1.5 rounded-full bg-current"></span>
|
||||
{$t(`pages.admin.customize.logo.history.status.${status}`)}
|
||||
</span>
|
||||
</TableBodyCell>
|
||||
<TableBodyCell class="border-variant1 w-24 rounded-r-md border-t border-r border-b p-4">
|
||||
<div class="flex items-center justify-end gap-3">
|
||||
<button
|
||||
class="text-secondary cursor-pointer transition-transform duration-200 hover:scale-110"
|
||||
aria-label={$t("common.preview")}
|
||||
onclick={() => openPreview(row)}
|
||||
>
|
||||
<Eye class="size-5" />
|
||||
</button>
|
||||
<button
|
||||
class="text-secondary cursor-pointer transition-transform duration-200 hover:scale-110"
|
||||
aria-label={$t("common.delete")}
|
||||
onclick={() => openDeleteModal(row)}
|
||||
>
|
||||
<Close class="size-5" />
|
||||
</button>
|
||||
</div>
|
||||
</TableBodyCell>
|
||||
{/snippet}
|
||||
</DataTable>
|
||||
|
||||
<Modal
|
||||
bind:open={isPreviewOpen}
|
||||
closeBtnClass="top-7 end-7 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="backdrop:bg-overlay fixed top-1/2 left-1/2 mx-2 flex w-fit max-w-[min(46rem,calc(100vw-1rem))] -translate-x-1/2 -translate-y-1/2 divide-y-0 rounded-3xl bg-white shadow-lg backdrop:backdrop-blur-[5px] sm:mx-4 lg:mx-0"
|
||||
bodyClass="border-grey max-h-[90vh] overflow-y-auto rounded-3xl bg-white p-6"
|
||||
>
|
||||
{#if previewRow}
|
||||
<div class="flex flex-col gap-4">
|
||||
<img
|
||||
src={previewRow.mediaUrl}
|
||||
alt={previewRow.altText}
|
||||
class="max-h-60 w-auto max-w-full object-contain"
|
||||
/>
|
||||
<p class="text-content text-base">{previewRow.altText}</p>
|
||||
</div>
|
||||
{/if}
|
||||
</Modal>
|
||||
|
||||
<DeleteModal
|
||||
bind:open={isDeleteModalOpen}
|
||||
title={$t("pages.admin.customize.logo.history.deleteModal.title")}
|
||||
description={$t("pages.admin.customize.logo.history.deleteModal.description")}
|
||||
onclick={confirmDelete}
|
||||
/>
|
||||
@@ -0,0 +1,39 @@
|
||||
<script lang="ts">
|
||||
import { t } from "../../../../i18n/store";
|
||||
import PlusIcon from "../../../icons/actions/PlusIcon.svelte";
|
||||
import Clock from "../../../icons/Clock.svelte";
|
||||
|
||||
interface Props {
|
||||
currentTab: string;
|
||||
onTabChange: (tabId: string) => void;
|
||||
}
|
||||
|
||||
let { currentTab, onTabChange }: Props = $props();
|
||||
|
||||
function tabClass(tabId: string): string {
|
||||
return currentTab === tabId
|
||||
? "border-primary text-secondary"
|
||||
: "border-variant1 text-content";
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex gap-0">
|
||||
<button
|
||||
class="hover:bg-primary-dark flex w-fit cursor-pointer items-center gap-2 rounded-t-lg border-b-2 px-6 py-2 text-base font-bold {tabClass(
|
||||
'new',
|
||||
)}"
|
||||
onclick={() => onTabChange("new")}
|
||||
>
|
||||
<PlusIcon class="text-secondary size-4" />
|
||||
{$t("pages.admin.customize.logo.tabs.new")}
|
||||
</button>
|
||||
<button
|
||||
class="hover:bg-primary-dark flex w-fit cursor-pointer items-center gap-2 rounded-t-lg border-b-2 px-6 py-2 text-base font-bold {tabClass(
|
||||
'history',
|
||||
)}"
|
||||
onclick={() => onTabChange("history")}
|
||||
>
|
||||
<Clock class="text-secondary size-4" />
|
||||
{$t("pages.admin.customize.logo.tabs.history")}
|
||||
</button>
|
||||
</div>
|
||||
@@ -89,4 +89,5 @@
|
||||
{labels}
|
||||
search={searchUsers}
|
||||
onSave={saveUsers}
|
||||
draftId="admin-featured-users"
|
||||
/>
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { actions } from "astro:actions";
|
||||
import { Modal } from "flowbite-svelte";
|
||||
import { untrack } from "svelte";
|
||||
|
||||
import ProjectPickerModal, { type PickedProject } from "./ProjectPickerModal.svelte";
|
||||
import ProjectSlotCard from "./ProjectSlotCard.svelte";
|
||||
import { t } from "../../../i18n/store";
|
||||
import { apiProjectsGetCollection } from "../../../openapi/client/sdk.gen";
|
||||
import { debounce } from "../../../utils/debounce";
|
||||
import { toCollectionItems } from "../../../utils/hydra";
|
||||
import ActionableButton from "../../library/buttons/ActionableButton.svelte";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import DropdownMenu from "../../library/dropdown/DropdownMenu.svelte";
|
||||
import Toast from "../../library/feedback/Toast.svelte";
|
||||
import RadioButton from "../../library/inputs/RadioButton.svelte";
|
||||
import Select from "../../library/inputs/Select.svelte";
|
||||
import Title from "../../library/typography/Title.svelte";
|
||||
|
||||
import type { Project } from "../../../openapi/client/types.gen";
|
||||
import type { DropdownOption } from "../../library/dropdown/dropdown.types";
|
||||
|
||||
interface SlotAssignment {
|
||||
position: number;
|
||||
projectId: number;
|
||||
@@ -67,18 +61,14 @@
|
||||
},
|
||||
];
|
||||
|
||||
let type = $state(config.highlight?.type ?? "recent");
|
||||
let layout = $state(config.highlight?.layout ?? "2x3");
|
||||
let type = $state(untrack(() => config.highlight?.type ?? "recent"));
|
||||
let layout = $state(untrack(() => config.highlight?.layout ?? "2x3"));
|
||||
let addOpen = $state(false);
|
||||
let projectQuery = $state("");
|
||||
let searchOptions = $state<DropdownOption[]>([]);
|
||||
let selectedOption = $state<DropdownOption[]>([]);
|
||||
let editingSlotIndex = $state<number | null>(null);
|
||||
let searchResults: Project[] = [];
|
||||
let showError = $state(false);
|
||||
let errorMessage = $state("");
|
||||
|
||||
let slotAssignments = $state<SlotAssignment[]>(config.slots);
|
||||
let slotAssignments = $state<SlotAssignment[]>(untrack(() => config.slots));
|
||||
|
||||
let slotCount = $derived(LAYOUTS.find((l) => l.id === layout)?.rows.flat().length ?? 0);
|
||||
|
||||
@@ -86,57 +76,22 @@
|
||||
Array.from({ length: slotCount }, (_, i) => slotAssignments.find((a) => a.position === i)),
|
||||
);
|
||||
|
||||
const searchProjects = debounce(async (title: string) => {
|
||||
const { data, error } = await apiProjectsGetCollection({
|
||||
baseUrl: "/api/relay",
|
||||
headers: { Accept: "application/ld+json" },
|
||||
query: { title, itemsPerPage: 10 },
|
||||
});
|
||||
|
||||
if (error) console.error("Project search failed:", error);
|
||||
|
||||
searchResults = toCollectionItems<Project>(data);
|
||||
searchOptions = searchResults.map((p) => ({
|
||||
id: String(p.id),
|
||||
label: p.title ?? p.slug ?? "",
|
||||
selected: false,
|
||||
}));
|
||||
});
|
||||
|
||||
function handleSearch(query: string) {
|
||||
const trimmed = query.trim();
|
||||
|
||||
if (trimmed.length < 2) {
|
||||
searchProjects.cancel();
|
||||
searchOptions = [];
|
||||
return;
|
||||
}
|
||||
|
||||
searchProjects(trimmed);
|
||||
}
|
||||
|
||||
function handleAddProject(slotIndex: number) {
|
||||
editingSlotIndex = slotIndex;
|
||||
projectQuery = "";
|
||||
searchOptions = [];
|
||||
selectedOption = [];
|
||||
addOpen = true;
|
||||
}
|
||||
|
||||
function handleConfirmAdd() {
|
||||
if (editingSlotIndex === null || selectedOption.length === 0) return;
|
||||
const chosen = selectedOption[0];
|
||||
const project = searchResults.find((p) => String(p.id) === chosen.id);
|
||||
function handleConfirmAdd(project: PickedProject) {
|
||||
if (editingSlotIndex === null) return;
|
||||
slotAssignments = [
|
||||
...slotAssignments.filter((a) => a.position !== editingSlotIndex),
|
||||
{
|
||||
position: editingSlotIndex,
|
||||
projectId: Number(chosen.id),
|
||||
projectTitle: chosen.label,
|
||||
projectImage: project?.video?.thumbnail ?? project?.cover ?? null,
|
||||
projectId: project.id,
|
||||
projectTitle: project.title,
|
||||
projectImage: project.image,
|
||||
},
|
||||
];
|
||||
addOpen = false;
|
||||
editingSlotIndex = null;
|
||||
}
|
||||
|
||||
@@ -232,48 +187,13 @@
|
||||
</div>
|
||||
<div class="grid gap-4 md:grid-cols-2">
|
||||
{#each slots as slot, index (index)}
|
||||
<div class="border-grey flex flex-col items-start gap-2 rounded-2xl border p-4">
|
||||
<p class="text-secondary font-bold">
|
||||
{$t("pages.admin.home.highlights.projects.slot", {
|
||||
number: String(index + 1).padStart(2, "0"),
|
||||
})}
|
||||
</p>
|
||||
{#if slot}
|
||||
{#if slot.projectImage}
|
||||
<img
|
||||
src={slot.projectImage}
|
||||
alt={slot.projectTitle}
|
||||
class="aspect-video w-full rounded-lg object-cover"
|
||||
/>
|
||||
{/if}
|
||||
<p class="text-content text-body-small font-medium">
|
||||
{slot.projectTitle}
|
||||
</p>
|
||||
<div class="flex gap-2">
|
||||
<Button
|
||||
kind="secondary"
|
||||
size="sm"
|
||||
onclick={() => handleAddProject(index)}
|
||||
>
|
||||
{$t("pages.admin.home.highlights.projects.replace")}
|
||||
</Button>
|
||||
<Button
|
||||
kind="ghost"
|
||||
size="sm"
|
||||
onclick={() => handleRemoveProject(index)}
|
||||
>
|
||||
{$t("pages.admin.home.highlights.projects.remove")}
|
||||
</Button>
|
||||
</div>
|
||||
{:else}
|
||||
<p class="text-content text-body-small">
|
||||
{$t("pages.admin.home.highlights.projects.empty")}
|
||||
</p>
|
||||
<Button kind="secondary" size="sm" onclick={() => handleAddProject(index)}>
|
||||
{$t("pages.admin.home.highlights.projects.add")}
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
<ProjectSlotCard
|
||||
slotNumber={index + 1}
|
||||
project={slot ? { title: slot.projectTitle, image: slot.projectImage } : null}
|
||||
onAdd={() => handleAddProject(index)}
|
||||
onReplace={() => handleAddProject(index)}
|
||||
onRemove={() => handleRemoveProject(index)}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
</section>
|
||||
@@ -281,51 +201,11 @@
|
||||
|
||||
<Toast floating variant="error" bind:showToast={showError}>{errorMessage}</Toast>
|
||||
|
||||
<Modal
|
||||
<ProjectPickerModal
|
||||
bind:open={addOpen}
|
||||
closeBtnClass="top-3 end-3 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="fixed top-1/2 left-1/2 mx-2 flex w-full max-w-172 -translate-x-1/2 -translate-y-1/2 flex-col gap-6 divide-y-0 overflow-visible rounded-3xl bg-white p-6 shadow-lg backdrop:bg-[#878282B2] backdrop:backdrop-blur-[5px] sm:mx-4 lg:mx-0"
|
||||
headerClass="md:p-0 p-0 border-none"
|
||||
bodyClass="md:p-0 p-0 border-none overflow-y-visible"
|
||||
footerClass="md:p-0 p-0 border-none flex items-center justify-end gap-4"
|
||||
>
|
||||
{#snippet header()}
|
||||
<Title level={2} variant="subsection">
|
||||
{$t("pages.admin.home.highlights.projects.modal.title")}
|
||||
</Title>
|
||||
{/snippet}
|
||||
<div class="flex flex-col gap-6">
|
||||
<p class="text-content text-base font-normal">
|
||||
{$t("pages.admin.home.highlights.projects.modal.description")}
|
||||
</p>
|
||||
<div class="relative">
|
||||
{#if projectQuery}
|
||||
<span
|
||||
class="text-secondary absolute top-0 left-4 z-10 -translate-y-1/2 transform bg-white px-1 text-sm font-medium"
|
||||
>
|
||||
{$t("pages.admin.home.highlights.projects.modal.search")}
|
||||
</span>
|
||||
{/if}
|
||||
<DropdownMenu
|
||||
variant="basic"
|
||||
hasSearch
|
||||
singleSelect
|
||||
clearable
|
||||
options={searchOptions}
|
||||
bind:selected={selectedOption}
|
||||
bind:searchValue={projectQuery}
|
||||
onSearch={handleSearch}
|
||||
searchClasses="rounded-3xl border-secondary shadow-none"
|
||||
searchPlaceholder={$t("pages.admin.home.highlights.projects.modal.search")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{#snippet footer()}
|
||||
<Button kind="ghost" onclick={() => (addOpen = false)} class="w-fit">
|
||||
{$t("common.cancel")}
|
||||
</Button>
|
||||
<Button onclick={handleConfirmAdd} class="w-fit">
|
||||
{$t("pages.admin.home.highlights.projects.modal.submit")}
|
||||
</Button>
|
||||
{/snippet}
|
||||
</Modal>
|
||||
title={$t("pages.admin.home.highlights.projects.modal.title")}
|
||||
description={$t("pages.admin.home.highlights.projects.modal.description")}
|
||||
searchLabel={$t("pages.admin.home.highlights.projects.modal.search")}
|
||||
submitLabel={$t("pages.admin.home.highlights.projects.modal.submit")}
|
||||
onConfirm={handleConfirmAdd}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
<!--
|
||||
Project Picker Modal - reusable admin modal to search and pick a project.
|
||||
|
||||
Searches the platform projects (debounced, min 2 chars) via the API relay
|
||||
and reports the chosen project through `onConfirm`. Closing the modal (or
|
||||
confirming) resets the search state.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Modal } from "flowbite-svelte";
|
||||
|
||||
import { t } from "../../../i18n/store";
|
||||
import { apiProjectsGetCollection } from "../../../openapi/client/sdk.gen";
|
||||
import { toCollectionItems } from "../../../utils/hydra";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import DropdownSearch from "../../library/dropdown/DropdownSearch.svelte";
|
||||
import Title from "../../library/typography/Title.svelte";
|
||||
|
||||
import type { Project } from "../../../openapi/client/types.gen";
|
||||
import type { DropdownOption } from "../../library/dropdown/dropdown.types";
|
||||
|
||||
export interface PickedProject {
|
||||
id: number;
|
||||
title: string;
|
||||
image: string | null;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
title: string;
|
||||
description?: string;
|
||||
searchLabel?: string;
|
||||
submitLabel?: string;
|
||||
onConfirm: (project: PickedProject) => void;
|
||||
}
|
||||
|
||||
let {
|
||||
open = $bindable(false),
|
||||
title,
|
||||
description,
|
||||
searchLabel,
|
||||
submitLabel,
|
||||
onConfirm,
|
||||
}: Props = $props();
|
||||
|
||||
let projectQuery = $state("");
|
||||
let selectedOption = $state<DropdownOption[]>([]);
|
||||
let searchResults: Project[] = [];
|
||||
|
||||
// Reset the search state every time the modal opens, so a previous pick
|
||||
// never lingers when it is reused for another slot.
|
||||
$effect(() => {
|
||||
if (open) {
|
||||
projectQuery = "";
|
||||
selectedOption = [];
|
||||
searchResults = [];
|
||||
}
|
||||
});
|
||||
|
||||
async function searchProjects(title: string, signal: AbortSignal): Promise<DropdownOption[]> {
|
||||
const { data, error } = await apiProjectsGetCollection({
|
||||
baseUrl: "/api/relay",
|
||||
headers: { Accept: "application/ld+json" },
|
||||
query: { title, itemsPerPage: 10 },
|
||||
signal,
|
||||
});
|
||||
|
||||
if (error) console.error("Project search failed:", error);
|
||||
|
||||
const results = toCollectionItems<Project>(data);
|
||||
// A superseded search must not replace the results `handleConfirm` looks into.
|
||||
if (!signal.aborted) searchResults = results;
|
||||
|
||||
return results.map((p) => ({
|
||||
id: String(p.id),
|
||||
label: p.title ?? p.slug ?? "",
|
||||
selected: false,
|
||||
}));
|
||||
}
|
||||
|
||||
function handleConfirm() {
|
||||
if (selectedOption.length === 0) return;
|
||||
const chosen = selectedOption[0];
|
||||
const project = searchResults.find((p) => String(p.id) === chosen.id);
|
||||
onConfirm({
|
||||
id: Number(chosen.id),
|
||||
title: chosen.label,
|
||||
image: project?.video?.thumbnail ?? project?.cover ?? null,
|
||||
});
|
||||
open = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
bind:open
|
||||
closeBtnClass="top-3 end-3 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="fixed top-1/2 left-1/2 mx-2 flex w-full max-w-172 -translate-x-1/2 -translate-y-1/2 flex-col gap-6 divide-y-0 overflow-visible rounded-3xl bg-white p-6 shadow-lg backdrop:bg-[#878282B2] backdrop:backdrop-blur-[5px] sm:mx-4 lg:mx-0"
|
||||
headerClass="md:p-0 p-0 border-none"
|
||||
bodyClass="md:p-0 p-0 border-none overflow-y-visible"
|
||||
footerClass="md:p-0 p-0 border-none flex items-center justify-end gap-4"
|
||||
>
|
||||
{#snippet header()}
|
||||
<Title level={2} variant="subsection">{title}</Title>
|
||||
{/snippet}
|
||||
<div class="flex flex-col gap-6">
|
||||
{#if description}
|
||||
<p class="text-content text-base font-normal">{description}</p>
|
||||
{/if}
|
||||
<div class="relative">
|
||||
{#if projectQuery && searchLabel}
|
||||
<span
|
||||
class="text-secondary absolute top-0 left-4 z-10 -translate-y-1/2 transform bg-white px-1 text-sm font-medium"
|
||||
>
|
||||
{searchLabel}
|
||||
</span>
|
||||
{/if}
|
||||
<DropdownSearch
|
||||
variant="basic"
|
||||
singleSelect
|
||||
clearable
|
||||
search={searchProjects}
|
||||
minChars={2}
|
||||
bind:selected={selectedOption}
|
||||
bind:value={projectQuery}
|
||||
searchClasses="rounded-3xl border-secondary shadow-none"
|
||||
placeholder={searchLabel ?? $t("common.search")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{#snippet footer()}
|
||||
<Button kind="ghost" onclick={() => (open = false)} class="w-fit">
|
||||
{$t("common.cancel")}
|
||||
</Button>
|
||||
<Button onclick={handleConfirm} class="w-fit">{submitLabel ?? $t("common.add")}</Button>
|
||||
{/snippet}
|
||||
</Modal>
|
||||
@@ -0,0 +1,137 @@
|
||||
<!--
|
||||
Project Slot Card - reusable admin card for a project slot in a grid.
|
||||
|
||||
Variants:
|
||||
- "fixed": image on the left + slot content on the right (24px gap). The
|
||||
content is a title/subtitle group at the top and the action buttons at
|
||||
the bottom, separated by auto space (justify-between). When a project is
|
||||
selected the title is the project title and the subtitle is its carousel
|
||||
position; the empty state shows the slot label ("Proyecto NN") plus the
|
||||
helper text instead.
|
||||
- onRemove: clears the project from the slot, rendered as an "X" icon
|
||||
button on filled cards (optional).
|
||||
- onRemoveSlot: deletes the whole slot card, rendered as a trash icon
|
||||
button on empty cards (opt-in; only used by proposed campaigns, other
|
||||
consumers keep non-deletable slots).
|
||||
- "add": standalone trailing card (title + subtitle + ghost button) used to
|
||||
append a new slot to the grid.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { t } from "../../../i18n/store";
|
||||
import PlusIcon from "../../icons/actions/PlusIcon.svelte";
|
||||
import Trash from "../../icons/actions/Trash.svelte";
|
||||
import Close from "../../icons/navigation/Close.svelte";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import Title from "../../library/typography/Title.svelte";
|
||||
|
||||
interface Props {
|
||||
slotNumber?: number;
|
||||
project?: { title: string; image: string | null } | null;
|
||||
variant?: "fixed" | "add";
|
||||
onAdd?: () => void;
|
||||
onReplace?: () => void;
|
||||
onRemove?: () => void;
|
||||
onRemoveSlot?: () => void;
|
||||
class?: string;
|
||||
}
|
||||
|
||||
let {
|
||||
slotNumber,
|
||||
project = null,
|
||||
variant = "fixed",
|
||||
onAdd,
|
||||
onReplace,
|
||||
onRemove,
|
||||
onRemoveSlot,
|
||||
class: className = "",
|
||||
}: Props = $props();
|
||||
</script>
|
||||
|
||||
{#if variant === "add"}
|
||||
<div
|
||||
class={twMerge(
|
||||
"border-grey bg-grey flex flex-col gap-6 rounded-3xl border-1 p-6",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Title level={2} variant="field" color="secondary" class="text-base">
|
||||
{$t("pages.admin.slotCard.addTitle")}
|
||||
</Title>
|
||||
<p class="text-content text-base font-normal">
|
||||
{$t("pages.admin.slotCard.addSubtitle")}
|
||||
</p>
|
||||
</div>
|
||||
<Button class="w-fit" kind="ghost" size="sm" onclick={() => onAdd?.()}>
|
||||
<PlusIcon class="size-4" />
|
||||
{$t("pages.admin.slotCard.addMore")}
|
||||
</Button>
|
||||
</div>
|
||||
{:else}
|
||||
<div class={twMerge("border-grey flex gap-6 rounded-2xl border p-4", className)}>
|
||||
{#if project?.image}
|
||||
<img
|
||||
src={project.image}
|
||||
alt={project.title}
|
||||
class="aspect-square size-30 shrink-0 self-start rounded-2xl object-cover"
|
||||
/>
|
||||
{/if}
|
||||
<div class="flex min-w-0 flex-1 flex-col items-start justify-between gap-4">
|
||||
{#if project}
|
||||
<div class="flex flex-col gap-1">
|
||||
<p class="text-secondary font-bold">{project.title}</p>
|
||||
{#if slotNumber !== undefined}
|
||||
<p class="text-content text-body-small font-normal">
|
||||
{$t("pages.admin.slotCard.position", {
|
||||
number: String(slotNumber).padStart(2, "0"),
|
||||
})}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<Button kind="secondary" size="sm" onclick={() => onReplace?.()}>
|
||||
{$t("pages.admin.slotCard.replace")}
|
||||
</Button>
|
||||
{#if onRemove}
|
||||
<button
|
||||
type="button"
|
||||
class="text-secondary cursor-pointer transition-transform duration-200 hover:scale-110"
|
||||
aria-label={$t("pages.admin.slotCard.remove")}
|
||||
onclick={() => onRemove?.()}
|
||||
>
|
||||
<Close class="size-5" />
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex flex-col gap-1">
|
||||
{#if slotNumber !== undefined}
|
||||
<p class="text-secondary font-bold">
|
||||
{$t("pages.admin.slotCard.slot", {
|
||||
number: String(slotNumber).padStart(2, "0"),
|
||||
})}
|
||||
</p>
|
||||
{/if}
|
||||
<p class="text-content text-body-small">{$t("pages.admin.slotCard.empty")}</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<Button kind="secondary" size="sm" onclick={() => onAdd?.()}>
|
||||
{$t("pages.admin.slotCard.add")}
|
||||
</Button>
|
||||
{#if onRemoveSlot}
|
||||
<button
|
||||
type="button"
|
||||
class="text-secondary cursor-pointer transition-transform duration-200 hover:scale-110"
|
||||
aria-label={$t("common.delete")}
|
||||
onclick={() => onRemoveSlot?.()}
|
||||
>
|
||||
<Trash class="size-5" />
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,179 @@
|
||||
<script lang="ts">
|
||||
import { actions } from "astro:actions";
|
||||
import { untrack } from "svelte";
|
||||
|
||||
import ProjectPickerModal, { type PickedProject } from "./ProjectPickerModal.svelte";
|
||||
import ProjectSlotCard from "./ProjectSlotCard.svelte";
|
||||
import { t } from "../../../i18n/store";
|
||||
import CampaignsTabsNav from "../../home/CampaignsTabsNav.svelte";
|
||||
import ActionableButton from "../../library/buttons/ActionableButton.svelte";
|
||||
import Toast from "../../library/feedback/Toast.svelte";
|
||||
import Grid from "../../library/layout/Grid.svelte";
|
||||
import Title from "../../library/typography/Title.svelte";
|
||||
|
||||
import type { ProposedCampaignTab } from "../../../repositories/proposedCampaigns";
|
||||
|
||||
interface SlotAssignment {
|
||||
tab: ProposedCampaignTab;
|
||||
position: number;
|
||||
// null project = empty slot (added from the grid, not yet filled)
|
||||
projectId: number | null;
|
||||
projectTitle: string | null;
|
||||
projectImage: string | null;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
config: {
|
||||
slots: SlotAssignment[];
|
||||
};
|
||||
}
|
||||
|
||||
let { config }: Props = $props();
|
||||
|
||||
let activeTab = $state<ProposedCampaignTab>("ending-soon");
|
||||
let pickerOpen = $state(false);
|
||||
let editingIndex = $state<number | null>(null);
|
||||
let showError = $state(false);
|
||||
let errorMessage = $state("");
|
||||
|
||||
// Seeded once: later prop changes must not overwrite what the admin is editing
|
||||
const initialSlots = untrack(() => config.slots);
|
||||
|
||||
// Slots are grouped per tab; the array order within a tab is the display
|
||||
// order (top to bottom, left to right) and becomes the saved position.
|
||||
let slotsByTab = $state<Record<ProposedCampaignTab, SlotAssignment[]>>({
|
||||
"ending-soon": initialSlots
|
||||
.filter((s) => s.tab === "ending-soon")
|
||||
.sort((a, b) => a.position - b.position),
|
||||
"most-successful": initialSlots
|
||||
.filter((s) => s.tab === "most-successful")
|
||||
.sort((a, b) => a.position - b.position),
|
||||
});
|
||||
|
||||
let activeSlots = $derived(slotsByTab[activeTab]);
|
||||
|
||||
function handleTabChange(tabId: string) {
|
||||
activeTab = tabId as ProposedCampaignTab;
|
||||
}
|
||||
|
||||
function openPicker(index: number) {
|
||||
editingIndex = index;
|
||||
pickerOpen = true;
|
||||
}
|
||||
|
||||
function appendSlot() {
|
||||
const list = slotsByTab[activeTab];
|
||||
const empty: SlotAssignment = {
|
||||
tab: activeTab,
|
||||
position: list.length,
|
||||
projectId: null,
|
||||
projectTitle: null,
|
||||
projectImage: null,
|
||||
};
|
||||
slotsByTab = { ...slotsByTab, [activeTab]: [...list, empty] };
|
||||
}
|
||||
|
||||
function handleConfirmPick(project: PickedProject) {
|
||||
if (editingIndex === null) return;
|
||||
|
||||
const picked: SlotAssignment = {
|
||||
tab: activeTab,
|
||||
position: editingIndex,
|
||||
projectId: project.id,
|
||||
projectTitle: project.title,
|
||||
projectImage: project.image,
|
||||
};
|
||||
|
||||
slotsByTab = {
|
||||
...slotsByTab,
|
||||
[activeTab]: slotsByTab[activeTab].map((s, i) => (i === editingIndex ? picked : s)),
|
||||
};
|
||||
editingIndex = null;
|
||||
}
|
||||
|
||||
function handleClearProject(index: number) {
|
||||
slotsByTab = {
|
||||
...slotsByTab,
|
||||
[activeTab]: slotsByTab[activeTab].map((s, i) =>
|
||||
i === index ? { ...s, projectId: null, projectTitle: null, projectImage: null } : s,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
function handleRemoveSlot(index: number) {
|
||||
slotsByTab = {
|
||||
...slotsByTab,
|
||||
[activeTab]: slotsByTab[activeTab].filter((_, i) => i !== index),
|
||||
};
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
const { error } = await actions.saveProposedCampaigns({
|
||||
"ending-soon": slotsByTab["ending-soon"]
|
||||
.map((s) => s.projectId)
|
||||
.filter((id): id is number => id !== null),
|
||||
"most-successful": slotsByTab["most-successful"]
|
||||
.map((s) => s.projectId)
|
||||
.filter((id): id is number => id !== null),
|
||||
});
|
||||
|
||||
if (error) {
|
||||
errorMessage = error.message;
|
||||
showError = true;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-10">
|
||||
<header class="flex flex-col justify-between gap-6 sm:flex-row sm:items-start">
|
||||
<div class="flex max-w-150 flex-col gap-2">
|
||||
<Title level={2} variant="headline">{$t("pages.admin.home.proposed.title")}</Title>
|
||||
<p class="text-content text-base font-normal">
|
||||
{$t("pages.admin.home.proposed.description")}
|
||||
</p>
|
||||
</div>
|
||||
<ActionableButton action={handleSave} autoreset={2000} class="w-fit shrink-0 px-6">
|
||||
{$t("pages.admin.home.proposed.save")}
|
||||
</ActionableButton>
|
||||
</header>
|
||||
|
||||
<section class="flex flex-col gap-6">
|
||||
<div class="flex flex-col gap-2">
|
||||
<Title level={3} variant="subsection">
|
||||
{$t("pages.admin.home.proposed.projects.title")}
|
||||
</Title>
|
||||
<p class="text-content text-body-small">
|
||||
{$t("pages.admin.home.proposed.projects.description")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<CampaignsTabsNav {activeTab} onTabChange={handleTabChange} alignment="left" />
|
||||
|
||||
<Grid class="grid-cols-1 md:grid-cols-2 lg:grid-cols-2">
|
||||
{#each activeSlots as slot, index (index)}
|
||||
<ProjectSlotCard
|
||||
slotNumber={index + 1}
|
||||
project={slot.projectId !== null && slot.projectTitle !== null
|
||||
? { title: slot.projectTitle, image: slot.projectImage }
|
||||
: null}
|
||||
onAdd={() => openPicker(index)}
|
||||
onReplace={() => openPicker(index)}
|
||||
onRemove={() => handleClearProject(index)}
|
||||
onRemoveSlot={() => handleRemoveSlot(index)}
|
||||
/>
|
||||
{/each}
|
||||
<ProjectSlotCard variant="add" onAdd={appendSlot} />
|
||||
</Grid>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<Toast floating variant="error" bind:showToast={showError}>{errorMessage}</Toast>
|
||||
|
||||
<ProjectPickerModal
|
||||
bind:open={pickerOpen}
|
||||
title={$t("pages.admin.home.proposed.modal.title")}
|
||||
description={$t("pages.admin.home.proposed.modal.description")}
|
||||
searchLabel={$t("pages.admin.home.proposed.modal.search")}
|
||||
submitLabel={$t("pages.admin.home.proposed.modal.submit")}
|
||||
onConfirm={handleConfirmPick}
|
||||
/>
|
||||
@@ -5,6 +5,7 @@
|
||||
import { locale, t } from "../../../../i18n/store";
|
||||
import { getDefaultLanguage } from "../../../../utils/consts";
|
||||
import { endOfDay, formatDate, startOfDay } from "../../../../utils/dates";
|
||||
import { useFormDraft, restoreFields } from "../../../../utils/forms/useFormDraft.svelte";
|
||||
import { getLanguageDisplayName, primaryLanguage } from "../../../../utils/lang";
|
||||
import ActionableButton from "../../../library/buttons/ActionableButton.svelte";
|
||||
import Toast from "../../../library/feedback/Toast.svelte";
|
||||
@@ -42,19 +43,19 @@
|
||||
const defaultLanguage = getDefaultLanguage();
|
||||
|
||||
// Every language's texts live here, the base one included, and are saved together.
|
||||
let texts = $state<Record<string, BannerTexts>>(
|
||||
initial
|
||||
? Object.fromEntries(
|
||||
initial.languages.map((code) => [
|
||||
code,
|
||||
{
|
||||
...emptyTexts(),
|
||||
...(code === initial.language ? initial : initial.translations[code]),
|
||||
},
|
||||
]),
|
||||
)
|
||||
: { [defaultLanguage]: emptyTexts() },
|
||||
);
|
||||
const initialTexts: Record<string, BannerTexts> = initial
|
||||
? Object.fromEntries(
|
||||
initial.languages.map((code) => [
|
||||
code,
|
||||
{
|
||||
...emptyTexts(),
|
||||
...(code === initial.language ? initial : initial.translations[code]),
|
||||
},
|
||||
]),
|
||||
)
|
||||
: { [defaultLanguage]: emptyTexts() };
|
||||
|
||||
let texts = $state<Record<string, BannerTexts>>(initialTexts);
|
||||
let languages = $state<string[]>(initial?.languages ?? [defaultLanguage]);
|
||||
let selectedLanguage = $state(untrack(() => languages[0]));
|
||||
const active = $derived(texts[selectedLanguage]);
|
||||
@@ -93,6 +94,37 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Nothing in this form is sensitive, so all of it can be kept.
|
||||
*/
|
||||
const { restored } = useFormDraft("admin-home-banner", () => ({
|
||||
texts,
|
||||
languages,
|
||||
selectedLanguage,
|
||||
startsAt: startsAt.toISOString(),
|
||||
endsAt: endsAt.toISOString(),
|
||||
}));
|
||||
|
||||
if (restored) {
|
||||
restoreFields(texts, restored.texts);
|
||||
|
||||
if (restored.languages) {
|
||||
languages = restored.languages;
|
||||
}
|
||||
|
||||
if (restored.selectedLanguage) {
|
||||
selectedLanguage = restored.selectedLanguage;
|
||||
}
|
||||
|
||||
if (restored.startsAt) {
|
||||
startsAt = new Date(restored.startsAt);
|
||||
}
|
||||
|
||||
if (restored.endsAt) {
|
||||
endsAt = new Date(restored.endsAt);
|
||||
}
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
fieldErrors = {};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { actions } from "astro:actions";
|
||||
import { Modal, TableBodyCell } from "flowbite-svelte";
|
||||
import { untrack } from "svelte";
|
||||
|
||||
import BannersForm from "./BannersForm.svelte";
|
||||
import { locale, t } from "../../../../i18n/store";
|
||||
@@ -25,7 +26,7 @@
|
||||
|
||||
let { rows, onError, onSaved }: Props = $props();
|
||||
|
||||
let list = $state(rows);
|
||||
let list = $state(untrack(() => rows));
|
||||
|
||||
const headers: DataTableHeader[] = [
|
||||
{ key: "pages.admin.comm.banners.history.headers.title", sortable: false },
|
||||
@@ -178,7 +179,7 @@
|
||||
onclose={closeModal}
|
||||
size="lg"
|
||||
class="flex w-full max-w-224.5 flex-col gap-6 rounded-3xl bg-white p-6 shadow-lg"
|
||||
closeBtnClass="absolute top-4 right-4 text-secondary cursor-pointer hover:scale-110 transition-transform duration-200 hover:bg-transparent"
|
||||
closeBtnClass="top-10 end-12 p-1.5 [&_svg]:size-7 text-secondary cursor-pointer hover:scale-110 transition-transform duration-200 hover:bg-transparent"
|
||||
headerClass="md:p-0 p-0 border-b-0"
|
||||
bodyClass="md:p-0 p-0 border-b-0"
|
||||
>
|
||||
@@ -210,7 +211,7 @@
|
||||
<Modal
|
||||
open={rowToEdit !== null}
|
||||
onclose={() => (rowToEdit = null)}
|
||||
closeBtnClass="top-7 end-7 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
closeBtnClass="top-10 end-12 p-1.5 [&_svg]:size-7 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="backdrop:bg-overlay fixed top-1/2 left-1/2 mx-2 flex w-fit max-w-[min(46rem,calc(100vw-1rem))] min-w-152 -translate-x-1/2 -translate-y-1/2 divide-y-0 rounded-3xl bg-white shadow-lg backdrop:backdrop-blur-[5px] sm:mx-4 lg:mx-0"
|
||||
bodyClass="border-grey max-h-[90vh] overflow-y-auto rounded-t-3xl border-b bg-white p-6"
|
||||
>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { actions } from "astro:actions";
|
||||
import { untrack } from "svelte";
|
||||
|
||||
import HeroForm from "./HeroForm.svelte";
|
||||
import HeroHistory from "./HeroHistory.svelte";
|
||||
@@ -19,7 +20,7 @@
|
||||
let currentSubtab = $state("fields");
|
||||
let showError = $state(false);
|
||||
let errorMessage = $state("");
|
||||
let heroesList = $state(heroes);
|
||||
let heroesList = $state(untrack(() => heroes));
|
||||
|
||||
function handleTabChange(tabId: string) {
|
||||
currentSubtab = tabId;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { actions, isInputError } from "astro:actions";
|
||||
import { untrack } from "svelte";
|
||||
|
||||
import HeroPreviewModal from "./HeroPreviewModal.svelte";
|
||||
import { locale, t } from "../../../../i18n/store";
|
||||
import { getDefaultLanguage } from "../../../../utils/consts";
|
||||
import { formatDate, startOfDay } from "../../../../utils/dates";
|
||||
import { useFormDraft, restoreFields } from "../../../../utils/forms/useFormDraft.svelte";
|
||||
import {
|
||||
getLanguageDisplayName,
|
||||
primaryLanguage as pickPrimaryLanguage,
|
||||
@@ -98,12 +100,14 @@
|
||||
// translations, and the default can be removed like any other language
|
||||
// once a second one exists.
|
||||
const defaultLanguage = getDefaultLanguage();
|
||||
const baseLanguage = hero?.language || defaultLanguage;
|
||||
const languagesSeed = hero
|
||||
// Seeded once: later prop changes must not overwrite what the admin is editing
|
||||
const initialHero = untrack(() => hero);
|
||||
const baseLanguage = initialHero?.language || defaultLanguage;
|
||||
const languagesSeed = initialHero
|
||||
? [
|
||||
...new Set([
|
||||
baseLanguage,
|
||||
...(hero.languages ?? []).filter((code) => code !== baseLanguage),
|
||||
...(initialHero.languages ?? []).filter((code) => code !== baseLanguage),
|
||||
]),
|
||||
]
|
||||
: [defaultLanguage];
|
||||
@@ -111,9 +115,9 @@
|
||||
const initialFieldValues: Record<string, HeroFields> = {};
|
||||
for (const lang of languagesSeed) {
|
||||
initialFieldValues[lang] =
|
||||
lang === baseLanguage && hero
|
||||
? fieldsFromRecord(hero)
|
||||
: fieldsFromTranslations(hero?.translations?.[lang]);
|
||||
lang === baseLanguage && initialHero
|
||||
? fieldsFromRecord(initialHero)
|
||||
: fieldsFromTranslations(initialHero?.translations?.[lang]);
|
||||
}
|
||||
|
||||
let languages = $state<string[]>(languagesSeed);
|
||||
@@ -134,7 +138,7 @@
|
||||
|
||||
let startsAt = $state(new Date());
|
||||
|
||||
let media = $state<HeroMedia | undefined>(storedMedia(hero));
|
||||
let media = $state<HeroMedia | undefined>(storedMedia(initialHero));
|
||||
let isUploadOpen = $state(false);
|
||||
|
||||
let isPreviewOpen = $state(false);
|
||||
@@ -142,6 +146,37 @@
|
||||
|
||||
const isVideo = $derived(media?.type.startsWith("video/") ?? false);
|
||||
|
||||
/**
|
||||
* Nothing in this form is sensitive, so all of it can be kept.
|
||||
*/
|
||||
const { restored } = useFormDraft("admin-home-hero", () => ({
|
||||
fieldValues,
|
||||
languages,
|
||||
selectedLanguage,
|
||||
startsAt: startsAt.toISOString(),
|
||||
media,
|
||||
}));
|
||||
|
||||
if (restored) {
|
||||
restoreFields(fieldValues, restored.fieldValues);
|
||||
|
||||
if (restored.languages) {
|
||||
languages = restored.languages;
|
||||
}
|
||||
|
||||
if (restored.selectedLanguage) {
|
||||
selectedLanguage = restored.selectedLanguage;
|
||||
}
|
||||
|
||||
if (restored.startsAt) {
|
||||
startsAt = new Date(restored.startsAt);
|
||||
}
|
||||
|
||||
if (restored.media) {
|
||||
media = restored.media;
|
||||
}
|
||||
}
|
||||
|
||||
function storedMedia(record: HomeHeroRecord | null): HeroMedia | undefined {
|
||||
if (!record?.mediaUrl || !record.mediaType) {
|
||||
return undefined;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { actions } from "astro:actions";
|
||||
import { Modal, TableBodyCell } from "flowbite-svelte";
|
||||
import { tick } from "svelte";
|
||||
import { tick, untrack } from "svelte";
|
||||
|
||||
import HeroForm from "./HeroForm.svelte";
|
||||
import HeroPreviewModal from "./HeroPreviewModal.svelte";
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
let { rows, onError, onSaved }: Props = $props();
|
||||
|
||||
let list = $state(rows);
|
||||
let list = $state(untrack(() => rows));
|
||||
|
||||
// rows is refreshed after a save; keep the local list in sync, while the
|
||||
// local deletions below continue to apply on top of the incoming list.
|
||||
@@ -272,7 +272,7 @@
|
||||
|
||||
<Modal
|
||||
bind:open={isEditModalOpen}
|
||||
closeBtnClass="top-7 end-7 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
closeBtnClass="top-10 end-12 p-1.5 [&_svg]:size-7 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="backdrop:bg-overlay fixed top-1/2 left-1/2 mx-2 flex w-fit max-w-[min(46rem,calc(100vw-1rem))] min-w-152 -translate-x-1/2 -translate-y-1/2 divide-y-0 rounded-3xl bg-white shadow-lg backdrop:backdrop-blur-[5px] sm:mx-4 lg:mx-0"
|
||||
bodyClass="border-grey max-h-[90vh] overflow-y-auto rounded-t-3xl border-b bg-white p-6"
|
||||
>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import ProjectsModalAnnotations from "./ProjectsModalAnnotations.svelte";
|
||||
import ProjectsModalPaid from "./ProjectsModalPaid.svelte";
|
||||
// Paid modal hidden until the API persists the paid amount.
|
||||
// import ProjectsModalPaid from "./ProjectsModalPaid.svelte";
|
||||
import ProjectsTable, { type ProjectRow, type ProjectSortKey } from "./ProjectsTable.svelte";
|
||||
import { t } from "../../../i18n/store";
|
||||
import {
|
||||
@@ -8,9 +9,8 @@
|
||||
apiProjectsIdPatch,
|
||||
apiAccountingsIdGet,
|
||||
apiUsersIdOrHandleGet,
|
||||
apiProjectSupportsmoneyTotalGetCollection,
|
||||
apiProjectsIdOrSlugGetUrl,
|
||||
apiProjectsGetCollectionUrl,
|
||||
apiProjectsmoneyTotalGetCollection,
|
||||
type Project,
|
||||
type Accounting,
|
||||
type User,
|
||||
@@ -24,9 +24,11 @@
|
||||
splitOrderParams,
|
||||
syncQueryFiltersToUrl,
|
||||
} from "../../../utils/queryParams";
|
||||
import Toast from "../../library/feedback/Toast.svelte";
|
||||
import Dashboard from "../AdminDashboard.svelte";
|
||||
|
||||
import type { ApiProjectsGetCollectionData } from "../../../openapi/client/types.gen";
|
||||
import type { ProjectStatus } from "../../../utils/projectStatus";
|
||||
|
||||
type ProjectsQuery = Partial<ApiProjectsGetCollectionData["query"]>;
|
||||
|
||||
@@ -56,6 +58,7 @@
|
||||
let filters: ProjectsQuery = $state(initialParams.filters);
|
||||
let projectRows = $state<ProjectRow[]>([]);
|
||||
let totalEarned = $state("—");
|
||||
let isTotalEarnedLoading = $state(false);
|
||||
|
||||
let accountingsCache = $state(new Map<string, Accounting>());
|
||||
let ownersCache = $state(new Map<string, User>());
|
||||
@@ -72,12 +75,14 @@
|
||||
});
|
||||
|
||||
let annotationsCache = $state(new Map<number, string>());
|
||||
let paidModalOpen = $state(false);
|
||||
// let paidModalOpen = $state(false);
|
||||
let annotationsModalOpen = $state(false);
|
||||
let paidValue = $state("");
|
||||
let maxAchievedValue = $state("");
|
||||
// let paidValue = $state("");
|
||||
// let maxAchievedValue = $state("");
|
||||
let annotationText = $state("");
|
||||
let selectedProjectId = $state(0);
|
||||
let showError = $state(false);
|
||||
let errorMessage = $state("");
|
||||
|
||||
let projectSlides = $derived([
|
||||
{ title: $t("pages.admin.projects.totalizers.selected"), amount: table.totalItems },
|
||||
@@ -85,37 +90,22 @@
|
||||
]);
|
||||
|
||||
/**
|
||||
* Fetches the total money earned for a given list of project IDs.
|
||||
* @param ids - Array of project IDs
|
||||
* Totals the money earned by every project matching the table filters, not only the current
|
||||
* page: `money_total` takes the same filters as the projects collection.
|
||||
*/
|
||||
async function fetchTotalEarned(ids: number[]) {
|
||||
if (ids.length === 0) {
|
||||
totalEarned = formatCurrency(0, import.meta.env.PUBLIC_DEFAULT_CURRENCY);
|
||||
async function fetchTotalEarned(projectFilters: ProjectsQuery) {
|
||||
isTotalEarnedLoading = true;
|
||||
const { data, error } = await apiProjectsmoneyTotalGetCollection({
|
||||
baseUrl: "/api/relay",
|
||||
query: projectFilters,
|
||||
});
|
||||
isTotalEarnedLoading = false;
|
||||
if (error || !data) {
|
||||
console.error("Failed to fetch money total:", error);
|
||||
totalEarned = "—";
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { data, error } = await apiProjectSupportsmoneyTotalGetCollection({
|
||||
baseUrl: "/api/relay",
|
||||
query: {
|
||||
"project[]": ids.map((id) =>
|
||||
apiProjectsIdOrSlugGetUrl.replace("{idOrSlug}", String(id)),
|
||||
),
|
||||
},
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error("Failed to fetch money total:", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
const total = data.amount ?? 0;
|
||||
const currency = data.currency ?? import.meta.env.PUBLIC_DEFAULT_CURRENCY;
|
||||
totalEarned = formatCurrency(total, currency);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to fetch money total", e);
|
||||
}
|
||||
totalEarned = formatCurrency(data.amount ?? 0, data.currency);
|
||||
}
|
||||
|
||||
function buildProjectsQuery(
|
||||
@@ -186,8 +176,6 @@
|
||||
const loadedProjects = toCollectionItems<Project>(collection);
|
||||
table.totalItems = getCollectionTotalItems(collection, response);
|
||||
|
||||
const projectIds = loadedProjects.map((p) => p.id).filter(Boolean) as number[];
|
||||
|
||||
const uniqueAccountingIris = [
|
||||
...new Set(loadedProjects.map((p) => p.accounting).filter(Boolean)),
|
||||
] as string[];
|
||||
@@ -223,7 +211,6 @@
|
||||
return data ? ([iri, data] as const) : null;
|
||||
}),
|
||||
),
|
||||
fetchTotalEarned(projectIds),
|
||||
]);
|
||||
|
||||
for (const [iri, accounting] of accountingResults.filter(Boolean) as [
|
||||
@@ -243,20 +230,26 @@
|
||||
const owner = project.owner ? ownersCache.get(project.owner) : undefined;
|
||||
const balance = accounting?.balance;
|
||||
const calendar = project.calendar;
|
||||
const min = project.budget?.minimum?.money;
|
||||
const opt = project.budget?.optimum?.money;
|
||||
|
||||
return {
|
||||
id: project.id ?? 0,
|
||||
name: project.title,
|
||||
slug: project.slug ?? "",
|
||||
slug: project.slug ?? String(project.id),
|
||||
promoter: owner?.displayName ?? owner?.email ?? "—",
|
||||
promoterHandle: owner?.handle ?? "",
|
||||
achieved: balance ? formatCurrency(balance.amount, balance.currency) : "—",
|
||||
paid: "—",
|
||||
paidMatchfunding: "—",
|
||||
status: project.status ?? "",
|
||||
status: project.status ?? "in_draft",
|
||||
datePublished: calendar?.release ?? "—",
|
||||
dateEnd1: calendar?.minimum ?? "—",
|
||||
dateEnd2: calendar?.optimum ?? "—",
|
||||
minOptim: "—",
|
||||
minOptim:
|
||||
min && opt
|
||||
? `${formatCurrency(min.amount, min.currency)} - ${formatCurrency(opt.amount, opt.currency)}`
|
||||
: "—",
|
||||
remaining: "—",
|
||||
annotationsCount: 0,
|
||||
annotations: "",
|
||||
@@ -280,6 +273,10 @@
|
||||
reloadProjects();
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
fetchTotalEarned(filters);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
const sortOption = sortFieldMap[table.selectedSort];
|
||||
|
||||
@@ -299,22 +296,32 @@
|
||||
table.currentPage = 1;
|
||||
}
|
||||
|
||||
async function handleStatusChange(projectId: number, status: string): Promise<void> {
|
||||
/** The API rejects transitions that break the project life-cycle; those surface as a toast. */
|
||||
async function handleStatusChange(projectId: number, status: ProjectStatus): Promise<boolean> {
|
||||
const { error } = await apiProjectsIdPatch({
|
||||
baseUrl: "/api/relay",
|
||||
path: { id: String(projectId) },
|
||||
body: { status: status as any },
|
||||
body: { status },
|
||||
});
|
||||
if (error) console.error("Failed to update project status:", error);
|
||||
if (error) {
|
||||
const detail = (error as { detail?: string | null }).detail;
|
||||
errorMessage = `${$t("pages.admin.projects.table.rows.details.statusChangeError")}${detail ? `: ${detail}` : ""}`;
|
||||
showError = true;
|
||||
return false;
|
||||
}
|
||||
const row = projectRows.find((p) => p.id === projectId);
|
||||
if (row) row.status = status;
|
||||
return true;
|
||||
}
|
||||
|
||||
function openPaidModal(project: ProjectRow, e: MouseEvent) {
|
||||
e.stopPropagation();
|
||||
selectedProjectId = project.id;
|
||||
paidValue = project.paid !== "—" ? project.paid : "";
|
||||
maxAchievedValue = project.achieved !== "—" ? project.achieved : "";
|
||||
paidModalOpen = true;
|
||||
}
|
||||
// Re-enable with `onOpenPaidModal={openPaidModal}` on <ProjectsTable> and the modal below.
|
||||
// function openPaidModal(project: ProjectRow, e: MouseEvent) {
|
||||
// e.stopPropagation();
|
||||
// selectedProjectId = project.id;
|
||||
// paidValue = project.paid !== "—" ? project.paid : "";
|
||||
// maxAchievedValue = project.achieved !== "—" ? project.achieved : "";
|
||||
// paidModalOpen = true;
|
||||
// }
|
||||
|
||||
function openAnnotationsModal(project: ProjectRow, e: MouseEvent) {
|
||||
e.stopPropagation();
|
||||
@@ -323,10 +330,10 @@
|
||||
annotationsModalOpen = true;
|
||||
}
|
||||
|
||||
function handleSavePaid() {
|
||||
reloadProjects();
|
||||
paidModalOpen = false;
|
||||
}
|
||||
// function handleSavePaid() {
|
||||
// reloadProjects();
|
||||
// paidModalOpen = false;
|
||||
// }
|
||||
|
||||
function handleSaveAnnotations() {
|
||||
annotationsCache = new Map(annotationsCache).set(selectedProjectId, annotationText);
|
||||
@@ -366,7 +373,7 @@
|
||||
}}
|
||||
slider={{
|
||||
slides: projectSlides,
|
||||
isLoading: table.isLoading,
|
||||
isLoading: table.isLoading || isTotalEarnedLoading,
|
||||
}}
|
||||
>
|
||||
<ProjectsTable
|
||||
@@ -381,17 +388,19 @@
|
||||
onItemsPerPageChange={table.handleItemsPerPageChange}
|
||||
onSortChange={table.handleSortChange}
|
||||
onStatusChange={handleStatusChange}
|
||||
onOpenPaidModal={openPaidModal}
|
||||
onOpenAnnotationsModal={openAnnotationsModal}
|
||||
/>
|
||||
</Dashboard>
|
||||
|
||||
<!-- Paid modal hidden until the API persists the paid amount.
|
||||
<ProjectsModalPaid
|
||||
bind:open={paidModalOpen}
|
||||
bind:paidValue
|
||||
maxAchieved={maxAchievedValue}
|
||||
onsave={handleSavePaid}
|
||||
/>
|
||||
-->
|
||||
<Toast floating variant="error" bind:showToast={showError}>{errorMessage}</Toast>
|
||||
<ProjectsModalAnnotations
|
||||
bind:open={annotationsModalOpen}
|
||||
bind:annotationText
|
||||
|
||||
@@ -1,24 +1,38 @@
|
||||
<script lang="ts">
|
||||
import Comments from "../../../components/icons/Comments.svelte";
|
||||
// Re-enable with the annotations button below.
|
||||
// import Comments from "../../../components/icons/Comments.svelte";
|
||||
import { t, locale } from "../../../i18n/store";
|
||||
import { formatDate } from "../../../utils/dates";
|
||||
import DetailsRow, { type DetailsField } from "../DetailsRow.svelte";
|
||||
import { PROJECT_STATUSES, projectStatusLabelKey } from "../../../utils/projectStatus";
|
||||
import Select from "../../library/inputs/Select.svelte";
|
||||
import ProjectPreviewModal from "../../project/edit/ProjectPreviewModal.svelte";
|
||||
import { extractId } from "../../../utils/extractId";
|
||||
import DetailsRow, { type DetailsField } from "../DetailsRow.svelte";
|
||||
|
||||
import type { ProjectRow } from "./ProjectsTable.svelte";
|
||||
import type { ProjectStatus } from "../../../utils/projectStatus";
|
||||
|
||||
interface Props {
|
||||
project: ProjectRow;
|
||||
onOpenAnnotationsModal: () => void;
|
||||
onChangeStatus?: (projectId: number) => void;
|
||||
onStatusChange: (projectId: number, status: ProjectStatus) => Promise<boolean>;
|
||||
userEmail?: string;
|
||||
}
|
||||
|
||||
let { project, onOpenAnnotationsModal, onChangeStatus, userEmail }: Props = $props();
|
||||
let { project, onOpenAnnotationsModal, onStatusChange, userEmail }: Props = $props();
|
||||
|
||||
// Bound to the select; reset to the project's status when the API rejects the change.
|
||||
let selectedStatus = $derived<string>(project.status);
|
||||
let isSavingStatus = $state(false);
|
||||
let previewOpen = $state(false);
|
||||
|
||||
async function handleStatusSelect(status: string) {
|
||||
if (status === project.status) return;
|
||||
isSavingStatus = true;
|
||||
const ok = await onStatusChange(project.id, status as ProjectStatus);
|
||||
isSavingStatus = false;
|
||||
if (!ok) selectedStatus = project.status;
|
||||
}
|
||||
|
||||
const fields: DetailsField[] = $derived([
|
||||
{
|
||||
label: $t("pages.admin.projects.table.rows.details.datePublished"),
|
||||
@@ -53,61 +67,49 @@
|
||||
},
|
||||
]);
|
||||
|
||||
function navigateToCharges() {
|
||||
if (!project.accounting) return;
|
||||
window.location.href = `/${$locale}/admin/charges?target=${encodeURIComponent(project.accounting)}`;
|
||||
}
|
||||
|
||||
function navigateToPromoter() {
|
||||
if (!project.owner) return;
|
||||
const ownerId = extractId(project.owner) || project.owner;
|
||||
window.location.href = `/${$locale}/user/${ownerId}`;
|
||||
}
|
||||
|
||||
function navigateToEdit() {
|
||||
const projectIdentifier = project.slug || project.id;
|
||||
if (!projectIdentifier) return;
|
||||
window.location.href = `/${$locale}/project/${projectIdentifier}/edit`;
|
||||
}
|
||||
|
||||
const isInCampaign = $derived(project.status === "in_campaign");
|
||||
|
||||
const actionKeys = ["promoter", "contributions", "campaignPageOrPreview", "edit"] as const;
|
||||
|
||||
function handleActionClick(key: (typeof actionKeys)[number]) {
|
||||
if (key === "contributions") navigateToCharges();
|
||||
if (key === "promoter") navigateToPromoter();
|
||||
if (key === "edit") navigateToEdit();
|
||||
if (key === "campaignPageOrPreview") {
|
||||
if (isInCampaign) {
|
||||
const projectIdentifier = project.slug || project.id;
|
||||
if (!projectIdentifier) return;
|
||||
window.location.href = `/${$locale}/project/${projectIdentifier}`;
|
||||
} else {
|
||||
previewOpen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
const actionClass =
|
||||
"border-secondary text-secondary cursor-pointer rounded-full border bg-white px-5 py-2 text-sm";
|
||||
</script>
|
||||
|
||||
<DetailsRow {fields} columns={4}>
|
||||
{#snippet actions()}
|
||||
<div class="flex flex-row flex-wrap gap-3">
|
||||
{#each actionKeys as key (key)}
|
||||
<button
|
||||
type="button"
|
||||
class="border-secondary text-secondary cursor-pointer rounded-full border bg-white px-5 py-2 text-sm"
|
||||
onclick={() => handleActionClick(key)}
|
||||
<div class="flex flex-row flex-wrap items-center gap-3">
|
||||
<Select
|
||||
class="py-2 text-sm"
|
||||
labelText={$t("pages.admin.projects.table.rows.details.status")}
|
||||
bind:value={selectedStatus}
|
||||
disabled={isSavingStatus}
|
||||
onChange={handleStatusSelect}
|
||||
>
|
||||
{#each PROJECT_STATUSES as status (status)}
|
||||
<option value={status}>{$t(projectStatusLabelKey(status))}</option>
|
||||
{/each}
|
||||
</Select>
|
||||
{#if project.promoterHandle}
|
||||
<a class={actionClass} href={`/${$locale}/user/${project.promoterHandle}`}>
|
||||
{$t("pages.admin.projects.table.rows.details.btns.promoter")}
|
||||
</a>
|
||||
{/if}
|
||||
{#if project.accounting}
|
||||
<a
|
||||
class={actionClass}
|
||||
href={`/${$locale}/admin/charges?target=${encodeURIComponent(project.accounting)}`}
|
||||
>
|
||||
{key === "campaignPageOrPreview"
|
||||
? isInCampaign
|
||||
? $t("pages.admin.projects.table.rows.details.btns.campaignPage")
|
||||
: $t("pages.admin.projects.table.rows.details.btns.preview")
|
||||
: key === "edit"
|
||||
? $t("pages.admin.projects.table.rows.details.btns.edit")
|
||||
: $t(`pages.admin.projects.table.rows.details.btns.${key}`)}
|
||||
{$t("pages.admin.projects.table.rows.details.btns.contributions")}
|
||||
</a>
|
||||
{/if}
|
||||
<a class={actionClass} href={`/${$locale}/project/${project.slug}/edit`}>
|
||||
{$t("pages.admin.projects.table.rows.details.btns.edit")}
|
||||
</a>
|
||||
{#if project.status === "in_campaign"}
|
||||
<a class={actionClass} href={`/${$locale}/project/${project.slug}`}>
|
||||
{$t("pages.admin.projects.table.rows.details.btns.campaignPage")}
|
||||
</a>
|
||||
{:else}
|
||||
<button type="button" class={actionClass} onclick={() => (previewOpen = true)}>
|
||||
{$t("pages.admin.projects.table.rows.details.btns.preview")}
|
||||
</button>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
{/snippet}
|
||||
{#snippet footer()}
|
||||
@@ -125,6 +127,7 @@
|
||||
{$t("pages.admin.projects.table.rows.details.btns.certificates")}
|
||||
</button>
|
||||
-->
|
||||
<!-- Hidden until the API persists annotations: the modal only keeps them in memory.
|
||||
<button
|
||||
onclick={onOpenAnnotationsModal}
|
||||
class="text-secondary bg-variant1 flex min-h-10 cursor-pointer flex-row items-center gap-2 rounded-2xl px-4 py-2 font-bold"
|
||||
@@ -135,6 +138,7 @@
|
||||
({project.annotationsCount})
|
||||
{/if}
|
||||
</button>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
@@ -5,15 +5,13 @@
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import TextArea from "../../library/inputs/TextArea.svelte";
|
||||
|
||||
let {
|
||||
open = $bindable(false),
|
||||
annotationText = $bindable(""),
|
||||
onsave,
|
||||
} = $props<{
|
||||
interface Props {
|
||||
open: boolean;
|
||||
annotationText: string;
|
||||
onsave?: (text: string) => void;
|
||||
}>();
|
||||
}
|
||||
|
||||
let { open = $bindable(false), annotationText = $bindable(""), onsave }: Props = $props();
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts" module>
|
||||
import type { ProjectStatus } from "../../../utils/projectStatus";
|
||||
import type { DataTableHeader, SortOption } from "../../library/tables/DataTable.svelte";
|
||||
|
||||
export type ProjectRow = {
|
||||
@@ -6,10 +7,11 @@
|
||||
name: string;
|
||||
slug: string;
|
||||
promoter: string;
|
||||
promoterHandle: string;
|
||||
achieved: string;
|
||||
paid: string;
|
||||
paidMatchfunding: string;
|
||||
status: string;
|
||||
status: ProjectStatus;
|
||||
datePublished: string;
|
||||
dateEnd1: string;
|
||||
dateEnd2: string;
|
||||
@@ -46,7 +48,8 @@
|
||||
{ key: "pages.admin.projects.table.headers.name" },
|
||||
{ key: "pages.admin.projects.table.headers.promoter" },
|
||||
{ key: "pages.admin.projects.table.headers.achieved" },
|
||||
{ key: "pages.admin.projects.table.headers.paid" },
|
||||
// Hidden until the API provides the paid amount (also the cell below).
|
||||
// { key: "pages.admin.projects.table.headers.paid" },
|
||||
{ key: "pages.admin.projects.table.headers.process" },
|
||||
{ key: "", class: "w-12" },
|
||||
];
|
||||
@@ -54,13 +57,14 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { TableBodyCell } from "flowbite-svelte";
|
||||
import { SvelteSet } from "svelte/reactivity";
|
||||
|
||||
import ProjectsDetailsRow from "./ProjectsDetailsRow.svelte";
|
||||
import { t } from "../../../i18n/store";
|
||||
import { ADMIN_ITEMS_PER_PAGE_OPTIONS } from "../../../utils/adminTable";
|
||||
import { projectStatusLabelKey } from "../../../utils/projectStatus";
|
||||
import Chevron from "../../icons/navigation/Chevron.svelte";
|
||||
import DataTable from "../../library/tables/DataTable.svelte";
|
||||
import Tag from "../../library/tags/Tag.svelte";
|
||||
|
||||
let {
|
||||
projects = [],
|
||||
@@ -76,7 +80,6 @@
|
||||
onStatusChange,
|
||||
onOpenPaidModal,
|
||||
onOpenAnnotationsModal,
|
||||
onChangeStatus,
|
||||
}: {
|
||||
projects: ProjectRow[];
|
||||
currentPage: number;
|
||||
@@ -88,85 +91,16 @@
|
||||
onPageChange?: (page: number) => void;
|
||||
onItemsPerPageChange?: (perPage: number) => void;
|
||||
onSortChange?: (sort: ProjectSortKey) => void;
|
||||
onStatusChange?: (projectId: number, status: string) => Promise<void>;
|
||||
onStatusChange: (projectId: number, status: ProjectStatus) => Promise<boolean>;
|
||||
onOpenPaidModal?: (project: ProjectRow, e: MouseEvent) => void;
|
||||
onOpenAnnotationsModal?: (project: ProjectRow, e: MouseEvent) => void;
|
||||
onChangeStatus?: (projectId: number) => void;
|
||||
} = $props();
|
||||
|
||||
let openRow = $state<number | null>(null);
|
||||
|
||||
const statusOptions = [
|
||||
{ value: "in_draft", label: $t("domain.project.status.in_draft") },
|
||||
{
|
||||
value: "to_campaign_review",
|
||||
label: $t("domain.project.status.to_campaign_review"),
|
||||
},
|
||||
{
|
||||
value: "in_campaign_review",
|
||||
label: $t("domain.project.status.in_campaign_review"),
|
||||
},
|
||||
{
|
||||
value: "in_campaign_review.to_change",
|
||||
label: $t("domain.project.status.in_campaign_review_to_change"),
|
||||
},
|
||||
{
|
||||
value: "in_campaign_review.to_review",
|
||||
label: $t("domain.project.status.in_campaign_review_to_review"),
|
||||
},
|
||||
{
|
||||
value: "campaign_review_rejected",
|
||||
label: $t("domain.project.status.campaign_review_rejected"),
|
||||
},
|
||||
{ value: "to_campaign", label: $t("domain.project.status.to_campaign") },
|
||||
{ value: "in_campaign", label: $t("domain.project.status.in_campaign") },
|
||||
{
|
||||
value: "campaign_failed",
|
||||
label: $t("domain.project.status.campaign_failed"),
|
||||
},
|
||||
{
|
||||
value: "campaign_cancelled",
|
||||
label: $t("domain.project.status.campaign_cancelled"),
|
||||
},
|
||||
{
|
||||
value: "to_funding_review",
|
||||
label: $t("domain.project.status.to_funding_review"),
|
||||
},
|
||||
{
|
||||
value: "in_funding_review",
|
||||
label: $t("domain.project.status.in_funding_review"),
|
||||
},
|
||||
{
|
||||
value: "in_funding_review.to_change",
|
||||
label: $t("domain.project.status.in_funding_review_to_change"),
|
||||
},
|
||||
{
|
||||
value: "in_funding_review.to_review",
|
||||
label: $t("domain.project.status.in_funding_review_to_review"),
|
||||
},
|
||||
{
|
||||
value: "funding_review_rejected",
|
||||
label: $t("domain.project.status.funding_review_rejected"),
|
||||
},
|
||||
{ value: "to_funding", label: $t("domain.project.status.to_funding") },
|
||||
{ value: "in_funding", label: $t("domain.project.status.in_funding") },
|
||||
{ value: "funding_paid", label: $t("domain.project.status.funding_paid") },
|
||||
];
|
||||
|
||||
function toggleRow(_row: ProjectRow, index: number): void {
|
||||
openRow = openRow === index ? null : index;
|
||||
}
|
||||
|
||||
const updatingStatus = new SvelteSet<number>();
|
||||
|
||||
async function handleStatusChangeInline(project: ProjectRow, newStatus: string) {
|
||||
updatingStatus.add(project.id);
|
||||
try {
|
||||
await onStatusChange?.(project.id, newStatus);
|
||||
} finally {
|
||||
updatingStatus.delete(project.id);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<DataTable
|
||||
@@ -199,6 +133,7 @@
|
||||
<TableBodyCell class="border-variant1 border-t border-b p-4">
|
||||
{project.achieved}
|
||||
</TableBodyCell>
|
||||
<!-- Hidden until the API provides the paid amount: the column shows "—" and the modal saves nothing.
|
||||
<TableBodyCell class="border-variant1 border-t border-b p-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<span>{project.paid}</span>
|
||||
@@ -211,19 +146,11 @@
|
||||
</button>
|
||||
</div>
|
||||
</TableBodyCell>
|
||||
-->
|
||||
<TableBodyCell class="border-variant1 border-t border-b p-4">
|
||||
<div onclick={(e) => e.stopPropagation()} role="presentation">
|
||||
<select
|
||||
class="border-secondary text-secondary rounded-sm border py-1 text-sm disabled:opacity-50"
|
||||
value={project.status}
|
||||
disabled={updatingStatus.has(project.id)}
|
||||
onchange={(e) => handleStatusChangeInline(project, e.currentTarget.value)}
|
||||
>
|
||||
{#each statusOptions as opt}
|
||||
<option value={opt.value}>{opt.label}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
<Tag class="border-secondary max-w-56 rounded-md border">
|
||||
<span class="truncate">{$t(projectStatusLabelKey(project.status))}</span>
|
||||
</Tag>
|
||||
</TableBodyCell>
|
||||
<TableBodyCell
|
||||
class="border-variant1 text-content rounded-r-md border-t border-r border-b p-4 text-sm"
|
||||
@@ -241,7 +168,7 @@
|
||||
{project}
|
||||
onOpenAnnotationsModal={() =>
|
||||
onOpenAnnotationsModal?.(project, new MouseEvent("click"))}
|
||||
{onChangeStatus}
|
||||
{onStatusChange}
|
||||
userEmail={userEmailById.get(project.id)}
|
||||
/>
|
||||
{/snippet}
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
apiUsersGetCollectionUrl,
|
||||
type User,
|
||||
} from "../../../openapi/client/index.ts";
|
||||
import { debounce } from "../../../utils/debounce.ts";
|
||||
import { toCollectionItems } from "../../../utils/hydra";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import DropdownMenu from "../../library/dropdown/DropdownMenu.svelte";
|
||||
import DropdownSearch from "../../library/dropdown/DropdownSearch.svelte";
|
||||
import UserResultRow from "../../library/dropdown/UserResultRow.svelte";
|
||||
import Title from "../../library/typography/Title.svelte";
|
||||
|
||||
@@ -34,7 +33,6 @@
|
||||
onAssign: (iri: string, name: string) => void;
|
||||
} = $props();
|
||||
|
||||
let candidates = $state<DropdownOption[]>([]);
|
||||
let searchValue = $state("");
|
||||
let selected = $state<DropdownOption[]>([]);
|
||||
|
||||
@@ -47,24 +45,14 @@
|
||||
};
|
||||
}
|
||||
|
||||
const searchUsers = debounce(async (term: string) => {
|
||||
async function searchUsers(term: string, signal: AbortSignal): Promise<DropdownOption[]> {
|
||||
const { data } = await apiUsersGetCollection({
|
||||
baseUrl: "/api/relay",
|
||||
query: { q: term.trim(), itemsPerPage: 30 },
|
||||
query: { q: term, itemsPerPage: 30 },
|
||||
signal,
|
||||
});
|
||||
|
||||
candidates = toCollectionItems<User>(data).map(toOption);
|
||||
}, 250);
|
||||
|
||||
function handleSearch(value: string): void {
|
||||
const trimmed = value.trim();
|
||||
if (trimmed.length < 2) {
|
||||
searchUsers.cancel();
|
||||
candidates = [];
|
||||
return;
|
||||
}
|
||||
|
||||
searchUsers(trimmed);
|
||||
return toCollectionItems<User>(data).map(toOption);
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
@@ -93,7 +81,7 @@
|
||||
|
||||
<Modal
|
||||
bind:open
|
||||
closeBtnClass="top-3 end-3 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
closeBtnClass="top-10 end-12 p-1.5 [&_svg]:size-7 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="backdrop:bg-overlay fixed top-1/2 left-1/2 mx-2 flex w-full max-w-120 -translate-x-1/2 -translate-y-1/2 flex-col gap-6 overflow-visible rounded-3xl border-b-0 bg-white p-6 shadow-lg backdrop:backdrop-blur-[5px] sm:mx-4 lg:mx-0"
|
||||
headerClass="border-b-0 md:p-0 p-0"
|
||||
bodyClass="md:p-0 p-0 border-b-0 overflow-y-visible"
|
||||
@@ -109,17 +97,17 @@
|
||||
{$t("pages.admin.reviews.projects.table.rows.details.modals.assignAdvisor.description")}
|
||||
</p>
|
||||
|
||||
<DropdownMenu
|
||||
options={candidates}
|
||||
<DropdownSearch
|
||||
search={searchUsers}
|
||||
minChars={2}
|
||||
debounceMs={250}
|
||||
bind:selected
|
||||
bind:searchValue
|
||||
bind:value={searchValue}
|
||||
variant="basic"
|
||||
singleSelect
|
||||
hasSearch
|
||||
searchPlaceholder={$t(
|
||||
placeholder={$t(
|
||||
"pages.admin.reviews.projects.table.rows.details.modals.assignAdvisor.searchPlaceholder",
|
||||
)}
|
||||
onSearch={handleSearch}
|
||||
label={title}
|
||||
selectedFirst
|
||||
>
|
||||
@@ -128,7 +116,7 @@
|
||||
<UserResultRow user={option.raw as User} />
|
||||
{/if}
|
||||
{/snippet}
|
||||
</DropdownMenu>
|
||||
</DropdownSearch>
|
||||
|
||||
{#snippet footer()}
|
||||
<Button kind="secondary" disabled={!selected.length} onclick={confirm} class="w-fit">
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
import { SvelteMap } from "svelte/reactivity";
|
||||
|
||||
import AssignAdvisorModal from "./AssignAdvisorModal.svelte";
|
||||
import ReviewProjectsTable, {
|
||||
type ProjectStatus,
|
||||
type ReviewProjectRow,
|
||||
} from "./ReviewProjectsTable.svelte";
|
||||
import ReviewProjectsTable, { type ReviewProjectRow } from "./ReviewProjectsTable.svelte";
|
||||
import { t } from "../../../i18n/store";
|
||||
import {
|
||||
apiProjectReviewAreasGetCollection,
|
||||
@@ -31,6 +28,7 @@
|
||||
|
||||
import type { ApiProjectReviewsGetCollectionData } from "../../../openapi/client/types.gen";
|
||||
import type { ProjectReviewRisk } from "../../../types/projectReview";
|
||||
import type { ProjectStatus } from "../../../utils/projectStatus";
|
||||
|
||||
type ReviewsQuery = Partial<ApiProjectReviewsGetCollectionData["query"]>;
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<script lang="ts" module>
|
||||
import type { Project, ProjectReview } from "../../../openapi/client/index.ts";
|
||||
import type { ProjectReview } from "../../../openapi/client/index.ts";
|
||||
import type { ProjectReviewRisk } from "../../../types/projectReview";
|
||||
import type { ProjectStatus } from "../../../utils/projectStatus";
|
||||
import type { DataTableHeader } from "../../library/tables/DataTable.svelte";
|
||||
|
||||
export type ProjectStatus = NonNullable<Project["status"]>;
|
||||
|
||||
export type ReviewProjectRow = {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -50,7 +49,7 @@
|
||||
import { t, locale } from "../../../i18n/store";
|
||||
import { ADMIN_ITEMS_PER_PAGE_OPTIONS } from "../../../utils/adminTable";
|
||||
import { formatDate } from "../../../utils/dates";
|
||||
import { REVIEW_STATUSES_BY_TYPE } from "../../../utils/projectStatus";
|
||||
import { projectStatusLabelKey, REVIEW_STATUSES_BY_TYPE } from "../../../utils/projectStatus";
|
||||
import { RISK_SQUARE_CLASSES } from "../../../utils/review";
|
||||
import Comments from "../../icons/Comments.svelte";
|
||||
import Chevron from "../../icons/navigation/Chevron.svelte";
|
||||
@@ -106,9 +105,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
const statusLabel = (status: string) =>
|
||||
$t(`domain.project.status.${status.replaceAll(".", "_")}`);
|
||||
|
||||
/**
|
||||
* Statuses a project can move to for the kind of review it is going through.
|
||||
* Whatever status the project holds is always offered, so a review that
|
||||
@@ -190,7 +186,7 @@
|
||||
<option value="">—</option>
|
||||
{/if}
|
||||
{#each statusOptions(project) as status (status)}
|
||||
<option value={status}>{statusLabel(status)}</option>
|
||||
<option value={status}>{$t(projectStatusLabelKey(status))}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<script lang="ts" generics="T">
|
||||
import { Modal } from "flowbite-svelte";
|
||||
import { untrack } from "svelte";
|
||||
import { twMerge, type ClassNameValue } from "tailwind-merge";
|
||||
|
||||
import { t } from "../../../i18n/store";
|
||||
import { debounce } from "../../../utils/debounce";
|
||||
import { useFormDraft } from "../../../utils/forms/useFormDraft.svelte";
|
||||
import ActionableButton from "../../library/buttons/ActionableButton.svelte";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import DropdownMenu from "../../library/dropdown/DropdownMenu.svelte";
|
||||
import DropdownSearch from "../../library/dropdown/DropdownSearch.svelte";
|
||||
import Toast from "../../library/feedback/Toast.svelte";
|
||||
import Title from "../../library/typography/Title.svelte";
|
||||
|
||||
@@ -32,6 +33,9 @@
|
||||
|
||||
/** Persists the assigned values in slot order. */
|
||||
onSave: (slots: SlotContent<T>[]) => Promise<{ error?: { message: string } } | void>;
|
||||
|
||||
/** Identifies the draft of this editor, so two of them do not write over each other. */
|
||||
draftId?: string;
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -42,6 +46,7 @@
|
||||
labels,
|
||||
search,
|
||||
onSave,
|
||||
draftId = "slot-editor",
|
||||
}: Props = $props();
|
||||
|
||||
/**
|
||||
@@ -49,43 +54,38 @@
|
||||
* user put them instead of compacting them upwards. Gaps are only collapsed
|
||||
* at save time, which is what the persistence layer expects.
|
||||
*/
|
||||
let assignments = $state<(SlotContent<T> | undefined)[]>([...contents]);
|
||||
let assignments = $state<(SlotContent<T> | undefined)[]>(untrack(() => [...contents]));
|
||||
let pickerOpen = $state(false);
|
||||
let editingIndex = $state<number | null>(null);
|
||||
let query = $state("");
|
||||
let options = $state<DropdownOption[]>([]);
|
||||
let picked = $state<DropdownOption[]>([]);
|
||||
/** Last results, kept so confirming an option can recover the full value. */
|
||||
let candidates = $state<SlotContent<T>[]>([]);
|
||||
let showError = $state(false);
|
||||
let errorMessage = $state("");
|
||||
|
||||
const runSearch = debounce(async (term: string) => {
|
||||
candidates = await search(term);
|
||||
options = candidates.map((c, i) => ({
|
||||
id: String(i),
|
||||
label: c.label,
|
||||
selected: false,
|
||||
}));
|
||||
});
|
||||
/**
|
||||
* The assigned slots are what the editor holds, so they are what can be kept.
|
||||
*/
|
||||
const { restored } = useFormDraft(
|
||||
untrack(() => draftId),
|
||||
() => ({ assignments }),
|
||||
);
|
||||
|
||||
function handleSearch(term: string) {
|
||||
const trimmed = term.trim();
|
||||
if (restored?.assignments) {
|
||||
assignments = restored.assignments;
|
||||
}
|
||||
|
||||
if (trimmed.length < 2) {
|
||||
runSearch.cancel();
|
||||
options = [];
|
||||
candidates = [];
|
||||
return;
|
||||
}
|
||||
|
||||
runSearch(trimmed);
|
||||
async function searchOptions(term: string, signal: AbortSignal): Promise<DropdownOption[]> {
|
||||
const results = await search(term);
|
||||
// A superseded search must not replace the candidates the options index into.
|
||||
if (!signal.aborted) candidates = results;
|
||||
return results.map((c, i) => ({ id: String(i), label: c.label, selected: false }));
|
||||
}
|
||||
|
||||
function openPicker(index: number) {
|
||||
editingIndex = index;
|
||||
query = "";
|
||||
options = [];
|
||||
candidates = [];
|
||||
picked = [];
|
||||
pickerOpen = true;
|
||||
@@ -189,7 +189,7 @@
|
||||
|
||||
<Modal
|
||||
bind:open={pickerOpen}
|
||||
closeBtnClass="top-3 end-3 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
closeBtnClass="top-10 end-12 p-1.5 [&_svg]:size-7 cursor-pointer bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="backdrop:bg-overlay fixed top-1/2 left-1/2 mx-2 flex w-full max-w-172 -translate-x-1/2 -translate-y-1/2 flex-col gap-6 divide-y-0 overflow-visible rounded-3xl bg-white p-6 shadow-lg backdrop:backdrop-blur-[5px] sm:mx-4 lg:mx-0"
|
||||
headerClass="md:p-0 p-0 border-none"
|
||||
bodyClass="md:p-0 p-0 border-none overflow-y-visible"
|
||||
@@ -209,17 +209,16 @@
|
||||
{labels.searchPlaceholder}
|
||||
</span>
|
||||
{/if}
|
||||
<DropdownMenu
|
||||
<DropdownSearch
|
||||
variant="basic"
|
||||
hasSearch
|
||||
singleSelect
|
||||
clearable
|
||||
{options}
|
||||
search={searchOptions}
|
||||
minChars={2}
|
||||
bind:selected={picked}
|
||||
bind:searchValue={query}
|
||||
onSearch={handleSearch}
|
||||
bind:value={query}
|
||||
searchClasses="rounded-3xl border-secondary shadow-none"
|
||||
searchPlaceholder={labels.searchPlaceholder}
|
||||
placeholder={labels.searchPlaceholder}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
import { formatDate } from "../../../utils/dates";
|
||||
import Close from "../../icons/navigation/Close.svelte";
|
||||
import Button from "../../library/buttons/Button.svelte";
|
||||
import DropdownMenu from "../../library/dropdown/DropdownMenu.svelte";
|
||||
import DropdownSearch from "../../library/dropdown/DropdownSearch.svelte";
|
||||
import Toast from "../../library/feedback/Toast.svelte";
|
||||
import PasswordInput from "../../library/inputs/PasswordInput.svelte";
|
||||
import { chargeStatusStyles } from "../charges/ChargesTable.svelte";
|
||||
import DetailsRow, { type DetailsField } from "../DetailsRow.svelte";
|
||||
|
||||
@@ -39,6 +40,11 @@
|
||||
let savingRoles = $state(false);
|
||||
let showError = $state(false);
|
||||
let errorMessage = $state("");
|
||||
let passwordModal = $state(false);
|
||||
let newPassword = $state("");
|
||||
let savingPassword = $state(false);
|
||||
let passwordError = $state("");
|
||||
let passwordSuccess = $state(false);
|
||||
|
||||
$effect(() => {
|
||||
if (user.accounting) {
|
||||
@@ -81,20 +87,20 @@
|
||||
return normalized.startsWith("ROLE_") ? normalized : `ROLE_${normalized}`;
|
||||
}
|
||||
|
||||
const roleOptions = $derived.by(() => {
|
||||
const search = roleSearch.trim().toLowerCase();
|
||||
function searchRoles(query: string): DropdownOption[] {
|
||||
const search = query.toLowerCase();
|
||||
const all = [...new Set([...user.roles, ...selectedRoles.map((o) => o.id)])].map(
|
||||
toRoleOption,
|
||||
);
|
||||
const matches = all.filter((o) => o.id.toLowerCase().includes(search));
|
||||
|
||||
const custom = toRoleId(roleSearch);
|
||||
const custom = toRoleId(query);
|
||||
if (custom && !all.some((o) => o.id === custom)) {
|
||||
matches.push(toRoleOption(custom));
|
||||
}
|
||||
|
||||
return matches;
|
||||
});
|
||||
}
|
||||
|
||||
async function saveRoles() {
|
||||
savingRoles = true;
|
||||
@@ -118,6 +124,48 @@
|
||||
onRolesUpdated?.(user.id, roles);
|
||||
}
|
||||
|
||||
function openPasswordModal() {
|
||||
newPassword = "";
|
||||
passwordError = "";
|
||||
passwordSuccess = false;
|
||||
passwordModal = true;
|
||||
}
|
||||
|
||||
async function savePassword() {
|
||||
passwordError = "";
|
||||
passwordSuccess = false;
|
||||
|
||||
if (!newPassword) {
|
||||
passwordError = $t("common.password.error.required");
|
||||
return;
|
||||
}
|
||||
if (newPassword.length < 8) {
|
||||
passwordError = $t("common.password.error.minLength");
|
||||
return;
|
||||
}
|
||||
|
||||
savingPassword = true;
|
||||
const { error, response } = await apiUsersIdPatch({
|
||||
baseUrl: "/api/relay",
|
||||
path: { id: String(user.id) },
|
||||
body: { password: newPassword },
|
||||
});
|
||||
savingPassword = false;
|
||||
|
||||
if (error) {
|
||||
errorMessage = $t(getErrorTranslationKey(createAuthError(response).type));
|
||||
showError = true;
|
||||
return;
|
||||
}
|
||||
|
||||
passwordSuccess = true;
|
||||
newPassword = "";
|
||||
setTimeout(() => {
|
||||
passwordModal = false;
|
||||
passwordSuccess = false;
|
||||
}, 800);
|
||||
}
|
||||
|
||||
function chargeDateFilterUrl(charge: GatewayCharge): string | undefined {
|
||||
if (!user.accounting || !charge.dateCreated) return;
|
||||
|
||||
@@ -204,6 +252,13 @@
|
||||
>
|
||||
{$t("pages.admin.users.table.rows.details.btns.roles")}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="border-secondary text-secondary cursor-pointer rounded-full border bg-white px-5 py-2 text-sm"
|
||||
onclick={openPasswordModal}
|
||||
>
|
||||
{$t("common.password.change")}
|
||||
</button>
|
||||
</div>
|
||||
{/snippet}
|
||||
</DetailsRow>
|
||||
@@ -225,14 +280,14 @@
|
||||
</button>
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<DropdownMenu
|
||||
<DropdownSearch
|
||||
variant="multiselect"
|
||||
chips
|
||||
hasSearch
|
||||
searchPlaceholder={$t("pages.admin.users.table.rows.details.roles.placeholder")}
|
||||
options={roleOptions}
|
||||
search={searchRoles}
|
||||
debounceMs={0}
|
||||
placeholder={$t("pages.admin.users.table.rows.details.roles.placeholder")}
|
||||
bind:selected={selectedRoles}
|
||||
bind:searchValue={roleSearch}
|
||||
bind:value={roleSearch}
|
||||
/>
|
||||
<div class="flex justify-end">
|
||||
<Button kind="primary" disabled={savingRoles} onclick={saveRoles}>
|
||||
@@ -242,6 +297,39 @@
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
bind:open={passwordModal}
|
||||
title={$t("common.password.change")}
|
||||
dismissable={false}
|
||||
class="relative max-w-lg"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="text-secondary absolute inset-e-4 top-4 cursor-pointer bg-transparent p-1 shadow-none hover:opacity-80 focus:ring-0"
|
||||
onclick={() => (passwordModal = false)}
|
||||
aria-label={$t("common.close")}
|
||||
>
|
||||
<Close width="24" height="24" />
|
||||
</button>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<PasswordInput
|
||||
bind:value={newPassword}
|
||||
labelText={$t("common.password.new")}
|
||||
class="h-14"
|
||||
disabled={savingPassword}
|
||||
/>
|
||||
{#if passwordError}
|
||||
<p class="text-tertiary text-sm">{passwordError}</p>
|
||||
{/if}
|
||||
<div class="flex justify-end">
|
||||
<Button kind="primary" disabled={savingPassword} onclick={savePassword}>
|
||||
{$t("common.password.save")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
bind:open={chargesModal}
|
||||
title={$t("pages.admin.users.table.rows.details.recentCharges")}
|
||||
@@ -284,3 +372,6 @@
|
||||
</Modal>
|
||||
|
||||
<Toast floating variant="error" bind:showToast={showError}>{errorMessage}</Toast>
|
||||
<Toast floating variant="success" bind:showToast={passwordSuccess}>
|
||||
{$t("common.password.success")}
|
||||
</Toast>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import { locale, t } from "../../i18n/store";
|
||||
import { formatAddress } from "../../utils/formatAddress";
|
||||
import { useFormDraft } from "../../utils/forms/useFormDraft.svelte";
|
||||
import AddressForm from "../address/AddressForm.svelte";
|
||||
import Button from "../library/buttons/Button.svelte";
|
||||
import RadioButton from "../library/inputs/RadioButton.svelte";
|
||||
@@ -34,14 +35,33 @@
|
||||
let isSubmitting = $state(false);
|
||||
let addressForm = $state<AddressForm>();
|
||||
|
||||
/**
|
||||
* The address picked before the language was switched. It decides whether the fields of a
|
||||
* new address are shown at all, so it has to come back with them.
|
||||
*/
|
||||
const { restored } = useFormDraft("checkout-address-choice", () => ({ choice }));
|
||||
|
||||
/** Kept out of the state on purpose: it must only be applied once. */
|
||||
let pendingChoice: string | undefined = restored?.choice;
|
||||
|
||||
function takePendingChoice(): string | undefined {
|
||||
const choice = pendingChoice;
|
||||
|
||||
pendingChoice = undefined;
|
||||
|
||||
return choice;
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (!open) return;
|
||||
|
||||
choice = addresses.some((a) => a.id === selected?.id)
|
||||
const seed = addresses.some((a) => a.id === selected?.id)
|
||||
? String(selected!.id)
|
||||
: addresses.length
|
||||
? ""
|
||||
: NEW;
|
||||
|
||||
choice = takePendingChoice() ?? seed;
|
||||
});
|
||||
|
||||
async function save(event: SubmitEvent) {
|
||||
@@ -95,7 +115,7 @@
|
||||
/>
|
||||
|
||||
{#if choice === NEW}
|
||||
<AddressForm bind:this={addressForm} {userIri} />
|
||||
<AddressForm bind:this={addressForm} {userIri} draftId="checkout-address" />
|
||||
{/if}
|
||||
</form>
|
||||
{#snippet footer()}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<div class="grid w-full grid-cols-2 gap-6">
|
||||
<div class="border-grey overflow-hidden rounded-3xl border">
|
||||
<img
|
||||
src={project.video?.thumbnail}
|
||||
src={project.cover || project.video?.thumbnail}
|
||||
alt={project.title}
|
||||
class="h-full w-full object-cover"
|
||||
/>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from "flowbite-svelte";
|
||||
import { untrack } from "svelte";
|
||||
|
||||
import { t } from "../../i18n/store";
|
||||
import { apiProjectSupportsIdPatch, type ProjectSupport } from "../../openapi/client";
|
||||
import { useFormDraft } from "../../utils/forms/useFormDraft.svelte";
|
||||
import Spinner from "../icons/status/Spinner.svelte";
|
||||
import Button from "../library/buttons/Button.svelte";
|
||||
import TextArea from "../library/inputs/TextArea.svelte";
|
||||
@@ -24,6 +26,31 @@
|
||||
let message = $state("");
|
||||
let isSubmitting = $state(false);
|
||||
|
||||
/** Identifies the draft of this comment, so two of them do not write over each other. */
|
||||
function commentDraftId(support: ProjectSupport): string {
|
||||
return `comment-${support.id ?? "new"}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* The comment written before the language was switched. It is not sensitive, so it can
|
||||
* be kept.
|
||||
*/
|
||||
const { restored } = useFormDraft(
|
||||
untrack(() => commentDraftId(support)),
|
||||
() => ({ message }),
|
||||
);
|
||||
|
||||
/** Kept out of the state on purpose: it must only be applied once. */
|
||||
let pendingMessage: string | undefined = restored?.message;
|
||||
|
||||
function takePendingMessage(): string | undefined {
|
||||
const message = pendingMessage;
|
||||
|
||||
pendingMessage = undefined;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
async function handleSubmit(event: SubmitEvent) {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -55,7 +82,7 @@
|
||||
|
||||
$effect(() => {
|
||||
if (open) {
|
||||
message = support?.message ?? "";
|
||||
message = takePendingMessage() ?? support?.message ?? "";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -63,7 +90,7 @@
|
||||
<Modal
|
||||
bind:open
|
||||
title={$t("pages.checkout.verify.approved.formReview.commentModal.title")}
|
||||
closeBtnClass="top-7 end-7 bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
closeBtnClass="top-10 end-12 p-1.5 [&_svg]:size-7 bg-transparent text-secondary hover:bg-transparent hover:text-secondary hover:scale-110 transition-transform duration-200 transform focus:ring-0 shadow-none dark:text-secondary dark:hover:text-secondary dark:hover:bg-transparent"
|
||||
class="backdrop:bg-overlay fixed top-1/2 left-1/2 w-full max-w-225 -translate-x-1/2 -translate-y-1/2 rounded-3xl bg-white p-6 shadow-lg backdrop:backdrop-blur-[5px]"
|
||||
headerClass="self-start md:px-0 p-0 text-2xl font-bold text-content text-ellipsis border-none"
|
||||
bodyClass="p-0 md:p-0 md:pt-1 border-none"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { type Project, type ProjectSupport } from "../../openapi/client";
|
||||
import { client } from "../../openapi/client/client.gen";
|
||||
import { apiProjectsIdOrSlugGetUrl } from "../../openapi/client/operation-paths.gen";
|
||||
import { useFormDraft } from "../../utils/forms/useFormDraft.svelte";
|
||||
import RadioButton from "../library/inputs/RadioButton.svelte";
|
||||
import Title from "../library/typography/Title.svelte";
|
||||
|
||||
@@ -17,6 +18,12 @@
|
||||
|
||||
let type = $state<"organization" | "individual">("organization");
|
||||
|
||||
const { restored } = useFormDraft("checkout-feedback", () => ({ type }));
|
||||
|
||||
if (restored) {
|
||||
type = restored.type === "individual" ? "individual" : "organization";
|
||||
}
|
||||
|
||||
let feedbackItems = $derived(() =>
|
||||
projects.map((project) => {
|
||||
const iri = client.buildUrl({
|
||||
@@ -24,7 +31,7 @@
|
||||
path: { idOrSlug: project.id },
|
||||
});
|
||||
|
||||
const support = projectSupports.find((ps) => ps.project === iri)!;
|
||||
const support = projectSupports.find((ps) => iri.endsWith(ps.project!))!;
|
||||
|
||||
return { project, support };
|
||||
}),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { navigate } from "astro:transitions/client";
|
||||
|
||||
import { t } from "../../i18n/store";
|
||||
import { useFormDraft } from "../../utils/forms/useFormDraft.svelte";
|
||||
import Toast from "../library/feedback/Toast.svelte";
|
||||
import Checkbox from "../library/inputs/Checkbox.svelte";
|
||||
import PasswordInput from "../library/inputs/PasswordInput.svelte";
|
||||
@@ -16,6 +17,20 @@
|
||||
let errorMessage = $state("");
|
||||
let showErrorToast = $state(false);
|
||||
|
||||
/**
|
||||
* The identifier and the terms are worth keeping across a language switch; the password
|
||||
* is not, so it is never handed over to the storage.
|
||||
*/
|
||||
const { restored } = useFormDraft("checkout-login", () => ({
|
||||
identifier,
|
||||
acceptTerms,
|
||||
}));
|
||||
|
||||
if (restored) {
|
||||
identifier = restored.identifier ?? "";
|
||||
acceptTerms = restored.acceptTerms ?? false;
|
||||
}
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ const defaultGateway =
|
||||
required
|
||||
disabled={gateway.id === "wallet"}
|
||||
checked={gateway.id === defaultGateway}
|
||||
class="after:bg-primary border-secondary checked:border-secondary checked:bg-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:content-[''] checked:after:block"
|
||||
class="border-secondary checked:border-secondary checked:bg-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-white after:content-[''] checked:after:block"
|
||||
/>
|
||||
<div class="flex flex-col leading-tight">
|
||||
<span class="font-semibold">{gateway.name}</span>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import { locale, t } from "../../i18n/store";
|
||||
import { getDefaultCountry } from "../../utils/consts";
|
||||
import { useFormDraft, restoreFields } from "../../utils/forms/useFormDraft.svelte";
|
||||
import { getValidationParams } from "../../utils/validation";
|
||||
import { zRegisterForm } from "../../validation/registerValidation";
|
||||
import Spinner from "../icons/status/Spinner.svelte";
|
||||
@@ -88,6 +89,36 @@
|
||||
let formError = $state("");
|
||||
let showFormToast = $state(false);
|
||||
|
||||
/**
|
||||
* The fields worth keeping across a language switch. The password and the tax id are
|
||||
* left out on purpose: they are sensitive, and the visitor can type them again.
|
||||
*/
|
||||
const { restored } = useFormDraft("checkout-register", () => ({
|
||||
type: form.type,
|
||||
identifier: form.identifier,
|
||||
firstname: form.firstname,
|
||||
lastname: form.lastname,
|
||||
legalName: form.legalName,
|
||||
taxIdCountry: form.taxIdCountry,
|
||||
showTaxIdField,
|
||||
acceptTerms,
|
||||
}));
|
||||
|
||||
if (restored) {
|
||||
form.type = restored.type === "organization" ? "organization" : "individual";
|
||||
|
||||
restoreFields(form, restored, [
|
||||
"identifier",
|
||||
"firstname",
|
||||
"lastname",
|
||||
"legalName",
|
||||
"taxIdCountry",
|
||||
]);
|
||||
|
||||
showTaxIdField = restored.showTaxIdField ?? false;
|
||||
acceptTerms = restored.acceptTerms ?? false;
|
||||
}
|
||||
|
||||
function validate(field: FieldName) {
|
||||
// taxId validity depends on country and type, so it is checked by the schema refinement
|
||||
if (field === "taxId") {
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Same track as the dots, so each label sits under its own dot -->
|
||||
<div class="mt-4 flex w-full items-start justify-between px-2 text-sm font-bold text-gray-700">
|
||||
<div class="text-content mt-4 flex w-full items-start justify-between px-2 text-sm font-bold">
|
||||
{#each stepsLabels as label, index}
|
||||
<div
|
||||
class="group flex w-2 shrink-0 justify-center first:justify-start last:justify-end lg:w-3"
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<div class="flex w-auto flex-col gap-4">
|
||||
<div class="flex flex-col gap-2">
|
||||
<Title level={2} variant="subsection">
|
||||
{$t("pages.checkout.tipjar.community")}
|
||||
{$t("I want to support the Democratich Tech Fund")}
|
||||
</Title>
|
||||
|
||||
<CurrencyInput
|
||||
@@ -97,10 +97,8 @@
|
||||
<Checkbox
|
||||
id="donation-checkbox"
|
||||
bind:checked={isChecked}
|
||||
onchange={toggleTip}
|
||||
class="gap-2"
|
||||
>
|
||||
<span class="text-secondary">{$t("pages.checkout.tipjar.checkboxLabel")}</span>
|
||||
</Checkbox>
|
||||
onchange={() => toggleTip()}
|
||||
label={$t("pages.checkout.tipjar.checkboxLabel")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
|
||||
<div class="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||
<div class="text-center sm:text-left">
|
||||
<span class="block text-sm text-gray-600">{$t("pages.checkout.wallet.currentBalance")}</span
|
||||
<span class="text-content/70 block text-sm"
|
||||
>{$t("pages.checkout.wallet.currentBalance")}</span
|
||||
>
|
||||
<p class="text-secondary text-double font-bold">
|
||||
{formatCurrency(accounting.balance)}
|
||||
@@ -18,7 +19,9 @@
|
||||
</div>
|
||||
|
||||
<div class="text-center sm:text-left">
|
||||
<span class="block text-sm text-gray-600">{$t("pages.checkout.wallet.amountToUse")} </span>
|
||||
<span class="text-content/70 block text-sm"
|
||||
>{$t("pages.checkout.wallet.amountToUse")}
|
||||
</span>
|
||||
<p id="cart-total" class="text-double font-bold text-red-500">
|
||||
{#if $checkoutHydrated}
|
||||
{formatCurrency($total)}
|
||||
@@ -29,7 +32,7 @@
|
||||
</div>
|
||||
|
||||
<div class="text-center sm:text-left">
|
||||
<span class="block text-sm text-gray-600"
|
||||
<span class="text-content/70 block text-sm"
|
||||
>{$t("pages.checkout.wallet.remainingBalance")}
|
||||
</span>
|
||||
<p id="cart-difference" class="text-secondary text-double font-bold">
|
||||
|
||||