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

Survey not found error handling #5160

Merged
merged 8 commits into from
Nov 15, 2023
Merged

Conversation

alexd-bes
Copy link
Contributor

@alexd-bes alexd-bes commented Nov 12, 2023

No issue: survey not found error handling

Changes:

  • Add error handling when an error is caught when fetching the survey

Screenshots:

Screenshot 2023-11-13 at 9 50 47 am

defaultOptions: {
queries: {
staleTime: 1000 * 60 * 5, // 5 minutes
refetchOnWindowFocus: false,
retry: 0,
retry: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah great find - I assume that this will fix the other places such as login where the request errors show up multiple times

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think the errors showing up multiple times is a side effect of various queries being present on different screens and possibly causing re-renders when we have redirects. So from what I could tell, for the most part when we handle surveys not being found before it redirects infinitely, then this issue is handled (90% of the time)

/**
* This is to redirect the user to the survey not found page if they try to access a survey that does not exist
*/
const SurveyNotFoundRedirect = ({ children }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea.
On a side note this file is getting a bit big. Maybe next time we add something we should split it up a bit

}
`;

export const ErrorDisplay = ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a great idea - it's handy to have this component

title?: string;
}

export const NotFoundPage = ({ error, title = '404: Page not found' }: NotFoundPageProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I make a request to update the NotFoundPage to be called ErrorPage since it's now generic. For example we might use it for Permission Denied errors or something. Also would you be able to tweak the styles so the Paper is in the middle of the page 🙏

Copy link
Contributor

@tcaiger tcaiger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking up these extra changes, it's great to have these error handled gracefully! Left a request for a couple of tweaks but I'm happy to pre-approve.

Base automatically changed from datatrak-web-epic to dev November 13, 2023 02:00
@tcaiger tcaiger changed the base branch from dev to datatrak-web-epic November 13, 2023 21:15
@alexd-bes alexd-bes merged commit 4026d98 into datatrak-web-epic Nov 15, 2023
42 checks passed
@alexd-bes alexd-bes deleted the survey-not-found branch November 15, 2023 21:35
tcaiger added a commit that referenced this pull request Nov 19, 2023
* Waitp 1368 datatrak web fe setup (#4875)

* Added skeleton datatrak-server package

* Added datatrak-server to CI/CD

* wip datatrak front end app

* Added api-client to datatrak-server

* Added /projects route to datatrak-server

* disable eslint and re-install dependencies

* Added /entities route to datatrak-server

* add base views and downgrade react

* Update api.js

* Disabled frozen-lockfile

* Reverted yarn.lock

* Re-enabled frozen lockfile

* Add datatrak to CI/CD

* Added /surveys and /surveyScreenComponents routes

* Re-enabled exports of ui-components

* Switched to using pre-existing build and start scripts for datatrak

* add base form components

* Fix datatrak build

* format data to screens

* Got login working

* Added extra fields to FetchSurveyScreenComponents

* Got project and country selection working

* Upated yarn.lock

* Got survey selection working

* Got Survey page working

* screen steps

* add template styling

* add admin route

* Switched to using .env var for server url

* add logout

* Fixed up FetchUserRoute

* Add submitSurveyResponse route

* labels

* Add entity question

* add entity question to screen

* survey submit

* Update yarn.lock

* Update package.json

* remove anything not from fe

* Merge branch 'dev' into datatrak-hackathon

* Remove unused files

* Add initial fetch example

* Update README.md

* Revert change

* Remove unneeded change

* Add back in datatrak-app

* Add .env.example

* Update files

* Remove unnecessary code

* Fixes

* Test remove server setup

* Remove test step

* WAITP-1368: Basic page layout (#4890)

* basic page layout

* styles

* use theme colours

---------

Co-authored-by: Rohan Port <rohan@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1367 DataTrak Server (#4902)

* WAITP-1367 Add datatrak_session table to db

* WAITP-1367 Add request type for datatrak user request

* WAITP-1367 Add datatrak-server package

* WAITP-1367 Regenerate yarn.lock

* WAITP-1367 Fix minor copy-paste errors

* WAITP-1367 Add datatrak_session to ignored tables for hooks

* WAITP-1367 Add datatrak-server to server startup script in datatrak-web

* WAITP-1367 Add datatrak-server to CI/CD scripts

* WAITP-1367 Reduce layer count in dockerfile

* WAITP-1367 Regenerate types

* WAITP-1367 Regnerate types (again)

* WAITP-1367 Fixup clashing exports

* WAITP-1367 Rebalance test batching

* WAITP-1367: Rename datatrak-server to datatrak-web-server (#4904)

* find and replace

* rename package

* Update tupaia-ci-cd.Dockerfile

* update types

* Generate types

* Revert "Generate types"

This reverts commit 6fbbec6.

* WAITP-1277 datatrak-web login form part 1 (#4899)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* Update private routes and fix build

* Fix type errors

* Fix types

* Generate types

* Revert "Generate types"

This reverts commit de0fb64.

* Create private route

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 register page (#4903)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Update storybook

* Fix storybook

* Add pages to datatrak-web and mobile styling

* Fixes

* Fix route names

* Update private routes and fix build

* Fix height

* Fix type errors

* Fix types

* Generate types

* Revert "Generate types"

This reverts commit de0fb64.

* Create private route

* Fix build

* Fix casing

* Fix build error

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1379: select survey (#4925)

* Initial landing page

* Working survey select

* Fix type errors

* WAITP-1411: Setup datatrak survey screens (#4920)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* fix types

* scrren layout

* refactor context

* tidy up css

* resolve conflicts

* Update merge

* Update useSurveyScreenComponents.tsx

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* Fix circular types error

* Fix route

* Test types generate

* revert generate changes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1417 top progress bar (#4923)

* Started on progress bar commit

* added more styling and changed logic

* designed logic for progress bar

* fixed progress bar colour

* fixed pr

* ready for retest

* Added to survey page

* cleaned a few things

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1345: core question types (#4930)

* Text question

* Binary and radio questions

* Update types

* ƒix option parsing

* Date question

* Update question number logic

* Instruction question

* Update index.ts

* Handle review screen

* Fix date styles

* Update text field width

* Update line height

* Add types

* remove question number for now

* Checkbox question and styling

* Checkbox question

* Add comment

* DateTimeQuestion

* Add controller around all questions

* Add in question number

* Reorder imports

* Handle more than 26 questions on a screen

* Update casing.ts

* Fix imports

* Fixes and generate types

* Fix merge and question number logic

* Fix props

* yarn generate

* yarn generate

* WAITP-1428: datatrak design updates (#4949)

* Auth updates part 1

* Auth view

* Survey screen

* Tooltip buttons

* Use theme variable

* Update theme variable for primary text

* Auth layout

* Move styles into common form files

* Fix layout padding

* Update layout

* Update SurveySelectPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1414 code generator hints (#4944)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* Initial landing page

* fix types

* scrren layout

* refactor context

* Working survey select

* tidy up css

* resolve conflicts

* Fix type errors

* Update merge

* Update useSurveyScreenComponents.tsx

* work in progress

* need testing

* quick fix

* styling commit

* few pr changes

* changed folder locations

* fixed imports and exports

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1346: Survey contents menu (#4958)

* Working menu

* Remove unused import

* Fixes

* WAITP-1350: Cancel survey workflow (#4964)

* WAITP-1327: Geolocate question type (#4917)

* WIP on geolocation question

* Pushing to remote for pairing

* updates to map pin drop functionality and ui

* tidying up unused imports and redundant components

* Fixes part 1

* Updates

* Fixes

---------

Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: acdunham <alex@beyondessential.com.au>

* Waitp 1427 survey submit success screen (#4965)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Fixes

* Fix types

* remove questions url

* Fix types

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* update ci cd with datatrak web

* add stub test

* WAITP-1407: Datatrak project select (#4950)

* project select modal

* save project id for a user

* fix types

* Update ProjectSelectPage.tsx

* edit project

* Update ProjectSelectPage.tsx

* Update ProjectSelectModal.tsx

* custom icons

* pr changes

* request access styles

* request access on click

* update types

* WAITP-1439: Survey review screen (#4985)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Review screen

* Initial mutation

* Tidy up files

* Fixes

* Update SurveyLayout.tsx

---------

Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1410: Request project access (#4997)

* Working request access

* Add access requested icon to project list

* Add 'EditUserForMe' endpoint

* Remove all countries requested view

* Refactor select list

* Fix on select issue

* Don't have onClick if is not a button

* Generate types

* Fixes

* Update types

* WAITP-1429: Autocomplete question (#5010)

* WIP

* Finish styling and get working

* Update styles

* Update font size

* Update hover colour

* Update packages/datatrak-web/src/features/Questions/AutocompleteQuestion.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1413: Datatrak Web Entity Question (#4996)

* setup entities question

* searching

* debounce

* styles

* close button

* sorting search results

* update filters

* remove old entity route

* fix filters

* fix types

* Update EntityList.js

* Update EntitiesRoute.ts

* refactor to match new list component

* Update useUser.ts

* add mock api with msw (#5019)

* WAITP-1437 toast messages (#5015)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Fixes

* Fix build errors and merge conflicts

* Fix error

* Fix broken test

* WAITP-1407: Add support for user preferences to user accounts (#5023)

* migration

* saving user preferences

* add validation to edit user endpoint

* fix tests

* WAITP-1431: Select country (#5026)

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Add country name to survey toolbar

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* Generate types

* Update schemas.ts

* Fixes

* Reorganise files

* Fix build errors

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1423: Primary entity question (#5027)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Fixes

* Fix build errors and merge conflicts

* Add country name to survey toolbar

* setup submit

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* move mocks

* primary entity handling

* Generate types

* Update schemas.ts

* attributes filter

* use country data

* Fixes

* Reorganise files

* Fix build errors

* update survey data key

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1369 Setup datatrak deployment (#5031)

* WAITP-1369 Add datatrak to servers.conf and subdomain suffixes

* WAITP-1369 Regenerate types

* WAITP-1369 Regen yarn.lock

* WAITP-1369 Fixup entity-server test

* WAITP-1369 Fixup usage of entity request type

* WAITP-1369 Remove broken include

* WAITP-1369 Regen types

* WAITP-1369 Fixup unit test

* Update tsconfig-build for datatrak-web-server

* no-issue-dedupe-react-router-dom

* WAITP-1349: Survey submit (#5032)

* Working survey submit

* Only show repeat survey button when canRepeat is true

* Fix todos

* Add loader

* Add coconut notification

* Tidy up

* Fix variable names

* Fix types

* Reorder imports

* Fix build error

* No issue: add test runner to datatrak-web (#5034)

* setup test runner

* add example survey

* change import meta to process env

* update survey test

* Update survey.test.tsx

* WAITP-1429: Autocomplete add and filtering of options (#5040)

* Enable create new option and filter options

* Tidy up code

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Update packages/datatrak-web/src/__tests__/features/Questions/AutocompleteQuestion.test.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Fix types

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1416: Visibility criteria (#5044)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* WAITP-1440: Mobile styling (#5042)

* WIP mobile styling

* WIP

* Fix project button styling

* Fix types

* Mobile app prompt

* Fix dashboard button styling

* WAITP-1347: Validation criteria (#5047)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Working validation

* Working validation

* Fix autocomplete styling

* Fix autocomplete issue

* Extract getRules function

* Fix typo

* No issue: Update survey screen fetching (#5050)

* Update get surveys endpoint

* Change to using surveys endpoint

* Fix types and visible question logic

* Remove old route

* Fix types and tests

* Generate types

* WAITP-1424: Entity question upserts (#5045)

* Enable create new option and filter options

* Tidy up code

* add filter prop

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Submit Survey route

* Update useSubmitSurvey.ts

* add entities upserted

* update test suite

* fix bad merge

* update types

* set country in upsert entity

* Update schemas.ts

* fix up types

* fix tests

* fix schema

* fix tests

* wip refactor form submission

* move tests to server

* generate schemas

* fix entity test

* Update render.tsx

* Update useSubmitSurvey.test.ts

* Update render.tsx

* reuse survey request types

* Update schemas.ts

* fix question types

* fix types

* Update schemas.ts

* optional screen id

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1430: condition question (#5049)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Fix tests and build

* WAITP-1453: UI updates (#5052)

* Handle location errors

* Fix redirect issue for requesting access

* Add tooltip delay

* Add delay on mobile devices

* Tidy tooltip props code

* Update popovers

* Update header heights

* Update number field width

* Make text inputs multiline when text wraps

* Make radio labels full width

* Clip side menu item length

* Center instruction only screens

* Remove horizontal centering

* Hide placeholder in review screen

* Update survey icons

* Remove unused import

* Fix build errors

* Fixes

* Fix errors

* WAITP-1412: Arithmetic question (#5054)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* Add handling for custom display text

* WAITP-1276: Forgot password (#5056)

* Add forgot passowrd view

* Working form

* Add stories

* Fix build

* Set height on forgot password screen

* Reset success screen

* Reorder imports

* WAITP-1345:Core question updates (#5066)

* Allow color to be set on radio options

* Get help text working

* Update SurveyQuestionGroup.tsx

* Update types

* WAITP-1349: Fix DataTrak survey submit (#5078)

* Update surveyResponse.js

* Update surveyResponse.js

* WAITP-1454: design updates (#5079)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* WAITP-1454: Fix sorting of surveys (#5080)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* Fix sorting in folders

* Update FE sorting

* tile component

* Revert "tile component"

This reverts commit 7b612fb.

* WAITP-1454: UI changes (#5089)

* tile component

* Show modal when exiting survey via home button

* Remove unused imports

* Stop menu re-rendering on change of survey screen

* Update button disabled state

* Fix build errors

* Fix tests

* Close side menu on screen change on mobile

* clean up code from another branch

* Update LandingPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 Forward signup route to web config server (#5090)

* WAITP-1377 Forward signup route to web config server

* WAITP-1377 Fixup lint

* WAITP-1449: QR code generator (#5086)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* WIP

* WIP

* WIP

* WIP

* Working qr code

* Fix types

* Update test

* Fix tests

* PR fixes

* WAITP-1415: Photo upload question (#5099)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* no-issue-fix-types-after-merge

* WAITP-1357: Datatrak dashboard survey responses (#5091)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* WAITP-1461: Datatrak design feedback (#5109)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* project select page

* menu ux

* Update useSubmitSurvey.ts

* gps question

* Update index.html

* Update ProjectsRoute.ts

* theming

* Update mui.d.ts

* Update useSubmitSurvey.test.ts

* Update theme.ts

* Update SurveySelectPage.tsx

* Update SurveySelectPage.tsx

* Update useValidationResolver.ts (#5128)

* WAITP-1412: fix arithmetic questions

* one time login flow (#5138)

* WAITP-1354: Leaderboard (#5132)

* no-issue: Add @tupaia/server-utils package (#5121)

* RN-1060: (task) Moved sendEmail to @tupaia/server-utils (#5126)

* RN-1060: (task) Added dashboards/:project/:entity/:dashboard/export route to tupaia-web (#5125)

* WAITP-1354: Leaderboard

* Update copyright

* Update internal email

* Update email filter

* Fix response type

* Update packages/datatrak-web/src/features/Leaderboard/LeaderboardTable.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update background variable

* Update branch name validation script (#5136)

* Update to use new leaderboard model

* Revert "Merge branch 'dev' into waitp-1354-leaderboard"

This reverts commit c2acdbe, reversing
changes made to 747f182.

* Fix types

* Update packages/database/src/modelClasses/SurveyResponse.js

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>

* PR fixes

* Fix error

---------

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>

* WAITP-1356: recent surveys (#5113)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* Frontend layout

* Working request

* Refetch recent surveys on submit

* Fix recent survey request and styling

* Use grid and update heading element

* Remove unnecessary css

* PR fixes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1469: account delete (#5134)

* WIP

* Account deletion

* Update component for section

* Update modals

* Remove forced open state

* Fix types

* fix build error

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Change format

* fix bad merge

* return zeros for rewards

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1330: File upload question type (#5100)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* Working file upload

* Fix build

* Remove unused vars

* Update format of file upload answers

* Update schemas.ts

* Update processSurveyResponse.test.ts

* Update upsertAnswers.js

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1424: Datatrak PrimaryEntity question fix (#5144)

* fix rewards types

* update primary entity question name

* WIP

* Fix success screen layout

* Fix date change issue

* Fix error styling

* Working activity feed

* Tidy ups

* WAITP-1427: Fix survey cancelling (#5148)

* Update CancelSurveyModal.tsx

* tidy up landing page

* fix console errors

* No issue: Only generate QR code when createNew is true

* No issue: Fix tests

* Remove permission group and country from admin panel feed items

* No issue: Fix recent survey layout

* Working pinned posts

* No issue: Login redirect (#5151)

* Redirect to route on login or project select

* Formatting

* Always show user on leaderboard

* WAITP-1478 Single survey response endpoint (#5153)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* WAITP-1478 Update survey response answers to map by question_id

* WAITP-1478 Rename RecentSurveyResponse to SingleSurveyResponse

* WAITP-1478 Rename files

* Fix PR

* Generate types

* Fix styling

* Update Button.tsx

* Fixes

* WAITP-1452: Datatrak-web refactor survey context (#5156)

* Update useLogin.ts

* refactor survey context to be at survey level

* Create migration

* Update types

* Responsive styling (#5158)

* Responsive styling

* Fix padding on mobile

* Handle project id in queries

* Filter user rewards by project id

* Update queries to have projectId as optional param

* Fix bindings

* Update SurveyResponse.js

* Add project column to admin panel

* WAITP-1452: Recent survey response page (#5157)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* useSurveyResponse

* survey review screen

* wip set default values

* set up route

* Update useLogin.ts

* refactor survey context to be at survey level

* remove bad merge

* survey data

* basic working setup

* remove debug changes

* split out paginator

* put page back in survey layout

* refactor layout components

* Update index.ts

* Update SurveyContext.tsx

* Update SurveyReviewSection.tsx

---------

Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>

* Update 20231112212117-AddProjectIdToSurveys-modifies-schema.js

* Add index to migration

* Fix migration

* Fix typo

* Cap survey name length at 50 characters

* WAITP-1490: Datatrak current user context (#5170)

* add current user context

* add error display

* rename context

* WAITP-1431: Fix survey select filter (#5177)

* Update SurveysRoute.ts

* remove tsx extentions

* Update SurveysRoute.ts

* WAITP-1387: Add survey project field (#5172)

* Responsive styling of dashboard leaderboard (#5173)

* Responsive styling of dashboard leaderboard

* Fix type error

* Survey not found error handling (#5160)

* Survey not found error handling

* Reorder imports

* Updates to route

* Fix types

* Remove unused imports

* Error page rename

* Rename page

* no-issue: Fix `location.state` null (#5179)

* extract useFromLocation

* extract `useFromLocation` to own file and use

* WAITP-1474: Update success illustration on DataTrak (#5159)

* generify high-five graphic filename

* update submission success graphic

* define margins along block/inline axes

See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flow_layout/Block_and_inline_layout_in_normal_flow

* success screen fix horizontal overflow

* define survey success image dimen with `rem`

* relabel button ‘Close’ → ‘Return to dashboard’

* Fix package error

* Fix autocomplete validation issue

* WAITP-1431: Update datatrak survey url with country code (#5182)

* add Single Entity Route

* use country url to submit

* fix tests

* make TupaiaWebEntityRequest re-usable

* Update SingleEntityRoute.ts

* update recent surveys and responses routes

* handle recent survey submissions

* Update SurveyResponsesSection.tsx

* update country id in survey page

* remove unused code

* Update processSurveyResponse.test.ts

---------

Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>
Co-authored-by: Rohan Port <rohan@beyondessential.com.au>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>
Co-authored-by: acdunham <alex@beyondessential.com.au>
Co-authored-by: Chao Xin Nhin <122791168+chaoxinnhin@users.noreply.github.com>
Co-authored-by: Wilhelmus Duncker <122330202+WDuncker@users.noreply.github.com>
Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>
Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Jasper Lai <33956381+jaskfla@users.noreply.github.com>
alexd-bes added a commit that referenced this pull request Nov 30, 2023
* Waitp 1368 datatrak web fe setup (#4875)

* Added skeleton datatrak-server package

* Added datatrak-server to CI/CD

* wip datatrak front end app

* Added api-client to datatrak-server

* Added /projects route to datatrak-server

* disable eslint and re-install dependencies

* Added /entities route to datatrak-server

* add base views and downgrade react

* Update api.js

* Disabled frozen-lockfile

* Reverted yarn.lock

* Re-enabled frozen lockfile

* Add datatrak to CI/CD

* Added /surveys and /surveyScreenComponents routes

* Re-enabled exports of ui-components

* Switched to using pre-existing build and start scripts for datatrak

* add base form components

* Fix datatrak build

* format data to screens

* Got login working

* Added extra fields to FetchSurveyScreenComponents

* Got project and country selection working

* Upated yarn.lock

* Got survey selection working

* Got Survey page working

* screen steps

* add template styling

* add admin route

* Switched to using .env var for server url

* add logout

* Fixed up FetchUserRoute

* Add submitSurveyResponse route

* labels

* Add entity question

* add entity question to screen

* survey submit

* Update yarn.lock

* Update package.json

* remove anything not from fe

* Merge branch 'dev' into datatrak-hackathon

* Remove unused files

* Add initial fetch example

* Update README.md

* Revert change

* Remove unneeded change

* Add back in datatrak-app

* Add .env.example

* Update files

* Remove unnecessary code

* Fixes

* Test remove server setup

* Remove test step

* WAITP-1368: Basic page layout (#4890)

* basic page layout

* styles

* use theme colours

---------

Co-authored-by: Rohan Port <rohan@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1367 DataTrak Server (#4902)

* WAITP-1367 Add datatrak_session table to db

* WAITP-1367 Add request type for datatrak user request

* WAITP-1367 Add datatrak-server package

* WAITP-1367 Regenerate yarn.lock

* WAITP-1367 Fix minor copy-paste errors

* WAITP-1367 Add datatrak_session to ignored tables for hooks

* WAITP-1367 Add datatrak-server to server startup script in datatrak-web

* WAITP-1367 Add datatrak-server to CI/CD scripts

* WAITP-1367 Reduce layer count in dockerfile

* WAITP-1367 Regenerate types

* WAITP-1367 Regnerate types (again)

* WAITP-1367 Fixup clashing exports

* WAITP-1367 Rebalance test batching

* WAITP-1367: Rename datatrak-server to datatrak-web-server (#4904)

* find and replace

* rename package

* Update tupaia-ci-cd.Dockerfile

* update types

* Generate types

* Revert "Generate types"

This reverts commit 6fbbec6.

* WAITP-1277 datatrak-web login form part 1 (#4899)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* Update private routes and fix build

* Fix type errors

* Fix types

* Generate types

* Revert "Generate types"

This reverts commit de0fb64.

* Create private route

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 register page (#4903)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Update storybook

* Fix storybook

* Add pages to datatrak-web and mobile styling

* Fixes

* Fix route names

* Update private routes and fix build

* Fix height

* Fix type errors

* Fix types

* Generate types

* Revert "Generate types"

This reverts commit de0fb64.

* Create private route

* Fix build

* Fix casing

* Fix build error

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1379: select survey (#4925)

* Initial landing page

* Working survey select

* Fix type errors

* WAITP-1411: Setup datatrak survey screens (#4920)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* fix types

* scrren layout

* refactor context

* tidy up css

* resolve conflicts

* Update merge

* Update useSurveyScreenComponents.tsx

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* Fix circular types error

* Fix route

* Test types generate

* revert generate changes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1417 top progress bar (#4923)

* Started on progress bar commit

* added more styling and changed logic

* designed logic for progress bar

* fixed progress bar colour

* fixed pr

* ready for retest

* Added to survey page

* cleaned a few things

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1345: core question types (#4930)

* Text question

* Binary and radio questions

* Update types

* ƒix option parsing

* Date question

* Update question number logic

* Instruction question

* Update index.ts

* Handle review screen

* Fix date styles

* Update text field width

* Update line height

* Add types

* remove question number for now

* Checkbox question and styling

* Checkbox question

* Add comment

* DateTimeQuestion

* Add controller around all questions

* Add in question number

* Reorder imports

* Handle more than 26 questions on a screen

* Update casing.ts

* Fix imports

* Fixes and generate types

* Fix merge and question number logic

* Fix props

* yarn generate

* yarn generate

* WAITP-1428: datatrak design updates (#4949)

* Auth updates part 1

* Auth view

* Survey screen

* Tooltip buttons

* Use theme variable

* Update theme variable for primary text

* Auth layout

* Move styles into common form files

* Fix layout padding

* Update layout

* Update SurveySelectPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1414 code generator hints (#4944)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* Initial landing page

* fix types

* scrren layout

* refactor context

* Working survey select

* tidy up css

* resolve conflicts

* Fix type errors

* Update merge

* Update useSurveyScreenComponents.tsx

* work in progress

* need testing

* quick fix

* styling commit

* few pr changes

* changed folder locations

* fixed imports and exports

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1346: Survey contents menu (#4958)

* Working menu

* Remove unused import

* Fixes

* WAITP-1350: Cancel survey workflow (#4964)

* WAITP-1327: Geolocate question type (#4917)

* WIP on geolocation question

* Pushing to remote for pairing

* updates to map pin drop functionality and ui

* tidying up unused imports and redundant components

* Fixes part 1

* Updates

* Fixes

---------

Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: acdunham <alex@beyondessential.com.au>

* Waitp 1427 survey submit success screen (#4965)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Fixes

* Fix types

* remove questions url

* Fix types

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* update ci cd with datatrak web

* add stub test

* WAITP-1407: Datatrak project select (#4950)

* project select modal

* save project id for a user

* fix types

* Update ProjectSelectPage.tsx

* edit project

* Update ProjectSelectPage.tsx

* Update ProjectSelectModal.tsx

* custom icons

* pr changes

* request access styles

* request access on click

* update types

* WAITP-1439: Survey review screen (#4985)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Review screen

* Initial mutation

* Tidy up files

* Fixes

* Update SurveyLayout.tsx

---------

Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1410: Request project access (#4997)

* Working request access

* Add access requested icon to project list

* Add 'EditUserForMe' endpoint

* Remove all countries requested view

* Refactor select list

* Fix on select issue

* Don't have onClick if is not a button

* Generate types

* Fixes

* Update types

* WAITP-1429: Autocomplete question (#5010)

* WIP

* Finish styling and get working

* Update styles

* Update font size

* Update hover colour

* Update packages/datatrak-web/src/features/Questions/AutocompleteQuestion.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1413: Datatrak Web Entity Question (#4996)

* setup entities question

* searching

* debounce

* styles

* close button

* sorting search results

* update filters

* remove old entity route

* fix filters

* fix types

* Update EntityList.js

* Update EntitiesRoute.ts

* refactor to match new list component

* Update useUser.ts

* add mock api with msw (#5019)

* WAITP-1437 toast messages (#5015)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Fixes

* Fix build errors and merge conflicts

* Fix error

* Fix broken test

* WAITP-1407: Add support for user preferences to user accounts (#5023)

* migration

* saving user preferences

* add validation to edit user endpoint

* fix tests

* WAITP-1431: Select country (#5026)

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Add country name to survey toolbar

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* Generate types

* Update schemas.ts

* Fixes

* Reorganise files

* Fix build errors

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1423: Primary entity question (#5027)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Fixes

* Fix build errors and merge conflicts

* Add country name to survey toolbar

* setup submit

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* move mocks

* primary entity handling

* Generate types

* Update schemas.ts

* attributes filter

* use country data

* Fixes

* Reorganise files

* Fix build errors

* update survey data key

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1369 Setup datatrak deployment (#5031)

* WAITP-1369 Add datatrak to servers.conf and subdomain suffixes

* WAITP-1369 Regenerate types

* WAITP-1369 Regen yarn.lock

* WAITP-1369 Fixup entity-server test

* WAITP-1369 Fixup usage of entity request type

* WAITP-1369 Remove broken include

* WAITP-1369 Regen types

* WAITP-1369 Fixup unit test

* Update tsconfig-build for datatrak-web-server

* no-issue-dedupe-react-router-dom

* WAITP-1349: Survey submit (#5032)

* Working survey submit

* Only show repeat survey button when canRepeat is true

* Fix todos

* Add loader

* Add coconut notification

* Tidy up

* Fix variable names

* Fix types

* Reorder imports

* Fix build error

* No issue: add test runner to datatrak-web (#5034)

* setup test runner

* add example survey

* change import meta to process env

* update survey test

* Update survey.test.tsx

* WAITP-1429: Autocomplete add and filtering of options (#5040)

* Enable create new option and filter options

* Tidy up code

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Update packages/datatrak-web/src/__tests__/features/Questions/AutocompleteQuestion.test.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Fix types

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1416: Visibility criteria (#5044)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* WAITP-1440: Mobile styling (#5042)

* WIP mobile styling

* WIP

* Fix project button styling

* Fix types

* Mobile app prompt

* Fix dashboard button styling

* WAITP-1347: Validation criteria (#5047)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Working validation

* Working validation

* Fix autocomplete styling

* Fix autocomplete issue

* Extract getRules function

* Fix typo

* No issue: Update survey screen fetching (#5050)

* Update get surveys endpoint

* Change to using surveys endpoint

* Fix types and visible question logic

* Remove old route

* Fix types and tests

* Generate types

* WAITP-1424: Entity question upserts (#5045)

* Enable create new option and filter options

* Tidy up code

* add filter prop

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Submit Survey route

* Update useSubmitSurvey.ts

* add entities upserted

* update test suite

* fix bad merge

* update types

* set country in upsert entity

* Update schemas.ts

* fix up types

* fix tests

* fix schema

* fix tests

* wip refactor form submission

* move tests to server

* generate schemas

* fix entity test

* Update render.tsx

* Update useSubmitSurvey.test.ts

* Update render.tsx

* reuse survey request types

* Update schemas.ts

* fix question types

* fix types

* Update schemas.ts

* optional screen id

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1430: condition question (#5049)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Fix tests and build

* WAITP-1453: UI updates (#5052)

* Handle location errors

* Fix redirect issue for requesting access

* Add tooltip delay

* Add delay on mobile devices

* Tidy tooltip props code

* Update popovers

* Update header heights

* Update number field width

* Make text inputs multiline when text wraps

* Make radio labels full width

* Clip side menu item length

* Center instruction only screens

* Remove horizontal centering

* Hide placeholder in review screen

* Update survey icons

* Remove unused import

* Fix build errors

* Fixes

* Fix errors

* WAITP-1412: Arithmetic question (#5054)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* Add handling for custom display text

* WAITP-1276: Forgot password (#5056)

* Add forgot passowrd view

* Working form

* Add stories

* Fix build

* Set height on forgot password screen

* Reset success screen

* Reorder imports

* WAITP-1345:Core question updates (#5066)

* Allow color to be set on radio options

* Get help text working

* Update SurveyQuestionGroup.tsx

* Update types

* WAITP-1349: Fix DataTrak survey submit (#5078)

* Update surveyResponse.js

* Update surveyResponse.js

* WAITP-1454: design updates (#5079)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* WAITP-1454: Fix sorting of surveys (#5080)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* Fix sorting in folders

* Update FE sorting

* tile component

* Revert "tile component"

This reverts commit 7b612fb.

* WAITP-1454: UI changes (#5089)

* tile component

* Show modal when exiting survey via home button

* Remove unused imports

* Stop menu re-rendering on change of survey screen

* Update button disabled state

* Fix build errors

* Fix tests

* Close side menu on screen change on mobile

* clean up code from another branch

* Update LandingPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 Forward signup route to web config server (#5090)

* WAITP-1377 Forward signup route to web config server

* WAITP-1377 Fixup lint

* WAITP-1449: QR code generator (#5086)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* WIP

* WIP

* WIP

* WIP

* Working qr code

* Fix types

* Update test

* Fix tests

* PR fixes

* WAITP-1415: Photo upload question (#5099)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* no-issue-fix-types-after-merge

* WAITP-1357: Datatrak dashboard survey responses (#5091)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* WAITP-1461: Datatrak design feedback (#5109)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* project select page

* menu ux

* Update useSubmitSurvey.ts

* gps question

* Update index.html

* Update ProjectsRoute.ts

* theming

* Update mui.d.ts

* Update useSubmitSurvey.test.ts

* Update theme.ts

* Update SurveySelectPage.tsx

* Update SurveySelectPage.tsx

* Update useValidationResolver.ts (#5128)

* WAITP-1412: fix arithmetic questions

* one time login flow (#5138)

* WAITP-1354: Leaderboard (#5132)

* no-issue: Add @tupaia/server-utils package (#5121)

* RN-1060: (task) Moved sendEmail to @tupaia/server-utils (#5126)

* RN-1060: (task) Added dashboards/:project/:entity/:dashboard/export route to tupaia-web (#5125)

* WAITP-1354: Leaderboard

* Update copyright

* Update internal email

* Update email filter

* Fix response type

* Update packages/datatrak-web/src/features/Leaderboard/LeaderboardTable.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update background variable

* Update branch name validation script (#5136)

* Update to use new leaderboard model

* Revert "Merge branch 'dev' into waitp-1354-leaderboard"

This reverts commit c2acdbe, reversing
changes made to 747f182.

* Fix types

* Update packages/database/src/modelClasses/SurveyResponse.js

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>

* PR fixes

* Fix error

---------

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>

* WAITP-1356: recent surveys (#5113)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* Frontend layout

* Working request

* Refetch recent surveys on submit

* Fix recent survey request and styling

* Use grid and update heading element

* Remove unnecessary css

* PR fixes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1469: account delete (#5134)

* WIP

* Account deletion

* Update component for section

* Update modals

* Remove forced open state

* Fix types

* fix build error

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Change format

* fix bad merge

* return zeros for rewards

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1330: File upload question type (#5100)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* Working file upload

* Fix build

* Remove unused vars

* Update format of file upload answers

* Update schemas.ts

* Update processSurveyResponse.test.ts

* Update upsertAnswers.js

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1424: Datatrak PrimaryEntity question fix (#5144)

* fix rewards types

* update primary entity question name

* WIP

* Fix success screen layout

* Fix date change issue

* Fix error styling

* Working activity feed

* Tidy ups

* WAITP-1427: Fix survey cancelling (#5148)

* Update CancelSurveyModal.tsx

* tidy up landing page

* fix console errors

* No issue: Only generate QR code when createNew is true

* No issue: Fix tests

* Remove permission group and country from admin panel feed items

* No issue: Fix recent survey layout

* Working pinned posts

* No issue: Login redirect (#5151)

* Redirect to route on login or project select

* Formatting

* Always show user on leaderboard

* WAITP-1478 Single survey response endpoint (#5153)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* WAITP-1478 Update survey response answers to map by question_id

* WAITP-1478 Rename RecentSurveyResponse to SingleSurveyResponse

* WAITP-1478 Rename files

* Fix PR

* Generate types

* Fix styling

* Update Button.tsx

* Fixes

* WAITP-1452: Datatrak-web refactor survey context (#5156)

* Update useLogin.ts

* refactor survey context to be at survey level

* Create migration

* Update types

* Responsive styling (#5158)

* Responsive styling

* Fix padding on mobile

* Handle project id in queries

* Filter user rewards by project id

* Update queries to have projectId as optional param

* Fix bindings

* Update SurveyResponse.js

* Add project column to admin panel

* WAITP-1452: Recent survey response page (#5157)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* useSurveyResponse

* survey review screen

* wip set default values

* set up route

* Update useLogin.ts

* refactor survey context to be at survey level

* remove bad merge

* survey data

* basic working setup

* remove debug changes

* split out paginator

* put page back in survey layout

* refactor layout components

* Update index.ts

* Update SurveyContext.tsx

* Update SurveyReviewSection.tsx

---------

Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>

* Update 20231112212117-AddProjectIdToSurveys-modifies-schema.js

* Add index to migration

* Fix migration

* Fix typo

* Cap survey name length at 50 characters

* WAITP-1490: Datatrak current user context (#5170)

* add current user context

* add error display

* rename context

* WAITP-1431: Fix survey select filter (#5177)

* Update SurveysRoute.ts

* remove tsx extentions

* Update SurveysRoute.ts

* WAITP-1387: Add survey project field (#5172)

* Responsive styling of dashboard leaderboard (#5173)

* Responsive styling of dashboard leaderboard

* Fix type error

* Survey not found error handling (#5160)

* Survey not found error handling

* Reorder imports

* Updates to route

* Fix types

* Remove unused imports

* Error page rename

* Rename page

* no-issue: Fix `location.state` null (#5179)

* extract useFromLocation

* extract `useFromLocation` to own file and use

* WAITP-1474: Update success illustration on DataTrak (#5159)

* generify high-five graphic filename

* update submission success graphic

* define margins along block/inline axes

See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flow_layout/Block_and_inline_layout_in_normal_flow

* success screen fix horizontal overflow

* define survey success image dimen with `rem`

* relabel button ‘Close’ → ‘Return to dashboard’

* Fix package error

* Fix autocomplete validation issue

* Create migration for surveys to project mapping

* WAITP-1431: Update datatrak survey url with country code (#5182)

* add Single Entity Route

* use country url to submit

* fix tests

* make TupaiaWebEntityRequest re-usable

* Update SingleEntityRoute.ts

* update recent surveys and responses routes

* handle recent survey submissions

* Update SurveyResponsesSection.tsx

* update country id in survey page

* remove unused code

* Update processSurveyResponse.test.ts

* Update queries

* Update preferred project on survey load

* Update queries and FE to handle project ids, and add migration for project creation

* Add toast to tell user project has been updated

* Remove unused import

* Remove unused import

* Update projectSurveyMappings.json

* Filter out new empty projects from Tupaia Web frontend

* Fix merge issues

* Update mappings

* Add new projects

* WAITP-1480: survey duplication (#5193)

* Make migration

* Update migration

* Update migration

* Remove survey responses when migrating down

* Update GETSurveyResponses.test.js

---------

Co-authored-by: Rohan Port <rohan@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>
Co-authored-by: Chao Xin Nhin <122791168+chaoxinnhin@users.noreply.github.com>
Co-authored-by: Wilhelmus Duncker <122330202+WDuncker@users.noreply.github.com>
Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>
Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Jasper Lai <33956381+jaskfla@users.noreply.github.com>
Co-authored-by: RajneelR <132311480+RajneelR@users.noreply.github.com>
alexd-bes added a commit that referenced this pull request Jan 18, 2024
* Waitp 1368 datatrak web fe setup (#4875)

* Added skeleton datatrak-server package

* Added datatrak-server to CI/CD

* wip datatrak front end app

* Added api-client to datatrak-server

* Added /projects route to datatrak-server

* disable eslint and re-install dependencies

* Added /entities route to datatrak-server

* add base views and downgrade react

* Update api.js

* Disabled frozen-lockfile

* Reverted yarn.lock

* Re-enabled frozen lockfile

* Add datatrak to CI/CD

* Added /surveys and /surveyScreenComponents routes

* Re-enabled exports of ui-components

* Switched to using pre-existing build and start scripts for datatrak

* add base form components

* Fix datatrak build

* format data to screens

* Got login working

* Added extra fields to FetchSurveyScreenComponents

* Got project and country selection working

* Upated yarn.lock

* Got survey selection working

* Got Survey page working

* screen steps

* add template styling

* add admin route

* Switched to using .env var for server url

* add logout

* Fixed up FetchUserRoute

* Add submitSurveyResponse route

* labels

* Add entity question

* add entity question to screen

* survey submit

* Update yarn.lock

* Update package.json

* remove anything not from fe

* Merge branch 'dev' into datatrak-hackathon

* Remove unused files

* Add initial fetch example

* Update README.md

* Revert change

* Remove unneeded change

* Add back in datatrak-app

* Add .env.example

* Update files

* Remove unnecessary code

* Fixes

* Test remove server setup

* Remove test step

* WAITP-1368: Basic page layout (#4890)

* basic page layout

* styles

* use theme colours

---------

Co-authored-by: Rohan Port <rohan@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1367 DataTrak Server (#4902)

* WAITP-1367 Add datatrak_session table to db

* WAITP-1367 Add request type for datatrak user request

* WAITP-1367 Add datatrak-server package

* WAITP-1367 Regenerate yarn.lock

* WAITP-1367 Fix minor copy-paste errors

* WAITP-1367 Add datatrak_session to ignored tables for hooks

* WAITP-1367 Add datatrak-server to server startup script in datatrak-web

* WAITP-1367 Add datatrak-server to CI/CD scripts

* WAITP-1367 Reduce layer count in dockerfile

* WAITP-1367 Regenerate types

* WAITP-1367 Regnerate types (again)

* WAITP-1367 Fixup clashing exports

* WAITP-1367 Rebalance test batching

* WAITP-1367: Rename datatrak-server to datatrak-web-server (#4904)

* find and replace

* rename package

* Update tupaia-ci-cd.Dockerfile

* update types

* Generate types

* Revert "Generate types"

This reverts commit 6fbbec6.

* WAITP-1277 datatrak-web login form part 1 (#4899)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* Update private routes and fix build

* Fix type errors

* Fix types

* Generate types

* Revert "Generate types"

This reverts commit de0fb64.

* Create private route

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 register page (#4903)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Update storybook

* Fix storybook

* Add pages to datatrak-web and mobile styling

* Fixes

* Fix route names

* Update private routes and fix build

* Fix height

* Fix type errors

* Fix types

* Generate types

* Revert "Generate types"

This reverts commit de0fb64.

* Create private route

* Fix build

* Fix casing

* Fix build error

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1379: select survey (#4925)

* Initial landing page

* Working survey select

* Fix type errors

* WAITP-1411: Setup datatrak survey screens (#4920)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* fix types

* scrren layout

* refactor context

* tidy up css

* resolve conflicts

* Update merge

* Update useSurveyScreenComponents.tsx

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* Fix circular types error

* Fix route

* Test types generate

* revert generate changes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1417 top progress bar (#4923)

* Started on progress bar commit

* added more styling and changed logic

* designed logic for progress bar

* fixed progress bar colour

* fixed pr

* ready for retest

* Added to survey page

* cleaned a few things

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1345: core question types (#4930)

* Text question

* Binary and radio questions

* Update types

* ƒix option parsing

* Date question

* Update question number logic

* Instruction question

* Update index.ts

* Handle review screen

* Fix date styles

* Update text field width

* Update line height

* Add types

* remove question number for now

* Checkbox question and styling

* Checkbox question

* Add comment

* DateTimeQuestion

* Add controller around all questions

* Add in question number

* Reorder imports

* Handle more than 26 questions on a screen

* Update casing.ts

* Fix imports

* Fixes and generate types

* Fix merge and question number logic

* Fix props

* yarn generate

* yarn generate

* WAITP-1428: datatrak design updates (#4949)

* Auth updates part 1

* Auth view

* Survey screen

* Tooltip buttons

* Use theme variable

* Update theme variable for primary text

* Auth layout

* Move styles into common form files

* Fix layout padding

* Update layout

* Update SurveySelectPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1414 code generator hints (#4944)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* Initial landing page

* fix types

* scrren layout

* refactor context

* Working survey select

* tidy up css

* resolve conflicts

* Fix type errors

* Update merge

* Update useSurveyScreenComponents.tsx

* work in progress

* need testing

* quick fix

* styling commit

* few pr changes

* changed folder locations

* fixed imports and exports

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1346: Survey contents menu (#4958)

* Working menu

* Remove unused import

* Fixes

* WAITP-1350: Cancel survey workflow (#4964)

* WAITP-1327: Geolocate question type (#4917)

* WIP on geolocation question

* Pushing to remote for pairing

* updates to map pin drop functionality and ui

* tidying up unused imports and redundant components

* Fixes part 1

* Updates

* Fixes

---------

Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: acdunham <alex@beyondessential.com.au>

* Waitp 1427 survey submit success screen (#4965)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Fixes

* Fix types

* remove questions url

* Fix types

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* update ci cd with datatrak web

* add stub test

* WAITP-1407: Datatrak project select (#4950)

* project select modal

* save project id for a user

* fix types

* Update ProjectSelectPage.tsx

* edit project

* Update ProjectSelectPage.tsx

* Update ProjectSelectModal.tsx

* custom icons

* pr changes

* request access styles

* request access on click

* update types

* WAITP-1439: Survey review screen (#4985)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Review screen

* Initial mutation

* Tidy up files

* Fixes

* Update SurveyLayout.tsx

---------

Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1410: Request project access (#4997)

* Working request access

* Add access requested icon to project list

* Add 'EditUserForMe' endpoint

* Remove all countries requested view

* Refactor select list

* Fix on select issue

* Don't have onClick if is not a button

* Generate types

* Fixes

* Update types

* WAITP-1429: Autocomplete question (#5010)

* WIP

* Finish styling and get working

* Update styles

* Update font size

* Update hover colour

* Update packages/datatrak-web/src/features/Questions/AutocompleteQuestion.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1413: Datatrak Web Entity Question (#4996)

* setup entities question

* searching

* debounce

* styles

* close button

* sorting search results

* update filters

* remove old entity route

* fix filters

* fix types

* Update EntityList.js

* Update EntitiesRoute.ts

* refactor to match new list component

* Update useUser.ts

* add mock api with msw (#5019)

* WAITP-1437 toast messages (#5015)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Fixes

* Fix build errors and merge conflicts

* Fix error

* Fix broken test

* WAITP-1407: Add support for user preferences to user accounts (#5023)

* migration

* saving user preferences

* add validation to edit user endpoint

* fix tests

* WAITP-1431: Select country (#5026)

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Add country name to survey toolbar

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* Generate types

* Update schemas.ts

* Fixes

* Reorganise files

* Fix build errors

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1423: Primary entity question (#5027)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Fixes

* Fix build errors and merge conflicts

* Add country name to survey toolbar

* setup submit

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* move mocks

* primary entity handling

* Generate types

* Update schemas.ts

* attributes filter

* use country data

* Fixes

* Reorganise files

* Fix build errors

* update survey data key

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1369 Setup datatrak deployment (#5031)

* WAITP-1369 Add datatrak to servers.conf and subdomain suffixes

* WAITP-1369 Regenerate types

* WAITP-1369 Regen yarn.lock

* WAITP-1369 Fixup entity-server test

* WAITP-1369 Fixup usage of entity request type

* WAITP-1369 Remove broken include

* WAITP-1369 Regen types

* WAITP-1369 Fixup unit test

* Update tsconfig-build for datatrak-web-server

* no-issue-dedupe-react-router-dom

* WAITP-1349: Survey submit (#5032)

* Working survey submit

* Only show repeat survey button when canRepeat is true

* Fix todos

* Add loader

* Add coconut notification

* Tidy up

* Fix variable names

* Fix types

* Reorder imports

* Fix build error

* No issue: add test runner to datatrak-web (#5034)

* setup test runner

* add example survey

* change import meta to process env

* update survey test

* Update survey.test.tsx

* WAITP-1429: Autocomplete add and filtering of options (#5040)

* Enable create new option and filter options

* Tidy up code

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Update packages/datatrak-web/src/__tests__/features/Questions/AutocompleteQuestion.test.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Fix types

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1416: Visibility criteria (#5044)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* WAITP-1440: Mobile styling (#5042)

* WIP mobile styling

* WIP

* Fix project button styling

* Fix types

* Mobile app prompt

* Fix dashboard button styling

* WAITP-1347: Validation criteria (#5047)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Working validation

* Working validation

* Fix autocomplete styling

* Fix autocomplete issue

* Extract getRules function

* Fix typo

* No issue: Update survey screen fetching (#5050)

* Update get surveys endpoint

* Change to using surveys endpoint

* Fix types and visible question logic

* Remove old route

* Fix types and tests

* Generate types

* WAITP-1424: Entity question upserts (#5045)

* Enable create new option and filter options

* Tidy up code

* add filter prop

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Submit Survey route

* Update useSubmitSurvey.ts

* add entities upserted

* update test suite

* fix bad merge

* update types

* set country in upsert entity

* Update schemas.ts

* fix up types

* fix tests

* fix schema

* fix tests

* wip refactor form submission

* move tests to server

* generate schemas

* fix entity test

* Update render.tsx

* Update useSubmitSurvey.test.ts

* Update render.tsx

* reuse survey request types

* Update schemas.ts

* fix question types

* fix types

* Update schemas.ts

* optional screen id

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1430: condition question (#5049)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Fix tests and build

* WAITP-1453: UI updates (#5052)

* Handle location errors

* Fix redirect issue for requesting access

* Add tooltip delay

* Add delay on mobile devices

* Tidy tooltip props code

* Update popovers

* Update header heights

* Update number field width

* Make text inputs multiline when text wraps

* Make radio labels full width

* Clip side menu item length

* Center instruction only screens

* Remove horizontal centering

* Hide placeholder in review screen

* Update survey icons

* Remove unused import

* Fix build errors

* Fixes

* Fix errors

* WAITP-1412: Arithmetic question (#5054)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* Add handling for custom display text

* WAITP-1276: Forgot password (#5056)

* Add forgot passowrd view

* Working form

* Add stories

* Fix build

* Set height on forgot password screen

* Reset success screen

* Reorder imports

* WAITP-1345:Core question updates (#5066)

* Allow color to be set on radio options

* Get help text working

* Update SurveyQuestionGroup.tsx

* Update types

* WAITP-1349: Fix DataTrak survey submit (#5078)

* Update surveyResponse.js

* Update surveyResponse.js

* WAITP-1454: design updates (#5079)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* WAITP-1454: Fix sorting of surveys (#5080)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* Fix sorting in folders

* Update FE sorting

* tile component

* Revert "tile component"

This reverts commit 7b612fb.

* WAITP-1454: UI changes (#5089)

* tile component

* Show modal when exiting survey via home button

* Remove unused imports

* Stop menu re-rendering on change of survey screen

* Update button disabled state

* Fix build errors

* Fix tests

* Close side menu on screen change on mobile

* clean up code from another branch

* Update LandingPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 Forward signup route to web config server (#5090)

* WAITP-1377 Forward signup route to web config server

* WAITP-1377 Fixup lint

* WAITP-1449: QR code generator (#5086)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* WIP

* WIP

* WIP

* WIP

* Working qr code

* Fix types

* Update test

* Fix tests

* PR fixes

* WAITP-1415: Photo upload question (#5099)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* no-issue-fix-types-after-merge

* WAITP-1357: Datatrak dashboard survey responses (#5091)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* WAITP-1461: Datatrak design feedback (#5109)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* project select page

* menu ux

* Update useSubmitSurvey.ts

* gps question

* Update index.html

* Update ProjectsRoute.ts

* theming

* Update mui.d.ts

* Update useSubmitSurvey.test.ts

* Update theme.ts

* Update SurveySelectPage.tsx

* Update SurveySelectPage.tsx

* Update useValidationResolver.ts (#5128)

* WAITP-1412: fix arithmetic questions

* one time login flow (#5138)

* WAITP-1354: Leaderboard (#5132)

* no-issue: Add @tupaia/server-utils package (#5121)

* RN-1060: (task) Moved sendEmail to @tupaia/server-utils (#5126)

* RN-1060: (task) Added dashboards/:project/:entity/:dashboard/export route to tupaia-web (#5125)

* WAITP-1354: Leaderboard

* Update copyright

* Update internal email

* Update email filter

* Fix response type

* Update packages/datatrak-web/src/features/Leaderboard/LeaderboardTable.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update background variable

* Update branch name validation script (#5136)

* Update to use new leaderboard model

* Revert "Merge branch 'dev' into waitp-1354-leaderboard"

This reverts commit c2acdbe, reversing
changes made to 747f182.

* Fix types

* Update packages/database/src/modelClasses/SurveyResponse.js

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>

* PR fixes

* Fix error

---------

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>

* WAITP-1356: recent surveys (#5113)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* Frontend layout

* Working request

* Refetch recent surveys on submit

* Fix recent survey request and styling

* Use grid and update heading element

* Remove unnecessary css

* PR fixes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1469: account delete (#5134)

* WIP

* Account deletion

* Update component for section

* Update modals

* Remove forced open state

* Fix types

* fix build error

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Change format

* fix bad merge

* return zeros for rewards

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1330: File upload question type (#5100)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* Working file upload

* Fix build

* Remove unused vars

* Update format of file upload answers

* Update schemas.ts

* Update processSurveyResponse.test.ts

* Update upsertAnswers.js

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1424: Datatrak PrimaryEntity question fix (#5144)

* fix rewards types

* update primary entity question name

* WIP

* Fix success screen layout

* Fix date change issue

* Fix error styling

* Working activity feed

* Tidy ups

* WAITP-1427: Fix survey cancelling (#5148)

* Update CancelSurveyModal.tsx

* tidy up landing page

* fix console errors

* No issue: Only generate QR code when createNew is true

* No issue: Fix tests

* Remove permission group and country from admin panel feed items

* No issue: Fix recent survey layout

* Working pinned posts

* No issue: Login redirect (#5151)

* Redirect to route on login or project select

* Formatting

* Always show user on leaderboard

* WAITP-1478 Single survey response endpoint (#5153)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* WAITP-1478 Update survey response answers to map by question_id

* WAITP-1478 Rename RecentSurveyResponse to SingleSurveyResponse

* WAITP-1478 Rename files

* Fix PR

* Generate types

* Fix styling

* Update Button.tsx

* Fixes

* WAITP-1452: Datatrak-web refactor survey context (#5156)

* Update useLogin.ts

* refactor survey context to be at survey level

* Create migration

* Update types

* Responsive styling (#5158)

* Responsive styling

* Fix padding on mobile

* Handle project id in queries

* Filter user rewards by project id

* Update queries to have projectId as optional param

* Fix bindings

* Update SurveyResponse.js

* Add project column to admin panel

* WAITP-1452: Recent survey response page (#5157)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* useSurveyResponse

* survey review screen

* wip set default values

* set up route

* Update useLogin.ts

* refactor survey context to be at survey level

* remove bad merge

* survey data

* basic working setup

* remove debug changes

* split out paginator

* put page back in survey layout

* refactor layout components

* Update index.ts

* Update SurveyContext.tsx

* Update SurveyReviewSection.tsx

---------

Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>

* Update 20231112212117-AddProjectIdToSurveys-modifies-schema.js

* Add index to migration

* Fix migration

* Fix typo

* Cap survey name length at 50 characters

* WAITP-1490: Datatrak current user context (#5170)

* add current user context

* add error display

* rename context

* WAITP-1431: Fix survey select filter (#5177)

* Update SurveysRoute.ts

* remove tsx extentions

* Update SurveysRoute.ts

* WAITP-1387: Add survey project field (#5172)

* Responsive styling of dashboard leaderboard (#5173)

* Responsive styling of dashboard leaderboard

* Fix type error

* Survey not found error handling (#5160)

* Survey not found error handling

* Reorder imports

* Updates to route

* Fix types

* Remove unused imports

* Error page rename

* Rename page

* no-issue: Fix `location.state` null (#5179)

* extract useFromLocation

* extract `useFromLocation` to own file and use

* WAITP-1474: Update success illustration on DataTrak (#5159)

* generify high-five graphic filename

* update submission success graphic

* define margins along block/inline axes

See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flow_layout/Block_and_inline_layout_in_normal_flow

* success screen fix horizontal overflow

* define survey success image dimen with `rem`

* relabel button ‘Close’ → ‘Return to dashboard’

* Fix package error

* Fix autocomplete validation issue

* Create migration for surveys to project mapping

* WAITP-1431: Update datatrak survey url with country code (#5182)

* add Single Entity Route

* use country url to submit

* fix tests

* make TupaiaWebEntityRequest re-usable

* Update SingleEntityRoute.ts

* update recent surveys and responses routes

* handle recent survey submissions

* Update SurveyResponsesSection.tsx

* update country id in survey page

* remove unused code

* Update processSurveyResponse.test.ts

* Update queries

* Update preferred project on survey load

* Update queries and FE to handle project ids, and add migration for project creation

* Add toast to tell user project has been updated

* Remove unused import

* Remove unused import

* Make migration

* Update migration

* Update projectSurveyMappings.json

* Update migration

* Filter out new empty projects from Tupaia Web frontend

* Fix merge issues

* Remove survey responses when migrating down

* Update mappings

* Add new projects

* Update getSocialFeed.js

* Update SurveyResponse.js

* Update Routes.tsx

* public survey route

* WAITP-1480: survey duplication (#5193)

* Make migration

* Update migration

* Update migration

* Remove survey responses when migrating down

* add survey route

* rename SurveyRoutes

* Update SurveyRoutes.tsx

* add copy button

* handle logged out user submit

* submitAsPublic

* add public user test

* generate types

* update CopySurveyUrlButton

* tweaks

* Update GETSurveyResponses.test.js

* WAITP-1495: Public entity questions (#5219)

* wip public requests

* update datatrak entity routes

* update options set permission check

* Update permissions.test.ts

* Update EntityQuestion.test.tsx

* support use Entity by code and id

* re organise entity routes

* Update useSubmitSurvey.test.ts

* fix front end tests

* fix viewing a submitted survey

* fix login loading

* update datatrak tests

* add login tests

* stub out unhandled responses

* WAITP-1514: DataTrak redirect back after login (#5262)

* fix login loading

* update datatrak tests

* add login tests

* stub out unhandled responses

* fix accessibility features

* Remove duplicate identifier

* Update handling of logged out entity descendents

* Update direct handling

* Working exportable multi value viz

* Generate types

* RN-1069: redirect after login

* Merge

* Global fieldset styles

* Remove extra types package

* Show multiValue titles for legacy reports

* Create constants for types

* Update types

* Fix types

* RN-998: Logo on export (#5330)

* en dash for date range

* another en dash for another date range

* border instead of divider

* code style

* natural casing of heading on PDF exports

* remove redundant `div`

* replace deprecated CSS

* refactor PDF export layout

* code style

* more appropriate vertical alignment

* project logo in export

* update tests to expect en dash

* fix header vertical alignment in PDF export

* clearer comment

* logotype → logo in alt description

Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>

* extract prop to interface

* avoid layout shift

practically speaking, this CLS doesn’t matter because it’s only in PDF exports, but this prevents Lighthouse flagging it as an issue

---------

Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>

* no-issue: README tidy-ups (#5331)

* replace codeship references with GHA

* README tidy-ups

* logo heading

* `code-of-conduct` → `CODE_OF_CONDUCT`

* succinctness

* Markdown markup style

* experiment: `<details>` disclusure element

* fix `details > ul` render

* `<details>` experiment continued

* abandon `<details>` experiment

* unignore Codeship things

* Markdown style

* relative links

* Revert "RN-998: Logo on export"

---------

Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>
Co-authored-by: Rohan Port <rohan@beyondessential.com.au>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>
Co-authored-by: acdunham <alex@beyondessential.com.au>
Co-authored-by: Chao Xin Nhin <122791168+chaoxinnhin@users.noreply.github.com>
Co-authored-by: Wilhelmus Duncker <122330202+WDuncker@users.noreply.github.com>
Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>
Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Jasper Lai <33956381+jaskfla@users.noreply.github.com>
Co-authored-by: RajneelR <132311480+RajneelR@users.noreply.github.com>
Co-authored-by: Andrew <vanbeekandrew@gmail.com>
alexd-bes added a commit that referenced this pull request Jan 25, 2024
* Waitp 1368 datatrak web fe setup (#4875)

* Added skeleton datatrak-server package

* Added datatrak-server to CI/CD

* wip datatrak front end app

* Added api-client to datatrak-server

* Added /projects route to datatrak-server

* disable eslint and re-install dependencies

* Added /entities route to datatrak-server

* add base views and downgrade react

* Update api.js

* Disabled frozen-lockfile

* Reverted yarn.lock

* Re-enabled frozen lockfile

* Add datatrak to CI/CD

* Added /surveys and /surveyScreenComponents routes

* Re-enabled exports of ui-components

* Switched to using pre-existing build and start scripts for datatrak

* add base form components

* Fix datatrak build

* format data to screens

* Got login working

* Added extra fields to FetchSurveyScreenComponents

* Got project and country selection working

* Upated yarn.lock

* Got survey selection working

* Got Survey page working

* screen steps

* add template styling

* add admin route

* Switched to using .env var for server url

* add logout

* Fixed up FetchUserRoute

* Add submitSurveyResponse route

* labels

* Add entity question

* add entity question to screen

* survey submit

* Update yarn.lock

* Update package.json

* remove anything not from fe

* Merge branch 'dev' into datatrak-hackathon

* Remove unused files

* Add initial fetch example

* Update README.md

* Revert change

* Remove unneeded change

* Add back in datatrak-app

* Add .env.example

* Update files

* Remove unnecessary code

* Fixes

* Test remove server setup

* Remove test step

* WAITP-1368: Basic page layout (#4890)

* basic page layout

* styles

* use theme colours

---------

Co-authored-by: Rohan Port <rohan@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1367 DataTrak Server (#4902)

* WAITP-1367 Add datatrak_session table to db

* WAITP-1367 Add request type for datatrak user request

* WAITP-1367 Add datatrak-server package

* WAITP-1367 Regenerate yarn.lock

* WAITP-1367 Fix minor copy-paste errors

* WAITP-1367 Add datatrak_session to ignored tables for hooks

* WAITP-1367 Add datatrak-server to server startup script in datatrak-web

* WAITP-1367 Add datatrak-server to CI/CD scripts

* WAITP-1367 Reduce layer count in dockerfile

* WAITP-1367 Regenerate types

* WAITP-1367 Regnerate types (again)

* WAITP-1367 Fixup clashing exports

* WAITP-1367 Rebalance test batching

* WAITP-1367: Rename datatrak-server to datatrak-web-server (#4904)

* find and replace

* rename package

* Update tupaia-ci-cd.Dockerfile

* update types

* Generate types

* Revert "Generate types"

This reverts commit 6fbbec6.

* WAITP-1277 datatrak-web login form part 1 (#4899)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* Update private routes and fix build

* Fix type errors

* Fix types

* Generate types

* Revert "Generate types"

This reverts commit de0fb64.

* Create private route

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 register page (#4903)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Update storybook

* Fix storybook

* Add pages to datatrak-web and mobile styling

* Fixes

* Fix route names

* Update private routes and fix build

* Fix height

* Fix type errors

* Fix types

* Generate types

* Revert "Generate types"

This reverts commit de0fb64.

* Create private route

* Fix build

* Fix casing

* Fix build error

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1379: select survey (#4925)

* Initial landing page

* Working survey select

* Fix type errors

* WAITP-1411: Setup datatrak survey screens (#4920)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* fix types

* scrren layout

* refactor context

* tidy up css

* resolve conflicts

* Update merge

* Update useSurveyScreenComponents.tsx

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* Fix circular types error

* Fix route

* Test types generate

* revert generate changes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1417 top progress bar (#4923)

* Started on progress bar commit

* added more styling and changed logic

* designed logic for progress bar

* fixed progress bar colour

* fixed pr

* ready for retest

* Added to survey page

* cleaned a few things

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1345: core question types (#4930)

* Text question

* Binary and radio questions

* Update types

* ƒix option parsing

* Date question

* Update question number logic

* Instruction question

* Update index.ts

* Handle review screen

* Fix date styles

* Update text field width

* Update line height

* Add types

* remove question number for now

* Checkbox question and styling

* Checkbox question

* Add comment

* DateTimeQuestion

* Add controller around all questions

* Add in question number

* Reorder imports

* Handle more than 26 questions on a screen

* Update casing.ts

* Fix imports

* Fixes and generate types

* Fix merge and question number logic

* Fix props

* yarn generate

* yarn generate

* WAITP-1428: datatrak design updates (#4949)

* Auth updates part 1

* Auth view

* Survey screen

* Tooltip buttons

* Use theme variable

* Update theme variable for primary text

* Auth layout

* Move styles into common form files

* Fix layout padding

* Update layout

* Update SurveySelectPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1414 code generator hints (#4944)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* Initial landing page

* fix types

* scrren layout

* refactor context

* Working survey select

* tidy up css

* resolve conflicts

* Fix type errors

* Update merge

* Update useSurveyScreenComponents.tsx

* work in progress

* need testing

* quick fix

* styling commit

* few pr changes

* changed folder locations

* fixed imports and exports

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1346: Survey contents menu (#4958)

* Working menu

* Remove unused import

* Fixes

* WAITP-1350: Cancel survey workflow (#4964)

* WAITP-1327: Geolocate question type (#4917)

* WIP on geolocation question

* Pushing to remote for pairing

* updates to map pin drop functionality and ui

* tidying up unused imports and redundant components

* Fixes part 1

* Updates

* Fixes

---------

Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: acdunham <alex@beyondessential.com.au>

* Waitp 1427 survey submit success screen (#4965)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Fixes

* Fix types

* remove questions url

* Fix types

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* update ci cd with datatrak web

* add stub test

* WAITP-1407: Datatrak project select (#4950)

* project select modal

* save project id for a user

* fix types

* Update ProjectSelectPage.tsx

* edit project

* Update ProjectSelectPage.tsx

* Update ProjectSelectModal.tsx

* custom icons

* pr changes

* request access styles

* request access on click

* update types

* WAITP-1439: Survey review screen (#4985)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Review screen

* Initial mutation

* Tidy up files

* Fixes

* Update SurveyLayout.tsx

---------

Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1410: Request project access (#4997)

* Working request access

* Add access requested icon to project list

* Add 'EditUserForMe' endpoint

* Remove all countries requested view

* Refactor select list

* Fix on select issue

* Don't have onClick if is not a button

* Generate types

* Fixes

* Update types

* WAITP-1429: Autocomplete question (#5010)

* WIP

* Finish styling and get working

* Update styles

* Update font size

* Update hover colour

* Update packages/datatrak-web/src/features/Questions/AutocompleteQuestion.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1413: Datatrak Web Entity Question (#4996)

* setup entities question

* searching

* debounce

* styles

* close button

* sorting search results

* update filters

* remove old entity route

* fix filters

* fix types

* Update EntityList.js

* Update EntitiesRoute.ts

* refactor to match new list component

* Update useUser.ts

* add mock api with msw (#5019)

* WAITP-1437 toast messages (#5015)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Fixes

* Fix build errors and merge conflicts

* Fix error

* Fix broken test

* WAITP-1407: Add support for user preferences to user accounts (#5023)

* migration

* saving user preferences

* add validation to edit user endpoint

* fix tests

* WAITP-1431: Select country (#5026)

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Add country name to survey toolbar

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* Generate types

* Update schemas.ts

* Fixes

* Reorganise files

* Fix build errors

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1423: Primary entity question (#5027)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Fixes

* Fix build errors and merge conflicts

* Add country name to survey toolbar

* setup submit

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* move mocks

* primary entity handling

* Generate types

* Update schemas.ts

* attributes filter

* use country data

* Fixes

* Reorganise files

* Fix build errors

* update survey data key

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1369 Setup datatrak deployment (#5031)

* WAITP-1369 Add datatrak to servers.conf and subdomain suffixes

* WAITP-1369 Regenerate types

* WAITP-1369 Regen yarn.lock

* WAITP-1369 Fixup entity-server test

* WAITP-1369 Fixup usage of entity request type

* WAITP-1369 Remove broken include

* WAITP-1369 Regen types

* WAITP-1369 Fixup unit test

* Update tsconfig-build for datatrak-web-server

* no-issue-dedupe-react-router-dom

* WAITP-1349: Survey submit (#5032)

* Working survey submit

* Only show repeat survey button when canRepeat is true

* Fix todos

* Add loader

* Add coconut notification

* Tidy up

* Fix variable names

* Fix types

* Reorder imports

* Fix build error

* No issue: add test runner to datatrak-web (#5034)

* setup test runner

* add example survey

* change import meta to process env

* update survey test

* Update survey.test.tsx

* WAITP-1429: Autocomplete add and filtering of options (#5040)

* Enable create new option and filter options

* Tidy up code

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Update packages/datatrak-web/src/__tests__/features/Questions/AutocompleteQuestion.test.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Fix types

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1416: Visibility criteria (#5044)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* WAITP-1440: Mobile styling (#5042)

* WIP mobile styling

* WIP

* Fix project button styling

* Fix types

* Mobile app prompt

* Fix dashboard button styling

* WAITP-1347: Validation criteria (#5047)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Working validation

* Working validation

* Fix autocomplete styling

* Fix autocomplete issue

* Extract getRules function

* Fix typo

* No issue: Update survey screen fetching (#5050)

* Update get surveys endpoint

* Change to using surveys endpoint

* Fix types and visible question logic

* Remove old route

* Fix types and tests

* Generate types

* WAITP-1424: Entity question upserts (#5045)

* Enable create new option and filter options

* Tidy up code

* add filter prop

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Submit Survey route

* Update useSubmitSurvey.ts

* add entities upserted

* update test suite

* fix bad merge

* update types

* set country in upsert entity

* Update schemas.ts

* fix up types

* fix tests

* fix schema

* fix tests

* wip refactor form submission

* move tests to server

* generate schemas

* fix entity test

* Update render.tsx

* Update useSubmitSurvey.test.ts

* Update render.tsx

* reuse survey request types

* Update schemas.ts

* fix question types

* fix types

* Update schemas.ts

* optional screen id

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1430: condition question (#5049)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Fix tests and build

* WAITP-1453: UI updates (#5052)

* Handle location errors

* Fix redirect issue for requesting access

* Add tooltip delay

* Add delay on mobile devices

* Tidy tooltip props code

* Update popovers

* Update header heights

* Update number field width

* Make text inputs multiline when text wraps

* Make radio labels full width

* Clip side menu item length

* Center instruction only screens

* Remove horizontal centering

* Hide placeholder in review screen

* Update survey icons

* Remove unused import

* Fix build errors

* Fixes

* Fix errors

* WAITP-1412: Arithmetic question (#5054)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* Add handling for custom display text

* WAITP-1276: Forgot password (#5056)

* Add forgot passowrd view

* Working form

* Add stories

* Fix build

* Set height on forgot password screen

* Reset success screen

* Reorder imports

* WAITP-1345:Core question updates (#5066)

* Allow color to be set on radio options

* Get help text working

* Update SurveyQuestionGroup.tsx

* Update types

* WAITP-1349: Fix DataTrak survey submit (#5078)

* Update surveyResponse.js

* Update surveyResponse.js

* WAITP-1454: design updates (#5079)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* WAITP-1454: Fix sorting of surveys (#5080)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* Fix sorting in folders

* Update FE sorting

* tile component

* Revert "tile component"

This reverts commit 7b612fb.

* WAITP-1454: UI changes (#5089)

* tile component

* Show modal when exiting survey via home button

* Remove unused imports

* Stop menu re-rendering on change of survey screen

* Update button disabled state

* Fix build errors

* Fix tests

* Close side menu on screen change on mobile

* clean up code from another branch

* Update LandingPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 Forward signup route to web config server (#5090)

* WAITP-1377 Forward signup route to web config server

* WAITP-1377 Fixup lint

* WAITP-1449: QR code generator (#5086)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* WIP

* WIP

* WIP

* WIP

* Working qr code

* Fix types

* Update test

* Fix tests

* PR fixes

* WAITP-1415: Photo upload question (#5099)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* no-issue-fix-types-after-merge

* WAITP-1357: Datatrak dashboard survey responses (#5091)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* WAITP-1461: Datatrak design feedback (#5109)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* project select page

* menu ux

* Update useSubmitSurvey.ts

* gps question

* Update index.html

* Update ProjectsRoute.ts

* theming

* Update mui.d.ts

* Update useSubmitSurvey.test.ts

* Update theme.ts

* Update SurveySelectPage.tsx

* Update SurveySelectPage.tsx

* Update useValidationResolver.ts (#5128)

* WAITP-1412: fix arithmetic questions

* one time login flow (#5138)

* WAITP-1354: Leaderboard (#5132)

* no-issue: Add @tupaia/server-utils package (#5121)

* RN-1060: (task) Moved sendEmail to @tupaia/server-utils (#5126)

* RN-1060: (task) Added dashboards/:project/:entity/:dashboard/export route to tupaia-web (#5125)

* WAITP-1354: Leaderboard

* Update copyright

* Update internal email

* Update email filter

* Fix response type

* Update packages/datatrak-web/src/features/Leaderboard/LeaderboardTable.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update background variable

* Update branch name validation script (#5136)

* Update to use new leaderboard model

* Revert "Merge branch 'dev' into waitp-1354-leaderboard"

This reverts commit c2acdbe, reversing
changes made to 747f182.

* Fix types

* Update packages/database/src/modelClasses/SurveyResponse.js

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>

* PR fixes

* Fix error

---------

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>

* WAITP-1356: recent surveys (#5113)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* Frontend layout

* Working request

* Refetch recent surveys on submit

* Fix recent survey request and styling

* Use grid and update heading element

* Remove unnecessary css

* PR fixes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1469: account delete (#5134)

* WIP

* Account deletion

* Update component for section

* Update modals

* Remove forced open state

* Fix types

* fix build error

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Change format

* fix bad merge

* return zeros for rewards

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1330: File upload question type (#5100)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* Working file upload

* Fix build

* Remove unused vars

* Update format of file upload answers

* Update schemas.ts

* Update processSurveyResponse.test.ts

* Update upsertAnswers.js

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1424: Datatrak PrimaryEntity question fix (#5144)

* fix rewards types

* update primary entity question name

* WIP

* Fix success screen layout

* Fix date change issue

* Fix error styling

* Working activity feed

* Tidy ups

* WAITP-1427: Fix survey cancelling (#5148)

* Update CancelSurveyModal.tsx

* tidy up landing page

* fix console errors

* No issue: Only generate QR code when createNew is true

* No issue: Fix tests

* Remove permission group and country from admin panel feed items

* No issue: Fix recent survey layout

* Working pinned posts

* No issue: Login redirect (#5151)

* Redirect to route on login or project select

* Formatting

* Always show user on leaderboard

* WAITP-1478 Single survey response endpoint (#5153)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* WAITP-1478 Update survey response answers to map by question_id

* WAITP-1478 Rename RecentSurveyResponse to SingleSurveyResponse

* WAITP-1478 Rename files

* Fix PR

* Generate types

* Fix styling

* Update Button.tsx

* Fixes

* WAITP-1452: Datatrak-web refactor survey context (#5156)

* Update useLogin.ts

* refactor survey context to be at survey level

* Create migration

* Update types

* Responsive styling (#5158)

* Responsive styling

* Fix padding on mobile

* Handle project id in queries

* Filter user rewards by project id

* Update queries to have projectId as optional param

* Fix bindings

* Update SurveyResponse.js

* Add project column to admin panel

* WAITP-1452: Recent survey response page (#5157)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* useSurveyResponse

* survey review screen

* wip set default values

* set up route

* Update useLogin.ts

* refactor survey context to be at survey level

* remove bad merge

* survey data

* basic working setup

* remove debug changes

* split out paginator

* put page back in survey layout

* refactor layout components

* Update index.ts

* Update SurveyContext.tsx

* Update SurveyReviewSection.tsx

---------

Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>

* Update 20231112212117-AddProjectIdToSurveys-modifies-schema.js

* Add index to migration

* Fix migration

* Fix typo

* Cap survey name length at 50 characters

* WAITP-1490: Datatrak current user context (#5170)

* add current user context

* add error display

* rename context

* WAITP-1431: Fix survey select filter (#5177)

* Update SurveysRoute.ts

* remove tsx extentions

* Update SurveysRoute.ts

* WAITP-1387: Add survey project field (#5172)

* Responsive styling of dashboard leaderboard (#5173)

* Responsive styling of dashboard leaderboard

* Fix type error

* Survey not found error handling (#5160)

* Survey not found error handling

* Reorder imports

* Updates to route

* Fix types

* Remove unused imports

* Error page rename

* Rename page

* no-issue: Fix `location.state` null (#5179)

* extract useFromLocation

* extract `useFromLocation` to own file and use

* Validate related questions are mandatory

* Use parent id for entity question if parent id question is not filled in

* Update packages/central-server/src/apiV2/import/importSurveys/Validator/ConfigValidator/EntityConfigValidator.js

Co-authored-by: Tom Caiger <caigertom@gmail.com>

---------

Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>
Co-authored-by: Rohan Port <rohan@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>
Co-authored-by: Chao Xin Nhin <122791168+chaoxinnhin@users.noreply.github.com>
Co-authored-by: Wilhelmus Duncker <122330202+WDuncker@users.noreply.github.com>
Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>
Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Jasper Lai <33956381+jaskfla@users.noreply.github.com>
Co-authored-by: Andrew <vanbeekandrew@gmail.com>
jaskfla added a commit that referenced this pull request Feb 19, 2024
* tile component

* Revert "tile component"

This reverts commit 7b612fb.

* WAITP-1454: UI changes (#5089)

* tile component

* Show modal when exiting survey via home button

* Remove unused imports

* Stop menu re-rendering on change of survey screen

* Update button disabled state

* Fix build errors

* Fix tests

* Close side menu on screen change on mobile

* clean up code from another branch

* Update LandingPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 Forward signup route to web config server (#5090)

* WAITP-1377 Forward signup route to web config server

* WAITP-1377 Fixup lint

* WAITP-1449: QR code generator (#5086)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* WIP

* WIP

* WIP

* WIP

* Working qr code

* Fix types

* Update test

* Fix tests

* PR fixes

* WAITP-1415: Photo upload question (#5099)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* no-issue-fix-types-after-merge

* WAITP-1357: Datatrak dashboard survey responses (#5091)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* WAITP-1461: Datatrak design feedback (#5109)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* project select page

* menu ux

* Update useSubmitSurvey.ts

* gps question

* Update index.html

* Update ProjectsRoute.ts

* theming

* Update mui.d.ts

* Update useSubmitSurvey.test.ts

* Update theme.ts

* Update SurveySelectPage.tsx

* Update SurveySelectPage.tsx

* Update useValidationResolver.ts (#5128)

* WAITP-1412: fix arithmetic questions

* one time login flow (#5138)

* WAITP-1354: Leaderboard (#5132)

* no-issue: Add @tupaia/server-utils package (#5121)

* RN-1060: (task) Moved sendEmail to @tupaia/server-utils (#5126)

* RN-1060: (task) Added dashboards/:project/:entity/:dashboard/export route to tupaia-web (#5125)

* WAITP-1354: Leaderboard

* Update copyright

* Update internal email

* Update email filter

* Fix response type

* Update packages/datatrak-web/src/features/Leaderboard/LeaderboardTable.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update background variable

* Update branch name validation script (#5136)

* Update to use new leaderboard model

* Revert "Merge branch 'dev' into waitp-1354-leaderboard"

This reverts commit c2acdbe, reversing
changes made to 747f182.

* Fix types

* Update packages/database/src/modelClasses/SurveyResponse.js

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>

* PR fixes

* Fix error

---------

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>

* WAITP-1356: recent surveys (#5113)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* Frontend layout

* Working request

* Refetch recent surveys on submit

* Fix recent survey request and styling

* Use grid and update heading element

* Remove unnecessary css

* PR fixes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1469: account delete (#5134)

* WIP

* Account deletion

* Update component for section

* Update modals

* Remove forced open state

* Fix types

* fix build error

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Change format

* fix bad merge

* return zeros for rewards

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1330: File upload question type (#5100)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* Working file upload

* Fix build

* Remove unused vars

* Update format of file upload answers

* Update schemas.ts

* Update processSurveyResponse.test.ts

* Update upsertAnswers.js

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1424: Datatrak PrimaryEntity question fix (#5144)

* fix rewards types

* update primary entity question name

* WIP

* Fix success screen layout

* Fix date change issue

* Fix error styling

* Working activity feed

* Tidy ups

* WAITP-1427: Fix survey cancelling (#5148)

* Update CancelSurveyModal.tsx

* tidy up landing page

* fix console errors

* No issue: Only generate QR code when createNew is true

* No issue: Fix tests

* Remove permission group and country from admin panel feed items

* No issue: Fix recent survey layout

* Working pinned posts

* No issue: Login redirect (#5151)

* Redirect to route on login or project select

* Formatting

* Always show user on leaderboard

* WAITP-1478 Single survey response endpoint (#5153)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* WAITP-1478 Update survey response answers to map by question_id

* WAITP-1478 Rename RecentSurveyResponse to SingleSurveyResponse

* WAITP-1478 Rename files

* Fix PR

* Generate types

* Fix styling

* Update Button.tsx

* Fixes

* WAITP-1452: Datatrak-web refactor survey context (#5156)

* Update useLogin.ts

* refactor survey context to be at survey level

* Create migration

* Update types

* Responsive styling (#5158)

* Responsive styling

* Fix padding on mobile

* sentnece case for heading

to match Figma (and Material Design style guide)

* Handle project id in queries

* enforce min gap in `AccountSettingsSection`

* user details form GUI

* Filter user rewards by project id

* two-column form in medium size class

* dim colour for `AccountSettingsSection` desc

* Update queries to have projectId as optional param

* prepopulate email in account settings

also move `const` declarations into `export`

* Fix bindings

* Update SurveyResponse.js

* Add project column to admin panel

* separate first/last names for UserRoute

* prepopulate first/last names in account settings

* WAITP-1452: Recent survey response page (#5157)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* useSurveyResponse

* survey review screen

* wip set default values

* set up route

* Update useLogin.ts

* refactor survey context to be at survey level

* remove bad merge

* survey data

* basic working setup

* remove debug changes

* split out paginator

* put page back in survey layout

* refactor layout components

* Update index.ts

* Update SurveyContext.tsx

* Update SurveyReviewSection.tsx

---------

Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>

* nest children instead of passing as prop

* Update 20231112212117-AddProjectIdToSurveys-modifies-schema.js

* Add index to migration

* Fix migration

* Fix typo

* Cap survey name length at 50 characters

* remove redundant nesting selector

* non-hacky label colouring in personal detail form

* `firstName`/`lastName` properties in user req body

* prepopulate contact no., employer, position

* remove faulty tooltip usage

* set ‘Save changes’ button initially disabled

* more sensible property ordering

* WAITP-1490: Datatrak current user context (#5170)

* add current user context

* add error display

* rename context

* make personal detail fields editable

* autofill attributes for employer and position

* use `useCurrentUser`

* use state for field values

* label font weight from theme

* Revert “use state for field values”

This reverts commit cc44f1b.

* make email uneditable in account settings

* wip: React Hook Form for personal details

* WAITP-1431: Fix survey select filter (#5177)

* Update SurveysRoute.ts

* remove tsx extentions

* Update SurveysRoute.ts

* WAITP-1387: Add survey project field (#5172)

* Responsive styling of dashboard leaderboard (#5173)

* Responsive styling of dashboard leaderboard

* Fix type error

* Survey not found error handling (#5160)

* Survey not found error handling

* Reorder imports

* Updates to route

* Fix types

* Remove unused imports

* Error page rename

* Rename page

* no-issue: Fix `location.state` null (#5179)

* extract useFromLocation

* extract `useFromLocation` to own file and use

* use React Hook Form `required` property

* make personal details fields controlled

* fix user details save button alignment

* clearer comment

* button tooltip only when form is dirty

* full width user detail save button

* Enter key hints for user details on mobile

* `tel` input mode for contact number field

* make PUT request to change user details

* WAITP-1474: Update success illustration on DataTrak (#5159)

* generify high-five graphic filename

* update submission success graphic

* define margins along block/inline axes

See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flow_layout/Block_and_inline_layout_in_normal_flow

* success screen fix horizontal overflow

* define survey success image dimen with `rem`

* relabel button ‘Close’ → ‘Return to dashboard’

* fix `mobileNumber` field in `UserRequest.ts`

* Fix package error

* Fix autocomplete validation issue

* fix fetching contact number

* use React Hook Form to set default field values

* optional `PersonalDetails` & remove unused import

* fix fetching contact number (again)

* WAITP-1431: Update datatrak survey url with country code (#5182)

* add Single Entity Route

* use country url to submit

* fix tests

* make TupaiaWebEntityRequest re-usable

* Update SingleEntityRoute.ts

* update recent surveys and responses routes

* handle recent survey submissions

* Update SurveyResponsesSection.tsx

* update country id in survey page

* remove unused code

* Update processSurveyResponse.test.ts

* WAITP-1496 Make questions optional in GETSurveys (#5185)

* WAITP-1496 Simple skip for join tables in GETSurveys

* WAITP-1496 Default to true

* WAITP-1496 Request questions in single survey route

* WAITP-1496 Add countryNames to surveys request

* user details: update only changed fields

* toast upon successful user detail change

* fix build errors

* fix typing issue

* shared type, success toast only when appropriate

previously, success toast would redundantly show when account deletion request was successfully made

* stricter typing of submit handler parameter

* refactor creation of dirty-field-only object

* email form field tooltip

* use shorthand to pass details to submit handler

* Apply suggestions from code review

specify `email` and `tel` input types

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* organise imports

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* uncontrolled personal details form

* more readable submit handler

* consolidate form default values

and disable save button when submitting

* reword success toast to match Figma

* un-require mobile number

* register mobile number field

* narrow typing of form `defaultValues`

* wip: reset personal details form

* remove extraneous logs

* fix input label layering

* wip: reset form

* dynamically label save button

* async-ify `updateUser`

* revert `useEditUser` signature change

* don’t await query invalidation

* restore previous `onSuccess`

* custom validation UI (and extract form component)

* organise file structure

* organise imports

* disable form while submitting

* fix form sizing

* extract inline `onSuccess` handler to named fn

* remove extraneous `export`

* fix dynamic button label

* relabel save button while submitting

* fix form width in medium size class

* actually fix form width in medium size class

* omit ellipsis in button

* more rigorous form validation

* don’t bother registering `email` field

* sanitise values by trimming

* enable complete removal of `mobile_number`

* remove extraneous log

Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>

* remove another extraneous log

Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>

* extract `assertNotWhitespace()`

* fix usage before definition

* extract non-whitespace assersion

* inline comments for submit handler

* conciser comment and trivial line reordering

* experiment: `required="non-whitespace"`

* code format

* more consistent code format

* remove commented-out code

* make inputs more accessible with `id` prop

also moved placement of a comment for clarity

* Revert "make inputs more accessible with `id` prop"

This reverts commit dfa3455.

* make inputs more accessible with `id` prop

also moved placement of a comment for clarity

* `div` → `Box`

* fix button alignment on mobile

* stricter typing for current user

* autofocus first field

* trim to validate iff input type ≠ password

and stricter typing

* remove dead code/comments

* remove extraneous ESLint comment

* rename a variable for consistency

* DRY up `fieldset` reset styles

* fix unobscured password fields

* fix registration T&C checkbox

* comment React Hook Form `validate` quirks

* finish merge from `dev`

* delete accidentally committed file

* fix import order

* destructure a variable

* move `formContext` definition

* comment `FormInput`

* fix registration checkbox behaviour

* better typing

* fix typo

* more explicit inline comment

* unify disabled button styling

* don’t disable registratino button

* refactor to avoid `reduce()`

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: acdunham <alex@beyondessential.com.au>
Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>
Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>
Co-authored-by: Andrew <vanbeekandrew@gmail.com>
alexd-bes added a commit that referenced this pull request Mar 10, 2024
* WAITP-1428: datatrak design updates (#4949)

* Auth updates part 1

* Auth view

* Survey screen

* Tooltip buttons

* Use theme variable

* Update theme variable for primary text

* Auth layout

* Move styles into common form files

* Fix layout padding

* Update layout

* Update SurveySelectPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1414 code generator hints (#4944)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* Initial landing page

* fix types

* scrren layout

* refactor context

* Working survey select

* tidy up css

* resolve conflicts

* Fix type errors

* Update merge

* Update useSurveyScreenComponents.tsx

* work in progress

* need testing

* quick fix

* styling commit

* few pr changes

* changed folder locations

* fixed imports and exports

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1346: Survey contents menu (#4958)

* Working menu

* Remove unused import

* Fixes

* WAITP-1350: Cancel survey workflow (#4964)

* WAITP-1327: Geolocate question type (#4917)

* WIP on geolocation question

* Pushing to remote for pairing

* updates to map pin drop functionality and ui

* tidying up unused imports and redundant components

* Fixes part 1

* Updates

* Fixes

---------

Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: acdunham <alex@beyondessential.com.au>

* Waitp 1427 survey submit success screen (#4965)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Fixes

* Fix types

* remove questions url

* Fix types

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* update ci cd with datatrak web

* add stub test

* WAITP-1407: Datatrak project select (#4950)

* project select modal

* save project id for a user

* fix types

* Update ProjectSelectPage.tsx

* edit project

* Update ProjectSelectPage.tsx

* Update ProjectSelectModal.tsx

* custom icons

* pr changes

* request access styles

* request access on click

* update types

* WAITP-1439: Survey review screen (#4985)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Review screen

* Initial mutation

* Tidy up files

* Fixes

* Update SurveyLayout.tsx

---------

Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1410: Request project access (#4997)

* Working request access

* Add access requested icon to project list

* Add 'EditUserForMe' endpoint

* Remove all countries requested view

* Refactor select list

* Fix on select issue

* Don't have onClick if is not a button

* Generate types

* Fixes

* Update types

* WAITP-1429: Autocomplete question (#5010)

* WIP

* Finish styling and get working

* Update styles

* Update font size

* Update hover colour

* Update packages/datatrak-web/src/features/Questions/AutocompleteQuestion.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1413: Datatrak Web Entity Question (#4996)

* setup entities question

* searching

* debounce

* styles

* close button

* sorting search results

* update filters

* remove old entity route

* fix filters

* fix types

* Update EntityList.js

* Update EntitiesRoute.ts

* refactor to match new list component

* Update useUser.ts

* add mock api with msw (#5019)

* WAITP-1437 toast messages (#5015)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Fixes

* Fix build errors and merge conflicts

* Fix error

* Fix broken test

* WAITP-1407: Add support for user preferences to user accounts (#5023)

* migration

* saving user preferences

* add validation to edit user endpoint

* fix tests

* WAITP-1431: Select country (#5026)

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Add country name to survey toolbar

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* Generate types

* Update schemas.ts

* Fixes

* Reorganise files

* Fix build errors

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1423: Primary entity question (#5027)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Fixes

* Fix build errors and merge conflicts

* Add country name to survey toolbar

* setup submit

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* move mocks

* primary entity handling

* Generate types

* Update schemas.ts

* attributes filter

* use country data

* Fixes

* Reorganise files

* Fix build errors

* update survey data key

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1369 Setup datatrak deployment (#5031)

* WAITP-1369 Add datatrak to servers.conf and subdomain suffixes

* WAITP-1369 Regenerate types

* WAITP-1369 Regen yarn.lock

* WAITP-1369 Fixup entity-server test

* WAITP-1369 Fixup usage of entity request type

* WAITP-1369 Remove broken include

* WAITP-1369 Regen types

* WAITP-1369 Fixup unit test

* Update tsconfig-build for datatrak-web-server

* no-issue-dedupe-react-router-dom

* WAITP-1349: Survey submit (#5032)

* Working survey submit

* Only show repeat survey button when canRepeat is true

* Fix todos

* Add loader

* Add coconut notification

* Tidy up

* Fix variable names

* Fix types

* Reorder imports

* Fix build error

* No issue: add test runner to datatrak-web (#5034)

* setup test runner

* add example survey

* change import meta to process env

* update survey test

* Update survey.test.tsx

* WAITP-1429: Autocomplete add and filtering of options (#5040)

* Enable create new option and filter options

* Tidy up code

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Update packages/datatrak-web/src/__tests__/features/Questions/AutocompleteQuestion.test.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Fix types

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1416: Visibility criteria (#5044)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* WAITP-1440: Mobile styling (#5042)

* WIP mobile styling

* WIP

* Fix project button styling

* Fix types

* Mobile app prompt

* Fix dashboard button styling

* WAITP-1347: Validation criteria (#5047)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Working validation

* Working validation

* Fix autocomplete styling

* Fix autocomplete issue

* Extract getRules function

* Fix typo

* No issue: Update survey screen fetching (#5050)

* Update get surveys endpoint

* Change to using surveys endpoint

* Fix types and visible question logic

* Remove old route

* Fix types and tests

* Generate types

* WAITP-1424: Entity question upserts (#5045)

* Enable create new option and filter options

* Tidy up code

* add filter prop

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Submit Survey route

* Update useSubmitSurvey.ts

* add entities upserted

* update test suite

* fix bad merge

* update types

* set country in upsert entity

* Update schemas.ts

* fix up types

* fix tests

* fix schema

* fix tests

* wip refactor form submission

* move tests to server

* generate schemas

* fix entity test

* Update render.tsx

* Update useSubmitSurvey.test.ts

* Update render.tsx

* reuse survey request types

* Update schemas.ts

* fix question types

* fix types

* Update schemas.ts

* optional screen id

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1430: condition question (#5049)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Fix tests and build

* WAITP-1453: UI updates (#5052)

* Handle location errors

* Fix redirect issue for requesting access

* Add tooltip delay

* Add delay on mobile devices

* Tidy tooltip props code

* Update popovers

* Update header heights

* Update number field width

* Make text inputs multiline when text wraps

* Make radio labels full width

* Clip side menu item length

* Center instruction only screens

* Remove horizontal centering

* Hide placeholder in review screen

* Update survey icons

* Remove unused import

* Fix build errors

* Fixes

* Fix errors

* WAITP-1412: Arithmetic question (#5054)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* Add handling for custom display text

* WAITP-1276: Forgot password (#5056)

* Add forgot passowrd view

* Working form

* Add stories

* Fix build

* Set height on forgot password screen

* Reset success screen

* Reorder imports

* WAITP-1345:Core question updates (#5066)

* Allow color to be set on radio options

* Get help text working

* Update SurveyQuestionGroup.tsx

* Update types

* WAITP-1349: Fix DataTrak survey submit (#5078)

* Update surveyResponse.js

* Update surveyResponse.js

* WAITP-1454: design updates (#5079)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* WAITP-1454: Fix sorting of surveys (#5080)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* Fix sorting in folders

* Update FE sorting

* tile component

* Revert "tile component"

This reverts commit 7b612fb.

* WAITP-1454: UI changes (#5089)

* tile component

* Show modal when exiting survey via home button

* Remove unused imports

* Stop menu re-rendering on change of survey screen

* Update button disabled state

* Fix build errors

* Fix tests

* Close side menu on screen change on mobile

* clean up code from another branch

* Update LandingPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 Forward signup route to web config server (#5090)

* WAITP-1377 Forward signup route to web config server

* WAITP-1377 Fixup lint

* WAITP-1449: QR code generator (#5086)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* WIP

* WIP

* WIP

* WIP

* Working qr code

* Fix types

* Update test

* Fix tests

* PR fixes

* WAITP-1415: Photo upload question (#5099)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* no-issue-fix-types-after-merge

* WAITP-1357: Datatrak dashboard survey responses (#5091)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* WAITP-1461: Datatrak design feedback (#5109)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* project select page

* menu ux

* Update useSubmitSurvey.ts

* gps question

* Update index.html

* Update ProjectsRoute.ts

* theming

* Update mui.d.ts

* Update useSubmitSurvey.test.ts

* Update theme.ts

* Update SurveySelectPage.tsx

* Update SurveySelectPage.tsx

* Update useValidationResolver.ts (#5128)

* WAITP-1412: fix arithmetic questions

* one time login flow (#5138)

* WAITP-1354: Leaderboard (#5132)

* no-issue: Add @tupaia/server-utils package (#5121)

* RN-1060: (task) Moved sendEmail to @tupaia/server-utils (#5126)

* RN-1060: (task) Added dashboards/:project/:entity/:dashboard/export route to tupaia-web (#5125)

* WAITP-1354: Leaderboard

* Update copyright

* Update internal email

* Update email filter

* Fix response type

* Update packages/datatrak-web/src/features/Leaderboard/LeaderboardTable.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update background variable

* Update branch name validation script (#5136)

* Update to use new leaderboard model

* Revert "Merge branch 'dev' into waitp-1354-leaderboard"

This reverts commit c2acdbe, reversing
changes made to 747f182.

* Fix types

* Update packages/database/src/modelClasses/SurveyResponse.js

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>

* PR fixes

* Fix error

---------

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>

* WAITP-1356: recent surveys (#5113)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* Frontend layout

* Working request

* Refetch recent surveys on submit

* Fix recent survey request and styling

* Use grid and update heading element

* Remove unnecessary css

* PR fixes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1469: account delete (#5134)

* WIP

* Account deletion

* Update component for section

* Update modals

* Remove forced open state

* Fix types

* fix build error

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Change format

* fix bad merge

* return zeros for rewards

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1330: File upload question type (#5100)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* Working file upload

* Fix build

* Remove unused vars

* Update format of file upload answers

* Update schemas.ts

* Update processSurveyResponse.test.ts

* Update upsertAnswers.js

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1424: Datatrak PrimaryEntity question fix (#5144)

* fix rewards types

* update primary entity question name

* WIP

* Fix success screen layout

* Fix date change issue

* Fix error styling

* Working activity feed

* Tidy ups

* WAITP-1427: Fix survey cancelling (#5148)

* Update CancelSurveyModal.tsx

* tidy up landing page

* fix console errors

* No issue: Only generate QR code when createNew is true

* No issue: Fix tests

* Remove permission group and country from admin panel feed items

* No issue: Fix recent survey layout

* Working pinned posts

* No issue: Login redirect (#5151)

* Redirect to route on login or project select

* Formatting

* Always show user on leaderboard

* WAITP-1478 Single survey response endpoint (#5153)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* WAITP-1478 Update survey response answers to map by question_id

* WAITP-1478 Rename RecentSurveyResponse to SingleSurveyResponse

* WAITP-1478 Rename files

* Fix PR

* Generate types

* Fix styling

* Update Button.tsx

* Fixes

* WAITP-1452: Datatrak-web refactor survey context (#5156)

* Update useLogin.ts

* refactor survey context to be at survey level

* Create migration

* Update types

* Responsive styling (#5158)

* Responsive styling

* Fix padding on mobile

* Handle project id in queries

* Filter user rewards by project id

* Update queries to have projectId as optional param

* Fix bindings

* Update SurveyResponse.js

* Add project column to admin panel

* WAITP-1452: Recent survey response page (#5157)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* useSurveyResponse

* survey review screen

* wip set default values

* set up route

* Update useLogin.ts

* refactor survey context to be at survey level

* remove bad merge

* survey data

* basic working setup

* remove debug changes

* split out paginator

* put page back in survey layout

* refactor layout components

* Update index.ts

* Update SurveyContext.tsx

* Update SurveyReviewSection.tsx

---------

Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>

* Update 20231112212117-AddProjectIdToSurveys-modifies-schema.js

* Add index to migration

* Fix migration

* Fix typo

* Cap survey name length at 50 characters

* WAITP-1490: Datatrak current user context (#5170)

* add current user context

* add error display

* rename context

* WAITP-1431: Fix survey select filter (#5177)

* Update SurveysRoute.ts

* remove tsx extentions

* Update SurveysRoute.ts

* WAITP-1387: Add survey project field (#5172)

* Responsive styling of dashboard leaderboard (#5173)

* Responsive styling of dashboard leaderboard

* Fix type error

* Survey not found error handling (#5160)

* Survey not found error handling

* Reorder imports

* Updates to route

* Fix types

* Remove unused imports

* Error page rename

* Rename page

* no-issue: Fix `location.state` null (#5179)

* extract useFromLocation

* extract `useFromLocation` to own file and use

* WAITP-1474: Update success illustration on DataTrak (#5159)

* generify high-five graphic filename

* update submission success graphic

* define margins along block/inline axes

See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flow_layout/Block_and_inline_layout_in_normal_flow

* success screen fix horizontal overflow

* define survey success image dimen with `rem`

* relabel button ‘Close’ → ‘Return to dashboard’

* Fix package error

* Fix autocomplete validation issue

* Create migration for surveys to project mapping

* WAITP-1431: Update datatrak survey url with country code (#5182)

* add Single Entity Route

* use country url to submit

* fix tests

* make TupaiaWebEntityRequest re-usable

* Update SingleEntityRoute.ts

* update recent surveys and responses routes

* handle recent survey submissions

* Update SurveyResponsesSection.tsx

* update country id in survey page

* remove unused code

* Update processSurveyResponse.test.ts

* Update queries

* Update preferred project on survey load

* Update queries and FE to handle project ids, and add migration for project creation

* Add toast to tell user project has been updated

* Remove unused import

* Remove unused import

* Make migration

* Update migration

* Update projectSurveyMappings.json

* Update migration

* Filter out new empty projects from Tupaia Web frontend

* Fix merge issues

* Remove survey responses when migrating down

* Update mappings

* Add new projects

* Update getSocialFeed.js

* Update SurveyResponse.js

* Update Routes.tsx

* public survey route

* WAITP-1480: survey duplication (#5193)

* Make migration

* Update migration

* Update migration

* Remove survey responses when migrating down

* add survey route

* rename SurveyRoutes

* Update SurveyRoutes.tsx

* add copy button

* handle logged out user submit

* submitAsPublic

* add public user test

* generate types

* update CopySurveyUrlButton

* tweaks

* Update GETSurveyResponses.test.js

* Hide search input when in review screen

* Fix lint error

* Show cancel modal when clicking on account settings

* Edit casing of button text

* Fix markdown formatting

* Update autocomplete styling

* Alphabetize autocomplete results

* Only show project update success toast when it happens behind the scenes

* Fix build error

* Fix test

* Update filter to be from starting letter

* Update autocomplete filtering

* WAITP-1495: Public entity questions (#5219)

* wip public requests

* update datatrak entity routes

* update options set permission check

* Update permissions.test.ts

* Update EntityQuestion.test.tsx

* support use Entity by code and id

* re organise entity routes

* Update useSubmitSurvey.test.ts

* fix front end tests

* Add x button to project select modal

* fix viewing a submitted survey

* fix login loading

* update datatrak tests

* add login tests

* stub out unhandled responses

* WAITP-1514: DataTrak redirect back after login (#5262)

* fix login loading

* update datatrak tests

* add login tests

* stub out unhandled responses

* fix accessibility features

* Add admin panel permissions check to user route

* WIP form

* Autocomplete and radio questions

* Working form

* WIP

* WIP tests

* Tests and tidy ups

* Tidy up merge

* Add request timeout

* Fix error

* FIx unused variable

* PR fixes

* Fix errors

* Add date placeholder and format

* Remove duplicate identifier

* Update handling of logged out entity descendents

* Update direct handling

* Merge

* Fix merge

* Fix error

* Fix merge issue

* Change name of interface

* Fix merge error

* Fix report timezone issue

* Handle undefined dates

---------

Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Chao Xin Nhin <122791168+chaoxinnhin@users.noreply.github.com>
Co-authored-by: Wilhelmus Duncker <122330202+WDuncker@users.noreply.github.com>
Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>
Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>
Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Jasper Lai <33956381+jaskfla@users.noreply.github.com>
Co-authored-by: RajneelR <132311480+RajneelR@users.noreply.github.com>
Co-authored-by: Andrew <vanbeekandrew@gmail.com>
alexd-bes added a commit that referenced this pull request Mar 17, 2024
* Waitp 1368 datatrak web fe setup (#4875)

* Added skeleton datatrak-server package

* Added datatrak-server to CI/CD

* wip datatrak front end app

* Added api-client to datatrak-server

* Added /projects route to datatrak-server

* disable eslint and re-install dependencies

* Added /entities route to datatrak-server

* add base views and downgrade react

* Update api.js

* Disabled frozen-lockfile

* Reverted yarn.lock

* Re-enabled frozen lockfile

* Add datatrak to CI/CD

* Added /surveys and /surveyScreenComponents routes

* Re-enabled exports of ui-components

* Switched to using pre-existing build and start scripts for datatrak

* add base form components

* Fix datatrak build

* format data to screens

* Got login working

* Added extra fields to FetchSurveyScreenComponents

* Got project and country selection working

* Upated yarn.lock

* Got survey selection working

* Got Survey page working

* screen steps

* add template styling

* add admin route

* Switched to using .env var for server url

* add logout

* Fixed up FetchUserRoute

* Add submitSurveyResponse route

* labels

* Add entity question

* add entity question to screen

* survey submit

* Update yarn.lock

* Update package.json

* remove anything not from fe

* Merge branch 'dev' into datatrak-hackathon

* Remove unused files

* Add initial fetch example

* Update README.md

* Revert change

* Remove unneeded change

* Add back in datatrak-app

* Add .env.example

* Update files

* Remove unnecessary code

* Fixes

* Test remove server setup

* Remove test step

* WAITP-1368: Basic page layout (#4890)

* basic page layout

* styles

* use theme colours

---------

Co-authored-by: Rohan Port <rohan@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1367 DataTrak Server (#4902)

* WAITP-1367 Add datatrak_session table to db

* WAITP-1367 Add request type for datatrak user request

* WAITP-1367 Add datatrak-server package

* WAITP-1367 Regenerate yarn.lock

* WAITP-1367 Fix minor copy-paste errors

* WAITP-1367 Add datatrak_session to ignored tables for hooks

* WAITP-1367 Add datatrak-server to server startup script in datatrak-web

* WAITP-1367 Add datatrak-server to CI/CD scripts

* WAITP-1367 Reduce layer count in dockerfile

* WAITP-1367 Regenerate types

* WAITP-1367 Regnerate types (again)

* WAITP-1367 Fixup clashing exports

* WAITP-1367 Rebalance test batching

* WAITP-1367: Rename datatrak-server to datatrak-web-server (#4904)

* find and replace

* rename package

* Update tupaia-ci-cd.Dockerfile

* update types

* Generate types

* Revert "Generate types"

This reverts commit 6fbbec6.

* WAITP-1277 datatrak-web login form part 1 (#4899)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* Update private routes and fix build

* Fix type errors

* Fix types

* Generate types

* Revert "Generate types"

This reverts commit de0fb64.

* Create private route

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 register page (#4903)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Update storybook

* Fix storybook

* Add pages to datatrak-web and mobile styling

* Fixes

* Fix route names

* Update private routes and fix build

* Fix height

* Fix type errors

* Fix types

* Generate types

* Revert "Generate types"

This reverts commit de0fb64.

* Create private route

* Fix build

* Fix casing

* Fix build error

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1379: select survey (#4925)

* Initial landing page

* Working survey select

* Fix type errors

* WAITP-1411: Setup datatrak survey screens (#4920)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* fix types

* scrren layout

* refactor context

* tidy up css

* resolve conflicts

* Update merge

* Update useSurveyScreenComponents.tsx

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* Fix circular types error

* Fix route

* Test types generate

* revert generate changes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1417 top progress bar (#4923)

* Started on progress bar commit

* added more styling and changed logic

* designed logic for progress bar

* fixed progress bar colour

* fixed pr

* ready for retest

* Added to survey page

* cleaned a few things

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1345: core question types (#4930)

* Text question

* Binary and radio questions

* Update types

* ƒix option parsing

* Date question

* Update question number logic

* Instruction question

* Update index.ts

* Handle review screen

* Fix date styles

* Update text field width

* Update line height

* Add types

* remove question number for now

* Checkbox question and styling

* Checkbox question

* Add comment

* DateTimeQuestion

* Add controller around all questions

* Add in question number

* Reorder imports

* Handle more than 26 questions on a screen

* Update casing.ts

* Fix imports

* Fixes and generate types

* Fix merge and question number logic

* Fix props

* yarn generate

* yarn generate

* WAITP-1428: datatrak design updates (#4949)

* Auth updates part 1

* Auth view

* Survey screen

* Tooltip buttons

* Use theme variable

* Update theme variable for primary text

* Auth layout

* Move styles into common form files

* Fix layout padding

* Update layout

* Update SurveySelectPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Waitp 1414 code generator hints (#4944)

* Setup reusable login form

* Working login

* User menu

* Fix versions

* Comments and tidy ups

* Fix build issue

* Add verify email view

* Update loginForm.stories.js

* FIx export

* Fix storybook

* Fixes

* Fix route names

* survey screens

* save form data

* routes

* Update Routes.tsx

* Initial landing page

* fix types

* scrren layout

* refactor context

* Working survey select

* tidy up css

* resolve conflicts

* Fix type errors

* Update merge

* Update useSurveyScreenComponents.tsx

* work in progress

* need testing

* quick fix

* styling commit

* few pr changes

* changed folder locations

* fixed imports and exports

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1346: Survey contents menu (#4958)

* Working menu

* Remove unused import

* Fixes

* WAITP-1350: Cancel survey workflow (#4964)

* WAITP-1327: Geolocate question type (#4917)

* WIP on geolocation question

* Pushing to remote for pairing

* updates to map pin drop functionality and ui

* tidying up unused imports and redundant components

* Fixes part 1

* Updates

* Fixes

---------

Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: acdunham <alex@beyondessential.com.au>

* Waitp 1427 survey submit success screen (#4965)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Fixes

* Fix types

* remove questions url

* Fix types

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* update ci cd with datatrak web

* add stub test

* WAITP-1407: Datatrak project select (#4950)

* project select modal

* save project id for a user

* fix types

* Update ProjectSelectPage.tsx

* edit project

* Update ProjectSelectPage.tsx

* Update ProjectSelectModal.tsx

* custom icons

* pr changes

* request access styles

* request access on click

* update types

* WAITP-1439: Survey review screen (#4985)

* almost done with routes

* sorted, does need cleaning up

* survey success commit

* Tidy up files

* Fix merge issues

* Review screen

* Initial mutation

* Tidy up files

* Fixes

* Update SurveyLayout.tsx

---------

Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1410: Request project access (#4997)

* Working request access

* Add access requested icon to project list

* Add 'EditUserForMe' endpoint

* Remove all countries requested view

* Refactor select list

* Fix on select issue

* Don't have onClick if is not a button

* Generate types

* Fixes

* Update types

* WAITP-1429: Autocomplete question (#5010)

* WIP

* Finish styling and get working

* Update styles

* Update font size

* Update hover colour

* Update packages/datatrak-web/src/features/Questions/AutocompleteQuestion.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1413: Datatrak Web Entity Question (#4996)

* setup entities question

* searching

* debounce

* styles

* close button

* sorting search results

* update filters

* remove old entity route

* fix filters

* fix types

* Update EntityList.js

* Update EntitiesRoute.ts

* refactor to match new list component

* Update useUser.ts

* add mock api with msw (#5019)

* WAITP-1437 toast messages (#5015)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Fixes

* Fix build errors and merge conflicts

* Fix error

* Fix broken test

* WAITP-1407: Add support for user preferences to user accounts (#5023)

* migration

* saving user preferences

* add validation to edit user endpoint

* fix tests

* WAITP-1431: Select country (#5026)

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Add country name to survey toolbar

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* Generate types

* Update schemas.ts

* Fixes

* Reorganise files

* Fix build errors

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1423: Primary entity question (#5027)

* Toast messages

* Remove buttons from landing page

* Apply error handling by default

* Generate types

* migration

* Working country display

* WIP

* saving user preferences

* Fixes

* Fix build errors and merge conflicts

* Add country name to survey toolbar

* setup submit

* Add country to entity search

* add validation to edit user endpoint

* Clean up and add comments

* Plumb in saving country

* move mocks

* primary entity handling

* Generate types

* Update schemas.ts

* attributes filter

* use country data

* Fixes

* Reorganise files

* Fix build errors

* update survey data key

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1369 Setup datatrak deployment (#5031)

* WAITP-1369 Add datatrak to servers.conf and subdomain suffixes

* WAITP-1369 Regenerate types

* WAITP-1369 Regen yarn.lock

* WAITP-1369 Fixup entity-server test

* WAITP-1369 Fixup usage of entity request type

* WAITP-1369 Remove broken include

* WAITP-1369 Regen types

* WAITP-1369 Fixup unit test

* Update tsconfig-build for datatrak-web-server

* no-issue-dedupe-react-router-dom

* WAITP-1349: Survey submit (#5032)

* Working survey submit

* Only show repeat survey button when canRepeat is true

* Fix todos

* Add loader

* Add coconut notification

* Tidy up

* Fix variable names

* Fix types

* Reorder imports

* Fix build error

* No issue: add test runner to datatrak-web (#5034)

* setup test runner

* add example survey

* change import meta to process env

* update survey test

* Update survey.test.tsx

* WAITP-1429: Autocomplete add and filtering of options (#5040)

* Enable create new option and filter options

* Tidy up code

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Update packages/datatrak-web/src/__tests__/features/Questions/AutocompleteQuestion.test.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Fix types

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1416: Visibility criteria (#5044)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* WAITP-1440: Mobile styling (#5042)

* WIP mobile styling

* WIP

* Fix project button styling

* Fix types

* Mobile app prompt

* Fix dashboard button styling

* WAITP-1347: Validation criteria (#5047)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Working validation

* Working validation

* Fix autocomplete styling

* Fix autocomplete issue

* Extract getRules function

* Fix typo

* No issue: Update survey screen fetching (#5050)

* Update get surveys endpoint

* Change to using surveys endpoint

* Fix types and visible question logic

* Remove old route

* Fix types and tests

* Generate types

* WAITP-1424: Entity question upserts (#5045)

* Enable create new option and filter options

* Tidy up code

* add filter prop

* Add tests for autocomplete question

* Update AutocompleteQuestion.test.tsx

* Add survey submit tests

* Submit Survey route

* Update useSubmitSurvey.ts

* add entities upserted

* update test suite

* fix bad merge

* update types

* set country in upsert entity

* Update schemas.ts

* fix up types

* fix tests

* fix schema

* fix tests

* wip refactor form submission

* move tests to server

* generate schemas

* fix entity test

* Update render.tsx

* Update useSubmitSurvey.test.ts

* Update render.tsx

* reuse survey request types

* Update schemas.ts

* fix question types

* fix types

* Update schemas.ts

* optional screen id

---------

Co-authored-by: acdunham <alex@beyondessential.com.au>

* WAITP-1430: condition question (#5049)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Fix tests and build

* WAITP-1453: UI updates (#5052)

* Handle location errors

* Fix redirect issue for requesting access

* Add tooltip delay

* Add delay on mobile devices

* Tidy tooltip props code

* Update popovers

* Update header heights

* Update number field width

* Make text inputs multiline when text wraps

* Make radio labels full width

* Clip side menu item length

* Center instruction only screens

* Remove horizontal centering

* Hide placeholder in review screen

* Update survey icons

* Remove unused import

* Fix build errors

* Fixes

* Fix errors

* WAITP-1412: Arithmetic question (#5054)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* Add handling for custom display text

* WAITP-1276: Forgot password (#5056)

* Add forgot passowrd view

* Working form

* Add stories

* Fix build

* Set height on forgot password screen

* Reset success screen

* Reorder imports

* WAITP-1345:Core question updates (#5066)

* Allow color to be set on radio options

* Get help text working

* Update SurveyQuestionGroup.tsx

* Update types

* WAITP-1349: Fix DataTrak survey submit (#5078)

* Update surveyResponse.js

* Update surveyResponse.js

* WAITP-1454: design updates (#5079)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* WAITP-1454: Fix sorting of surveys (#5080)

* Update hover state for primary buttons

* New validation

* Update text area focus styles

* Update project button font weight

* Update checkbox colour

* Remove menu list item hover

* Text sizing and close menu on click

* Update landing page display sizing

* Fix geolocate accuracy

* Update validation types

* Fix build

* Fix autocomplete filter

* PR fixes

* Alphabetize survey results

* Update sorting

* Fix sorting in folders

* Update FE sorting

* tile component

* Revert "tile component"

This reverts commit 7b612fb.

* WAITP-1454: UI changes (#5089)

* tile component

* Show modal when exiting survey via home button

* Remove unused imports

* Stop menu re-rendering on change of survey screen

* Update button disabled state

* Fix build errors

* Fix tests

* Close side menu on screen change on mobile

* clean up code from another branch

* Update LandingPage.tsx

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1377 Forward signup route to web config server (#5090)

* WAITP-1377 Forward signup route to web config server

* WAITP-1377 Fixup lint

* WAITP-1449: QR code generator (#5086)

* WIP visibility criteria

* Working survey visibility criteria

* Generate types

* Add tests

* Redirect user if survey screen is not visible

* Reset invisible answers

* Handle when value is not an array

* Remove only from test

* Fix tests

* Conditional questions working

* Get question fully updating

* Generate types

* Add tests and update types

* Update survey.json

* Fix types and build

* Fix tests

* Initial logic and separate out context

* Working arithmetic question

* Fix tests and build

* Generate types

* Fix types

* Add tests

* WIP

* WIP

* WIP

* WIP

* Working qr code

* Fix types

* Update test

* Fix tests

* PR fixes

* WAITP-1415: Photo upload question (#5099)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* no-issue-fix-types-after-merge

* WAITP-1357: Datatrak dashboard survey responses (#5091)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* WAITP-1461: Datatrak design feedback (#5109)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* project select page

* menu ux

* Update useSubmitSurvey.ts

* gps question

* Update index.html

* Update ProjectsRoute.ts

* theming

* Update mui.d.ts

* Update useSubmitSurvey.test.ts

* Update theme.ts

* Update SurveySelectPage.tsx

* Update SurveySelectPage.tsx

* Update useValidationResolver.ts (#5128)

* WAITP-1412: fix arithmetic questions

* one time login flow (#5138)

* WAITP-1354: Leaderboard (#5132)

* no-issue: Add @tupaia/server-utils package (#5121)

* RN-1060: (task) Moved sendEmail to @tupaia/server-utils (#5126)

* RN-1060: (task) Added dashboards/:project/:entity/:dashboard/export route to tupaia-web (#5125)

* WAITP-1354: Leaderboard

* Update copyright

* Update internal email

* Update email filter

* Fix response type

* Update packages/datatrak-web/src/features/Leaderboard/LeaderboardTable.tsx

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update background variable

* Update branch name validation script (#5136)

* Update to use new leaderboard model

* Revert "Merge branch 'dev' into waitp-1354-leaderboard"

This reverts commit c2acdbe, reversing
changes made to 747f182.

* Fix types

* Update packages/database/src/modelClasses/SurveyResponse.js

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>

* PR fixes

* Fix error

---------

Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>

* WAITP-1356: recent surveys (#5113)

* Update LandingPage.tsx

* update landing page

* data fetching layer

* fix console errors

* re organise landing page

* tooltips

* style tweaks

* update landing page layout

* horizontal scroll

* page limit

* Frontend layout

* Working request

* Refetch recent surveys on submit

* Fix recent survey request and styling

* Use grid and update heading element

* Remove unnecessary css

* PR fixes

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1469: account delete (#5134)

* WIP

* Account deletion

* Update component for section

* Update modals

* Remove forced open state

* Fix types

* fix build error

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Update packages/datatrak-web/src/api/mutations/useEditUser.ts

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* Change format

* fix bad merge

* return zeros for rewards

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1330: File upload question type (#5100)

* WIP

* Use built in functionality

* Add comment

* Fix build errors

* Working file upload

* Fix build

* Remove unused vars

* Update format of file upload answers

* Update schemas.ts

* Update processSurveyResponse.test.ts

* Update upsertAnswers.js

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

* WAITP-1424: Datatrak PrimaryEntity question fix (#5144)

* fix rewards types

* update primary entity question name

* WIP

* Fix success screen layout

* Fix date change issue

* Fix error styling

* Working activity feed

* Tidy ups

* WAITP-1427: Fix survey cancelling (#5148)

* Update CancelSurveyModal.tsx

* tidy up landing page

* fix console errors

* No issue: Only generate QR code when createNew is true

* No issue: Fix tests

* Remove permission group and country from admin panel feed items

* No issue: Fix recent survey layout

* Working pinned posts

* No issue: Login redirect (#5151)

* Redirect to route on login or project select

* Formatting

* Always show user on leaderboard

* WAITP-1478 Single survey response endpoint (#5153)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* WAITP-1478 Update survey response answers to map by question_id

* WAITP-1478 Rename RecentSurveyResponse to SingleSurveyResponse

* WAITP-1478 Rename files

* Fix PR

* Generate types

* Fix styling

* Update Button.tsx

* Fixes

* WAITP-1452: Datatrak-web refactor survey context (#5156)

* Update useLogin.ts

* refactor survey context to be at survey level

* Create migration

* Update types

* Responsive styling (#5158)

* Responsive styling

* Fix padding on mobile

* Handle project id in queries

* Filter user rewards by project id

* Update queries to have projectId as optional param

* Fix bindings

* Update SurveyResponse.js

* Add project column to admin panel

* WAITP-1452: Recent survey response page (#5157)

* WAITP-1478 Add types definition for RecentSurveyResponseRoute

* WAITP-1478 Regen types

* WAITP-1478 Add route for RecentSurveyResponse

* WAITP-1478 Fixup export

* WAITP-1478 Update url

* WAITP-1478 Regen types

* useSurveyResponse

* survey review screen

* wip set default values

* set up route

* Update useLogin.ts

* refactor survey context to be at survey level

* remove bad merge

* survey data

* basic working setup

* remove debug changes

* split out paginator

* put page back in survey layout

* refactor layout components

* Update index.ts

* Update SurveyContext.tsx

* Update SurveyReviewSection.tsx

---------

Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>

* Update 20231112212117-AddProjectIdToSurveys-modifies-schema.js

* Add index to migration

* Fix migration

* Fix typo

* Cap survey name length at 50 characters

* WAITP-1490: Datatrak current user context (#5170)

* add current user context

* add error display

* rename context

* WAITP-1431: Fix survey select filter (#5177)

* Update SurveysRoute.ts

* remove tsx extentions

* Update SurveysRoute.ts

* WAITP-1387: Add survey project field (#5172)

* Responsive styling of dashboard leaderboard (#5173)

* Responsive styling of dashboard leaderboard

* Fix type error

* Survey not found error handling (#5160)

* Survey not found error handling

* Reorder imports

* Updates to route

* Fix types

* Remove unused imports

* Error page rename

* Rename page

* no-issue: Fix `location.state` null (#5179)

* extract useFromLocation

* extract `useFromLocation` to own file and use

* WAITP-1474: Update success illustration on DataTrak (#5159)

* generify high-five graphic filename

* update submission success graphic

* define margins along block/inline axes

See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flow_layout/Block_and_inline_layout_in_normal_flow

* success screen fix horizontal overflow

* define survey success image dimen with `rem`

* relabel button ‘Close’ → ‘Return to dashboard’

* Fix package error

* Fix autocomplete validation issue

* Create migration for surveys to project mapping

* WAITP-1431: Update datatrak survey url with country code (#5182)

* add Single Entity Route

* use country url to submit

* fix tests

* make TupaiaWebEntityRequest re-usable

* Update SingleEntityRoute.ts

* update recent surveys and responses routes

* handle recent survey submissions

* Update SurveyResponsesSection.tsx

* update country id in survey page

* remove unused code

* Update processSurveyResponse.test.ts

* Update queries

* Update preferred project on survey load

* Update queries and FE to handle project ids, and add migration for project creation

* Add toast to tell user project has been updated

* Remove unused import

* Remove unused import

* Make migration

* Update migration

* Update projectSurveyMappings.json

* Update migration

* Filter out new empty projects from Tupaia Web frontend

* Fix merge issues

* Remove survey responses when migrating down

* Update mappings

* Add new projects

* Add project filtering to activity feed

* WAITP-1480: survey duplication (#5193)

* Make migration

* Update migration

* Update migration

* Remove survey responses when migrating down

* Update PinnedFeedItem.tsx

* Fix build error

* Fix merge error

* Fix error

* WAITP-1482: activity feed changes (#5354)

* Update feed scraper to add all survey responses to feed items

* Add access policy to Datatrak

* Move endpoints over to using new model functions

* Update yarn.lock

* Update packages/datatrak-web-server/src/app/middleware/attachAccessPolicy.ts

Co-authored-by: Jasper Lai <33956381+jaskfla@users.noreply.github.com>

* Fix merge error

* Update model to handle only some countries user has access to

* Update methods

* Move access policy logic to server-boilerplate

* Fix tupaia-web-server tests

* Revert "Fix tupaia-web-server tests"

This reverts commit 0e64b50.

* Fix tests

* Fix tests

* Remove unneeded fixtures

---------

Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>
Co-authored-by: Jasper Lai <33956381+jaskfla@users.noreply.github.com>

* Fix merge error

* Filter feed items by feed item permissions

* Fix feed item ordering

* Reset feed on login request

* Fix ambiguous query

* Fixes

* Update datatrak activity feed filter format

* Dedupe feed items on infinite scroll

---------

Co-authored-by: acdunham <129009580+acdunham@users.noreply.github.com>
Co-authored-by: Rohan Port <rohan@beyondessential.com.au>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
Co-authored-by: Ethan McQuarrie <69437175+EMcQ-BES@users.noreply.github.com>
Co-authored-by: Chao Xin Nhin <122791168+chaoxinnhin@users.noreply.github.com>
Co-authored-by: Wilhelmus Duncker <122330202+WDuncker@users.noreply.github.com>
Co-authored-by: wduncker <wduncker@LAPTOP-AFVENG10>
Co-authored-by: Chao Xin Nhin <chaon@missionreadyhq.com>
Co-authored-by: Ethan McQuarrie <ethan@beyondessential.com.au>
Co-authored-by: Rohan Port <59544282+rohan-bes@users.noreply.github.com>
Co-authored-by: Jasper Lai <33956381+jaskfla@users.noreply.github.com>
Co-authored-by: RajneelR <132311480+RajneelR@users.noreply.github.com>
Co-authored-by: Andrew <vanbeekandrew@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants