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

Feature/thanks page picture #121

Merged
merged 10 commits into from
Jun 28, 2023
Merged

Feature/thanks page picture #121

merged 10 commits into from
Jun 28, 2023

Conversation

mmoila
Copy link
Collaborator

@mmoila mmoila commented Jun 27, 2023

Add possibility to include a user defined image to thank you page. Uses SurveyImageList component which is also used for background image.

The backend offers an api endpoint with format api/file/<image_type>/<file_name>. All available images of certain type can be fetched using api/file/<image_type>.

Thank you page images are saved to the database to table data.files. Filepath column in the database is used to define the type of the image (background-images or thanks-page-images).

Closes #105

@mmoila mmoila requested a review from jlaamanen June 27, 2023 08:07

useEffect(() => {
async function getThanksPageImage() {
const res = await fetch(
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] Should this fetch actually only be used for fetching the headers? I believe you can fetch headers only with { method: 'HEAD' }.

The survey.thanksPage.imagePath could be used directly in the <img> tag's src attribute. Writing a megabytes long blob data into a data URL and rendering it after first downloading the image would probably be quite a slow task, especially on mobile devices

}

function getActiveImage() {
const activeImage;
Copy link
Contributor

Choose a reason for hiding this comment

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

const variables shouldn't be re-assignable, I wonder why there are no errors here... 🤔 However, you can also return directly the results of images?.find(...) ?? null in both cases, no need for a variable for this.

@mmoila mmoila merged commit 08b2816 into develop Jun 28, 2023
@mmoila mmoila deleted the feature/thanks-page-picture branch June 28, 2023 10:30
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.5: Kiitos-sivulle kuva
2 participants