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

94 mitgliedsantrag #585

Closed
wants to merge 7 commits into from
Closed

94 mitgliedsantrag #585

wants to merge 7 commits into from

Conversation

jstet
Copy link
Member

@jstet jstet commented Oct 3, 2023

No description provided.

@jstet jstet linked an issue Oct 3, 2023 that may be closed by this pull request
@vercel
Copy link

vercel bot commented Oct 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
correlaid ⬜️ Ignored (Inspect) Oct 3, 2023 5:10pm

@jstet jstet mentioned this pull request Oct 3, 2023
Copy link
Collaborator

@KonradUdoHannes KonradUdoHannes left a comment

Choose a reason for hiding this comment

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

Generally I think this already looks good. I left a few general comments on how to potentially make it more readable and how to make it more testable. Happy to discuss this further if desired.

import * as yup from 'yup';
import _ from 'lodash';

export function createSchema(validationData, membership_application) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I recommend to rename the parameters as the names suggest there might be user data passed, which is not the case.

I think for instance the following would be better
validateionData -> validationErrMsg
membership_application -> membershipFormDefinition

Finding a very good name for the latter one seems a little harder as it is basically already some sort of schema and its a little harder to not pick confusing naming when this is passed to a createSchema function. But anything that makes it clear that this is not user data is good.

For testing the createSchema function is also good. As the schema can easily be created for tests. The focus here should be to tests the composition of the different yup elements, and not to test yup itself. For instance I would assume that the yup email validator works, but the final schema that we define might easily have a mixup where a mandatory field ends up as optional. When testing this one could also see whether you has a "fail fast" feature which one could switch off for testing. This would then allow a test to for instance submit an empty json and get validation errors for all the required fields in a single test.

@@ -0,0 +1,34 @@
import jsPDF from 'jspdf';

export function generatePDF(values, membership_application) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again a bit confusing naming with membership_application, which only contains schema information.

const data = await directus_fetch(MembershipQuery);

return {
membership_application: data.membership_application,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again confusing naming, which means that the naming in directus is maybe not optimal as well, there might be additional considerations for the directus naming, but when creating the object here the name should be changed to something more clear from the website perspective.

});

export let data;
$: membership_application = data.membership_application.data.fields;
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a bit of a naming discrepancy here in directus and for the website code. In directus data has fields which themselves again have fields. The Website calls this groups and fields respectively. It might be a good idea to align it towards to terminology of the website, which I think is clearer.


export let data;
$: membership_application = data.membership_application.data.fields;
$: validationData = data.membership_application.data.validation;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentioned earlier, I think naming that makes clear that these are error messages would be better.

}
},
extend: reporter,
onSubmit: async (values) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as for the validation. Creating this callback should be isolated such that it can be tested in isolation.

<p class="pb-3">{group.description}</p>
</div>
<div class="gap-5 lg:grid lg:grid-cols-2">
{#each group.fields as field}
Copy link
Collaborator

Choose a reason for hiding this comment

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

One could consider making a FormField component that isolates a lot of this logic here, that way one could more easily test that all the different types of fields work in isolation. But since errors here are likely visual I think its less of a priority compared to carefully testing callbacks that may fail in the background.

>
{#if field.type === 'checkbox'}
<label for={field.name} class="mb-2 mt-4 font-semibold"
>{field.mandatory === true ? '* ' : ''}{field.label}</label
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
>{field.mandatory === true ? '* ' : ''}{field.label}</label
>{field.mandatory ? '* ' : ''}{field.label}</label

/>
{:else if field.type === 'radio_group'}
<h3 class="mb-2 mt-4 font-semibold">
{field.mandatory === true ? '* ' : ''}{field.label}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{field.mandatory === true ? '* ' : ''}{field.label}
{field.mandatory ? '* ' : ''}{field.label}

{/each}
{:else}
<label for={field.name} class="mb-2 mt-4 font-semibold"
>{field.mandatory === true ? '* ' : ''}{field.label}</label
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
>{field.mandatory === true ? '* ' : ''}{field.label}</label
>{field.mandatory ? '* ' : ''}{field.label}</label

@jstet
Copy link
Member Author

jstet commented Oct 7, 2023

Thank you so much @KonradUdoHannes !!

@jstet
Copy link
Member Author

jstet commented Oct 25, 2023

An internal decision was made to use an external provider for membership applications

@jstet jstet closed this Oct 25, 2023
@pr130 pr130 mentioned this pull request Nov 3, 2023
1 task
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.

Mitgliedsantrag
2 participants