From 81eec76f68228fb690c9fdd771790592e07c18fc Mon Sep 17 00:00:00 2001 From: Lorenz Sieben Date: Mon, 14 Oct 2024 18:02:53 +0200 Subject: [PATCH 1/4] Allow going back from the second analasis --- .../p/[token]/evaluate-response/[response].ts | 54 ++++++++++++------- .../p/[token]/evaluate-response/index.astro | 2 +- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/pages/p/[token]/evaluate-response/[response].ts b/src/pages/p/[token]/evaluate-response/[response].ts index 5510ccb..d4272cf 100644 --- a/src/pages/p/[token]/evaluate-response/[response].ts +++ b/src/pages/p/[token]/evaluate-response/[response].ts @@ -29,29 +29,47 @@ export const POST: APIRoute = async ({ params, redirect }) => { .run(client); if (!proceeding) return new Response('Invalid token.', { status: 403 }); - if (!['awaitingControllerResponse'].includes(proceeding.state) || !proceeding.noticeSent) - return new Response('You cannot evaluate the response to this proceeding now.', { status: 400 }); + if (!proceeding.noticeSent) + return new Response('You cannot evaluate the response to this proceeding now.', { status: 400 }); // Arguably, we might fail more gracefully if we redirect to /p/ here - if (response === 'none' && new Date() < calculateDeadline(proceeding.noticeSent)) - return new Response('Give the developer until the end of the deadline to respond.', { status: 400 }); + if (proceeding.state === 'awaitingControllerResponse') { + if (response === 'none' && new Date() < calculateDeadline(proceeding.noticeSent)) + return new Response('Give the developer until the end of the deadline to respond.', { status: 400 }); - const { token: analysisToken } = await startAnalysis(proceeding.app.platform, proceeding.app.appId); + const { token: analysisToken } = await startAnalysis(proceeding.app.platform, proceeding.app.appId); - await e - .update(e.Proceeding, () => ({ - // eslint-disable-next-line camelcase - filter_single: { token }, + // TODO: Fail if starting analysis fails - set: { - controllerResponse: response, + await e + .update(e.Proceeding, () => ({ + // eslint-disable-next-line camelcase + filter_single: { token }, - requestedAnalysis: e.insert(e.RequestedAnalysis, { - type: 'second', - token: analysisToken, - }), - }, - })) - .run(client); + set: { + controllerResponse: response, + + requestedAnalysis: e.insert(e.RequestedAnalysis, { + type: 'second', + token: analysisToken, + }), + }, + })) + .run(client); + } else if (proceeding.state === 'needsSecondAnalysis') { + if (response === 'none' && new Date() < calculateDeadline(proceeding.noticeSent)) + return new Response('Give the developer until the end of the deadline to respond.', { status: 400 }); + + await e + .update(e.Proceeding, () => ({ + // eslint-disable-next-line camelcase + filter_single: { token }, + + set: { + controllerResponse: response, + }, + })) + .run(client); + } else return new Response('You cannot evaluate the response to this proceeding now.', { status: 400 }); // Arguably, we might fails more gracefully if we redirect to /p/ here return redirect(`/p/${token}`); }; diff --git a/src/pages/p/[token]/evaluate-response/index.astro b/src/pages/p/[token]/evaluate-response/index.astro index 238241a..f085f1e 100644 --- a/src/pages/p/[token]/evaluate-response/index.astro +++ b/src/pages/p/[token]/evaluate-response/index.astro @@ -19,7 +19,7 @@ const proceeding = await e .assert_single() .run(client); -if (proceeding?.state !== 'awaitingControllerResponse' || !proceeding.noticeSent) +if (!proceeding?.noticeSent || ['awaitingControllerResponse', 'needsSecondAnalysis'].includes(proceeding.state)) return new Response('You cannot evaluate the response to this proceeding now.', { status: 400 }); const deadline = calculateDeadline(proceeding.noticeSent); From aa5c97db089d832128ea67d923ffdef49bc5a842 Mon Sep 17 00:00:00 2001 From: Lorenz Sieben Date: Wed, 16 Oct 2024 17:49:36 +0200 Subject: [PATCH 2/4] Activate preact devtools --- astro.config.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/astro.config.mjs b/astro.config.mjs index dd1975e..d329c51 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -10,7 +10,8 @@ export default defineConfig({ adapter: node({ mode: 'standalone', }), - integrations: [preact(), global()], + // eslint-disable-next-line no-undef + integrations: [preact({ devtools: process.env.NODE_ENV === 'development' }), global()], i18n: { defaultLocale: 'en', locales: ['en'], From c42ffb000428277b5efde95693eea484da7096ad Mon Sep 17 00:00:00 2001 From: Lorenz Sieben Date: Wed, 16 Oct 2024 21:19:50 +0200 Subject: [PATCH 3/4] Make pages more navigable and accessible --- .../ComplaintLandingPage/AskAuthority.astro | 27 ++-- .../AskComplaintType.astro | 30 ++-- .../AskDeveloperAddress.astro | 2 +- .../AskDeviceHasRegisteredSimCard.astro | 33 ++--- .../ComplaintLandingPage/AskIsUserOfApp.astro | 32 +++-- .../AskLoggedIntoAppStore.astro | 33 ++--- .../AskUserNetworkActivity.astro | 5 +- src/components/RadioForm.astro | 53 +++++++ src/i18n/en.json | 3 +- src/pages/p/[token]/complain/[question].ts | 126 ---------------- .../p/[token]/complain/[question]/answer.ts | 136 ++++++++++++++++++ .../p/[token]/complain/[question]/index.astro | 88 ++++++++++++ src/pages/p/[token]/complain/index.astro | 39 +---- .../p/[token]/evaluate-response/index.astro | 2 +- src/styles/main.scss | 32 +++++ 15 files changed, 392 insertions(+), 249 deletions(-) create mode 100644 src/components/RadioForm.astro delete mode 100644 src/pages/p/[token]/complain/[question].ts create mode 100644 src/pages/p/[token]/complain/[question]/answer.ts create mode 100644 src/pages/p/[token]/complain/[question]/index.astro diff --git a/src/components/ComplaintLandingPage/AskAuthority.astro b/src/components/ComplaintLandingPage/AskAuthority.astro index 95ba8bf..b792a33 100644 --- a/src/components/ComplaintLandingPage/AskAuthority.astro +++ b/src/components/ComplaintLandingPage/AskAuthority.astro @@ -4,12 +4,14 @@ import Base from '../../layouts/base.astro'; import { absUrl } from '../../lib/util'; import TextRaw from '../TextRaw.astro'; import { dpas } from '../../lib/dpas'; +import RadioForm from '../RadioForm.astro'; interface Props { token: string; + complaintAuthority: string | null; } -const { token } = Astro.props; +const { token, complaintAuthority } = Astro.props; --- @@ -17,18 +19,13 @@ const { token } = Astro.props;

-
-
- { - Object.values(dpas).map((d) => ( -
- - -
- )) - } -
-
+ , key: string) => { + agg[key] = dpas[key]!.name; + return agg; + }, {})} + value={complaintAuthority} + idPrefix="askAuthority" + /> diff --git a/src/components/ComplaintLandingPage/AskComplaintType.astro b/src/components/ComplaintLandingPage/AskComplaintType.astro index b53a36f..6ded906 100644 --- a/src/components/ComplaintLandingPage/AskComplaintType.astro +++ b/src/components/ComplaintLandingPage/AskComplaintType.astro @@ -3,12 +3,14 @@ import { t } from '../../i18n/server'; import Base from '../../layouts/base.astro'; import { absUrl } from '../../lib/util'; import TextRaw from '../TextRaw.astro'; +import RadioForm from '../RadioForm.astro'; interface Props { token: string; + complaintType: string | null | undefined; } -const { token } = Astro.props; +const { token, complaintType } = Astro.props; --- @@ -21,18 +23,16 @@ const { token } = Astro.props;
  • {t('complaint-landing-askComplaintType', 'informal-complaint-explanation')}
  • -
    -
    - { - (['formal', 'informal'] as const).map((type) => ( -
    - - -
    - )) - } -
    -
    + + Object.assign(agg, { + [type]: t('complaint-landing-askComplaintType', `${type}-complaint-button`), + }), + {}, + )} + value={complaintType} + idPrefix="askComplaintType" + /> diff --git a/src/components/ComplaintLandingPage/AskDeveloperAddress.astro b/src/components/ComplaintLandingPage/AskDeveloperAddress.astro index 952e473..2b46045 100644 --- a/src/components/ComplaintLandingPage/AskDeveloperAddress.astro +++ b/src/components/ComplaintLandingPage/AskDeveloperAddress.astro @@ -29,7 +29,7 @@ const { token, developerName, privacyPolicyUrl } = Astro.props;

    -
    +