Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2025-01-09 #135

Merged
merged 67 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
f09dbe2
Workflow: Remove diffing, rename workflow&steps
tordans Dec 12, 2024
8534787
Workflow: Remove progress bar
tordans Dec 12, 2024
b36be5a
Workflow: Reenable diffing for build&deploy
tordans Dec 12, 2024
85e569e
Workflow: Rename AWS steps
tordans Dec 12, 2024
9387b35
Env: Update types and docs
tordans Dec 12, 2024
2c48da6
Docker: Rename container and volumen
tordans Dec 12, 2024
9165c38
Pull DB: Update after server migration
tordans Dec 12, 2024
3b39ffe
Pull DB: Move seeding to script
tordans Dec 12, 2024
0bcb486
Env: Provide empty env keys
tordans Dec 12, 2024
90b4ae2
Husky: Dont check tests on push
tordans Dec 12, 2024
ae0e6a0
Survey: add form validation
JohannaPeanut Dec 12, 2024
21e6276
Survey: update validation config for BB
JohannaPeanut Dec 16, 2024
7a75bff
Survey: update marker for optional fields
JohannaPeanut Dec 16, 2024
6ca95c4
Survey: update types
JohannaPeanut Dec 16, 2024
58df161
Survey: remove outdated notice for required fields
JohannaPeanut Dec 16, 2024
52e71d2
Survey: remove maxLength on text input, reintroduce on textarea
JohannaPeanut Dec 16, 2024
0e61a4b
Survey: update wording
JohannaPeanut Dec 17, 2024
e14a707
Env: Improve docs
tordans Dec 12, 2024
2a2776e
Readme: Fix typos
tordans Dec 12, 2024
8a842d9
Docker: Use postgres 16 locally as well
tordans Dec 17, 2024
4a2c43d
Revert "Docker: Use postgres 16 locally as well"
tordans Dec 17, 2024
c010150
DB: Pin postgres 16 in docker command
tordans Dec 17, 2024
3b48c7a
DB: Disable user seeding for testing data
tordans Dec 17, 2024
b5f1414
use named clsx import for
JohannaPeanut Dec 16, 2024
e49668d
Survey: update required message for custom
JohannaPeanut Dec 16, 2024
9a7b8b7
Survey: update watchIsMap, add comment
JohannaPeanut Dec 16, 2024
00ea837
Survey: add detailed comments to createSurveySchema function for bett…
JohannaPeanut Dec 17, 2024
7ab0f5a
Survey: add aria-describedby for map, custom, checkbox, radio
JohannaPeanut Dec 17, 2024
c007748
Survey: disable submit buttons if form is submitting
JohannaPeanut Dec 17, 2024
2f99b0d
Survey: Use Props type directly instead of React.FC<Props>
JohannaPeanut Dec 17, 2024
1c14ce1
Survey: add comment in types
JohannaPeanut Dec 18, 2024
3370181
Survey: add clean up comment
JohannaPeanut Dec 18, 2024
58ce814
Survey: rename and rework getFormfieldNames, add desc comment
JohannaPeanut Dec 17, 2024
dfde67d
Merge branch 'develop' into Survey-form-validation
JohannaPeanut Dec 23, 2024
1e495be
Delete SurveyStaticMap.tsx
JohannaPeanut Dec 23, 2024
a87c92b
Enhance survey form validation (#136)
JohannaPeanut Dec 23, 2024
00dbfae
Survey: rename evaluationRefs
JohannaPeanut Dec 18, 2024
2bd51e3
Survey: introduce geometry category in furture surveys, export coordi…
JohannaPeanut Dec 19, 2024
d5c8c7e
Survey: make type polygon possible as geometry category
JohannaPeanut Dec 23, 2024
42fbbb7
SurveyResponse: location lat lng in separate columns in csv
JohannaPeanut Dec 23, 2024
6b2f00b
Survey: update marker for optional fields in feedback part
JohannaPeanut Dec 23, 2024
d834a25
SurveyResponse: show geometry category in list map
JohannaPeanut Dec 23, 2024
b7c51a8
SurveyResponse: Update survey.ts rs8 to test polygon
JohannaPeanut Dec 23, 2024
88a7c09
SurveyResponse: fix csv export
JohannaPeanut Dec 30, 2024
304793a
SurveyResponse: fix wkt helper
JohannaPeanut Dec 30, 2024
4d7f648
Survey: fix appearance of error box
JohannaPeanut Dec 30, 2024
f15f737
Survey: fix validation; include all fields
JohannaPeanut Dec 30, 2024
1e4c8f4
clean up
JohannaPeanut Dec 30, 2024
8f02ec6
SurveyResponse: rename var
JohannaPeanut Dec 30, 2024
b860d09
SurveyResponse: remove subsections prop
JohannaPeanut Dec 30, 2024
7e80b52
SurveyResponse: show list of selected responses in map view
JohannaPeanut Dec 30, 2024
8536072
SurveyResponse: show all survey responses in overview map
JohannaPeanut Jan 2, 2025
3f951c9
SurveyResponse: update and extract mapSelection and responseSelection…
JohannaPeanut Jan 8, 2025
c7cfd99
SurvyResponse: fix or ignore type errors
JohannaPeanut Jan 8, 2025
67e6aac
SurveyResponse: make layer ids kebab-case
JohannaPeanut Jan 8, 2025
d6e65b7
add clean up comments
JohannaPeanut Jan 8, 2025
6e67dfd
Survey: fix rs8 bounds
JohannaPeanut Jan 8, 2025
41f3b4e
SurveyResponse: update bg color of user text
JohannaPeanut Jan 8, 2025
a96882c
SurveyResponse: fix number of cols in map view
JohannaPeanut Jan 8, 2025
216b11e
SurveyResponse: fix user text preview width
JohannaPeanut Jan 8, 2025
dd39a98
Use Props type directly instead of React.FC<Props> and clean up
JohannaPeanut Jan 9, 2025
3c81535
SurveyResponse: update link to overview map
JohannaPeanut Jan 9, 2025
93326d3
SurveyResponse: update line style in list map
JohannaPeanut Jan 9, 2025
ca02070
SurveResponse: update wording and order in csv download
JohannaPeanut Jan 9, 2025
112bab8
SurveyResponse: update maxzoom in overview map
JohannaPeanut Jan 9, 2025
cbc4158
Survey: update geometryFallback for rs8 and frm7
JohannaPeanut Jan 9, 2025
0f9ef9b
SurveyResponse: add headline for list, add information in item button
JohannaPeanut Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
# Update `/src/env.d.ts` whenever this file is changed.

# See `./docker-compose.yml`
DATABASE_URL=postgresql://postgres:password@localhost:6001/postgres
DATABASE_URL=postgresql://postgres:password@localhost:6001/dbmaster

# For `npm run db:getDump && npm run db:restoreDump`
# https://lightsail.aws.amazon.com/ls/webapp/eu-central-1/databases/trassenscout-db-production/connect
DATABASE_URL_PRODUCTION=postgresql://USER:PSWD@URL:PORT/dbmaster
# But first run `ssh trassenscout-production-postgres-tunnel` in a separate terminal
DATABASE_URL_PRODUCTION=postgresql://USER:PSWD@host.docker.internal:PORT/dbmaster
# For `npm run db:getDump:staging && npm run db:restoreDump`
# https://lightsail.aws.amazon.com/ls/webapp/eu-central-1/databases/trassenscout-db-staging/connect
DATABASE_URL_STAGING=postgresql://USER:PSWD@URL:PORT/dbmaster
# But first run `ssh trassenscout-staging-postgres-tunnel` in a separate terminal
DATABASE_URL_STAGING=postgresql://USER:PSWD@host.docker.internal:PORT/dbmaster

S3_UPLOAD_ROOTFOLDER=upload-localdev

Expand All @@ -32,11 +32,13 @@ ADMIN_EMAIL=hello@trassenscout.de
# Key for restricted api routes
TS_API_KEY=ok

# MAILJET_APIKEY_PUBLIC='' # Only on the server
# MAILJET_APIKEY_PRIVATE='' # Only on the server
MAILJET_APIKEY_PUBLIC='' # Only on the server
MAILJET_APIKEY_PRIVATE='' # Only on the server

SESSION_SECRET_KEY=secret

NEXT_PUBLIC_APP_ENV=development # 'staging', 'production'
# NEXT_PUBLIC_APP_ORIGIN=http://127.0.0.1:5000 # 'https://staging,trassenscout.de', 'https://trassenscout.de'
# NEXT_PUBLIC_APP_ORIGIN=http://127.0.0.1:5000 # 5000 for `npm run start` 'https://staging,trassenscout.de', 'https://trassenscout.de'

# for development: test the survey starting with another state
NEXT_PUBLIC_PUBLIC_SURVEY_START_STAGE=START
9 changes: 5 additions & 4 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# How we work with environment variables and secrets

## In Worflow
## In Workflow

- All environment variables and secrets are defined in Github:
- All environment variables and secrets are defined in GitHub:
- Either on repo level:
- [Repository secrets](https://github.com/FixMyBerlin/trassenscout/settings/secrets/actions)
- (We don't use [repository variables](https://github.com/FixMyBerlin/trassenscout/settings/variables/actions) to keep things simpler.)
- Or on Environment level
- [Staging](https://github.com/FixMyBerlin/trassenscout/settings/environments/2395297920/edit#environment-secrets)
- [Production](https://github.com/FixMyBerlin/trassenscout/settings/environments/2395358496/edit#environment-secrets)
- Some variables are dynamically created when feasable to reduce the number of variables in Github
- Some variables are dynamically created when feasible to reduce the number of variables in GitHub
- Consider adding things that don't change to the code instead of the environment variables/secrets

## In Docker compose
Expand All @@ -33,6 +33,7 @@
| `POSTGRES_PASSWORD` | `secrets.POSTGRES_PASSWORD` | |
| `POSTGRES_DB` | `vars.POSTGRES_DB` | |
| `POSTGRES_HOST` | `vars.POSTGRES_HOST` | |
| `DATABASE_URL` | `.env`-variable | In `.env` as composite value |
| | | |
| `SESSION_SECRET_KEY` | `secrets.SESSION_SECRET_KEY` | [Required by Blitz][session-secret-key] |
| | | |
Expand All @@ -42,7 +43,7 @@
| | | |
| `S3_UPLOAD_KEY` | `secrets.S3_UPLOAD_KEY` | |
| `S3_UPLOAD_SECRET` | `secrets.S3_UPLOAD_SECRET` | |
| `S3_UPLOAD_ROOTFOLDER` | `.env`-variable | In `.env` as composit value |
| `S3_UPLOAD_ROOTFOLDER` | `.env`-variable | In `.env` as composite value |
| | | |
| `TS_API_KEY` | `secrets.TS_API_KEY` | |
| | | |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-app-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
with:
ENVIRONMENT: production

restart-services:
services:
needs: deploy-app
uses: ./.github/workflows/restart-services.yml
uses: ./.github/workflows/services.yml
secrets: inherit
with:
ENVIRONMENT: production
4 changes: 2 additions & 2 deletions .github/workflows/deploy-app-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
with:
ENVIRONMENT: staging

restart-services:
services:
needs: deploy-app
uses: ./.github/workflows/restart-services.yml
uses: ./.github/workflows/services.yml
secrets: inherit
with:
ENVIRONMENT: staging
18 changes: 9 additions & 9 deletions .github/workflows/deploy-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ on:
type: string

jobs:
# diff_app:
# uses: ./.github/workflows/diff-last-run.yml
# with:
# CHECK_DIFF_LOCATIONS: src/ db/ public/ emails/ docker/
diff_app:
uses: ./.github/workflows/diff-last-run.yml
with:
CHECK_DIFF_LOCATIONS: src/ db/ public/ emails/ docker/

build_app:
runs-on: ubuntu-latest
# needs: diff_app
# if: ${{ needs.diff_app.outputs.changes == 'true' }}
needs: diff_app
if: ${{ needs.diff_app.outputs.changes == 'true' }}
environment:
name: ${{ inputs.ENVIRONMENT }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Upgrade AWS CLI version and setup lightsailctl
- name: "AWS: Install CLI"
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
curl --fail -s -S "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update

- name: Configure AWS credentials
- name: "AWS: Configure credentials"
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/diff-last-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- name: Get last run commit SHA
run: |
LAST_RUN_SHA=$(curl --request GET \
LAST_RUN_SHA=$(curl --fail -s -S --request GET \
--url https://api.github.com/repos/${{ github.repository }}/actions/runs?branch=${{ github.head_ref || github.ref_name }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
| jq -r '.workflow_runs[] | select(.conclusion == "success") | .head_sha' | head -1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Restart Services
name: Services

on:
workflow_call:
Expand All @@ -8,21 +8,14 @@ on:
type: string

jobs:
# diff_docker:
# uses: ./.github/workflows/diff-last-run.yml
# with:
# CHECK_DIFF_LOCATIONS: docker-compose*

restart_services:
pull_restart:
runs-on: ubuntu-latest
# needs: diff_docker
# if: ${{ needs.diff_docker.outputs.changes == 'true' }}
environment:
name: ${{ inputs.ENVIRONMENT }}
# `url` adds adds link to the Github UI
url: ${{ vars.APP_ORIGIN }}
steps:
- name: Stop & Start containers
- name: Pull, Restart, Cleanup
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
Expand Down
3 changes: 2 additions & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
npm run type-check
npm run lint
npm run format
npm run test

# npm run test # disabled so we can push without the db running
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

## Architecture

This project is build with [BlitzJS](https://blitzjs.com/) a toolkit build upon [ReactJS](https://reactjs.org/). Data is stored in a PostgreSQL database using Docker.
This project is build with [Blitz](https://blitzjs.com/) a toolkit build upon [React](https://reactjs.org/). Data is stored in a PostgreSQL database using Docker.

## Development

For starting developing, the following steps could be helpful for getting started:

- Use or nvm to install Node.js: `nvm use`
- Install dependenices: `npm install`
- Install dependencies: `npm install`
- Start develop environment: `npm run dev` (start docker, start blitz)
- Run all checks: `npm run check` (check migrations, check typescript run linter, run prettier, run tests)
- Use `npm run build && npx serve dist` to test the build
Expand All @@ -30,10 +30,9 @@ There is a `.env.local` and a `.env.production` file, which provide the keys to
- Blitz provides the basic file structure and conventions [(Docs)](https://blitzjs.com/docs/file-structure)
- BLitz provides the [Blitz CLI (Docs)](https://blitzjs.com/docs/cli-overview), especially the [generators (Docs)](https://blitzjs.com/docs/cli-generate)
- Blitz handles Authentication with [Blitz Auth (Docs)](https://blitzjs.com/docs/auth)
- Blitz handels the communication between server and client with [Blitz RPC (Docs)](https://blitzjs.com/docs/rpc-overview)
- Blitz enhances NextJS with [type save routes (Docs)](https://blitzjs.com/docs/cli-routes)
- Everything else is part of Next JS and documented in [the Next JS Docs](https://nextjs.org/docs/getting-started).
> **Note** This project usees Next 12 (for now).
- Blitz handles the communication between server and client with [Blitz RPC (Docs)](https://blitzjs.com/docs/rpc-overview)
- Blitz enhances Next with [type save routes (Docs)](https://blitzjs.com/docs/cli-routes)
- Everything else is part of Next and documented in [the Next Docs](https://nextjs.org/docs/getting-started).

## Getting Started

Expand Down Expand Up @@ -101,8 +100,8 @@ Follow this steps to add a model with forms and pages:
1. Schema:

- Follow the steps in `src/core/templates/page/__modelIdParam__/edit.tsx` to create a shared [Zod schema (Docs)](https://zod.dev/) and add it to the form for client side validations.
- Update the zod schema to match the Prisma schema.
- You can use `type UserType = z.infer<typeof UserSchema>` to create a TS schema from zod that can be compared to the prima schema (which are located in `node_modules/.prisma/client/index.d.ts`)
- Update the Zod schema to match the Prisma schema.
- You can use `type UserType = z.infer<typeof UserSchema>` to create a TS schema from Zod that can be compared to the prisma schema (which are located in `node_modules/.prisma/client/index.d.ts`)
- You can use https://github.com/CarterGrimmeisen/zod-prisma to generate a starting point for this based on the prisma schema. However, this package should only be used in a separate branch since it collides with blitz in some way.

1. Add seed data in [db/seeds.ts](./db/seeds.ts) – all models should have good seed data.
17 changes: 12 additions & 5 deletions db/remote/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# About

Helper script to pull the production database for local development. Handles anonmization.
Helper script to pull the production database for local development. Handles data anonymization.

# Steps
## Initial Setup

1. Add `DATABASE_URL_PRODUCTION` to [`.env.local`](../../.env.local)
2. `npm run db:getDump`
3. `npm run db:restoreDump`
1. Configure [`.env.local`](../../.env.local) based on [`.env.local.example`](../../.env.local.example)
2. Setup SSH tunnels for production and staging

## Run

```sh
ssh trassenscout-… # tunnel name production or staging – run in separate terminal
npm run db:getDump # or npm run db:getDump:staging
npm run db:restoreDump
```
8 changes: 5 additions & 3 deletions db/remote/get-dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ while getopts 'sh' OPTION; do
esac
done

. ./.env
. ./.env.local
if [ $USE_STAGING ]; then
if ! [ -v DATABASE_URL_STAGING ]; then
Expand All @@ -33,6 +32,9 @@ else
fi

DIR=$( cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P )
alias pg_dump="docker run -it --rm --entrypoint pg_dump postgres"
pg_dump $DATABASE_URL | grep -vE 'rdsadmin;|dbmasteruser;' > $DIR/data/dump.sql

docker run -it --rm --entrypoint pg_dump postgres:16-alpine $DATABASE_URL | grep -vE 'rdsadmin;|dbmasteruser;' > $DIR/data/dump.sql

# Show first 5 lines
head -n 5 $DIR/data/dump.sql
ls -l $DIR/data/dump.sql
11 changes: 7 additions & 4 deletions db/remote/restore-dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ set -e
DIR=$( cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P )
ls $DIR/data/dump.sql > /dev/null

alias psql="docker exec -i rsv-builder-db psql -U postgres"
psql template1 < $DIR/sql/pre-restore.sql
psql postgres < $DIR/data/dump.sql
psql postgres < $DIR/sql/post-restore.sql
docker exec -i ts-db psql -U postgres template1 < $DIR/sql/pre-restore.sql
docker exec -i ts-db psql -U postgres dbmaster < $DIR/data/dump.sql
docker exec -i ts-db psql -U postgres dbmaster < $DIR/sql/post-restore.sql

blitz prisma migrate deploy

# TODO: It looks like this is broken. Need to do a clean test later(TM)…
# SEED_USER_ONLY=1 blitz db seed
6 changes: 3 additions & 3 deletions db/remote/sql/pre-restore.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT pg_terminate_backend (pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'postgres';
DROP DATABASE postgres;
CREATE DATABASE postgres;
WHERE pg_stat_activity.datname = 'dbmaster';
DROP DATABASE dbmaster;
CREATE DATABASE dbmaster;
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ services:
ports:
- "6001:5432"
volumes:
- rsv-data:/var/lib/postgresql/data
container_name: rsv-builder-db
- ts-data:/var/lib/postgresql/data
container_name: ts-db
command: ["postgres", "-clog_destination=stderr", "-clog_statement=all"]
volumes:
rsv-data:
ts-data:
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"start": "npm run predev:check_docker && blitz start --hostname 127.0.0.1 --port 5000",
"dev": "blitz dev --hostname 127.0.0.1 --port 6173",
"predev": "npm run codegen && npm run predev:check_docker",
"predev:check_docker": "if [[ $(docker inspect -f '{{.State.Running}}' rsv-builder-db) = \"true\" ]]; then echo Docker: Skipping – Container already running; else docker compose up --detach; fi",
"predev:check_docker": "if [[ $(docker inspect -f '{{.State.Running}}' ts-db) = \"true\" ]]; then echo Docker: Skipping – Container already running; else docker compose up --detach; fi",
"codegen": "blitz codegen",
"postdev": "docker compose stop",
"debug": "DEBUG=blitz:* blitz console",
Expand All @@ -25,7 +25,7 @@
"migrate:compare": "git diff origin/main... -- db/migrations",
"db:getDump": "db/remote/get-dump.sh",
"db:getDump:staging": "USE_STAGING=1 db/remote/get-dump.sh",
"db:restoreDump": "npm run predev && db/remote/restore-dump.sh && SEED_USER_ONLY=1 blitz db seed",
"db:restoreDump": "npm run predev && db/remote/restore-dump.sh",
"check": "npm run migrate:check && npm run type-check && npm run lint && npm run format && npm run test",
"type-check": "tsc --noEmit",
"lint": "eslint --fix --ignore-pattern \"src/core/templates/*\" --ignore-path .gitignore --ext .js,.ts,.tsx .",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { blueButtonStyles } from "@/src/core/components/links"
import { AllowedSurveySlugs } from "@/src/survey-public/utils/allowedSurveySlugs"
import deleteTestSurveyResponses from "@/src/survey-responses/mutations/deleteTestSurveyResponses"
import { useMutation } from "@blitzjs/rpc"
import clsx from "clsx"
import { clsx } from "clsx"
import { useRouter } from "next/navigation"

type DeleteButtonProps = {
Expand Down
1 change: 1 addition & 0 deletions src/core/components/forms/LabeledCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const LabeledCheckbox = forwardRef<HTMLInputElement, LabeledCheckboxProps
>
<div className="flex h-5 items-center">
<input
aria-describedby={scope + "Hint"}
type="checkbox"
disabled={disabled || isSubmitting}
readOnly={readonly}
Expand Down
6 changes: 3 additions & 3 deletions src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace NodeJS {
| "MORE"
| "FEEDBACK"
| "EMAIL"
readonly NEXT_PUBLIC_APP_ORIGIN:
| "http://127.0.0.1:5000"
| "https://staging,trassenscout.de"
readonly NEXT_PUBLIC_APP_ORIGIN?:
| "http://127.0.0.1:5000" // for `npm run start`
| "https://staging.trassenscout.de"
| "https://trassenscout.de"
}
}
2 changes: 1 addition & 1 deletion src/pages/[projectSlug]/surveys/[surveyId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const Survey = () => {
page.questions && feedbackQuestions.push(...page.questions)
}

const userLocationQuestionId = responseConfig?.evaluationRefs["feedback-location"]
const userLocationQuestionId = responseConfig?.evaluationRefs["location"]

const surveyResponsesFeedbackPartWithLocation = surveyResponsesFeedbackPart.filter(
// @ts-expect-error
Expand Down
13 changes: 4 additions & 9 deletions src/pages/[projectSlug]/surveys/[surveyId]/responses/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { LayoutRs, MetaTags } from "@/src/core/layouts"
import { useProjectSlug } from "@/src/core/routes/usePagesDirectoryProjectSlug"
import { useSlugId } from "@/src/core/routes/useSlug"
import getOperatorsWithCount from "@/src/server/operators/queries/getOperatorsWithCount"
import getSubsections from "@/src/server/subsections/queries/getSubsections"
import { getBackendConfigBySurveySlug } from "@/src/survey-public/utils/getConfigBySurveySlug"
import getSurveyResponseTopicsByProject from "@/src/survey-response-topics/queries/getSurveyResponseTopicsByProject"
import { EditableSurveyResponseFilterForm } from "@/src/survey-responses/components/feedback/EditableSurveyResponseFilterForm"
Expand Down Expand Up @@ -48,20 +47,17 @@ export const SurveyResponse = () => {
await refetchResponses()
}

const [{ subsections }] = useQuery(getSubsections, { projectSlug })

// Handle scroll into view on page load (like a hash URL) based on a ref and URL param `stakeholderDetails`.
// The ref is an error of listItems where the array index is the stakeholderNote.id.
const params = useRouterQuery()
const paramsStakeholderDetails = parseInt(String(params.responseDetails))
const paramsSurveyResponseId = parseInt(String(params.responseDetails))
const accordionRefs = useRef<Array<HTMLDivElement | null>>([])

useEffect(() => {
if (paramsStakeholderDetails) {
const currentRef = accordionRefs.current?.at(paramsStakeholderDetails)
if (paramsSurveyResponseId) {
const currentRef = accordionRefs.current?.at(paramsSurveyResponseId)
currentRef?.scrollIntoView({ behavior: "smooth" })
}
}, [paramsStakeholderDetails])
}, [paramsSurveyResponseId])

return (
<>
Expand Down Expand Up @@ -110,7 +106,6 @@ export const SurveyResponse = () => {
response={response}
operators={operators}
topics={topics}
subsections={subsections}
refetchResponsesAndTopics={refetchResponsesAndTopics}
/>
</div>
Expand Down
Loading
Loading