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

Create template modal #757

Merged
merged 8 commits into from
Jan 3, 2024
Merged

Create template modal #757

merged 8 commits into from
Jan 3, 2024

Conversation

negreirosleo
Copy link
Contributor

Create save task as template modal.

Instead of having controlled inputs and react query I tried using the new server actions from next js v14 to submit the form. I like the result of it, it save us from writing more code to track the fetch states, and having to use more hooks.

Screencast.from.2023-12-29.18-23-09.webm

This was done to use the server actions without having to use the
experimental flag, it was release in v14 and since we are using next I
think it is worth using the features that are driving the framework
development
This class is created to improve the error handling through the code and
t make it easier to create new errors
This modal contains the form to save a task as a template
This SubmitButton is a regular button but it uses the useFormStatus hook
to get the "pending" state from form to know if it should or shouldn't
be disabled.
This commit doubles down on the next js capabilities, by using new the server
actions it makes a lot of states tracking and useEffects unnecessary
thus making us write less code to have the same features
This commit changes the structure for the apiClient dependecy injection,
it exports a makeCreateTemplate function that receives the apiClient as
prop and return the createTemplate function, I made this change because
I think this pattern is easier to follow through the application. Also I
intend to change the other api calls in future pr's.
The Jest transformer breaks with some server libs that are used by the
server actions, this globally mocks the next-auth session so we don't
have to worry about it ever again.
@negreirosleo negreirosleo force-pushed the create-template-modal branch from fdbc4bf to 99fbed5 Compare January 2, 2024 15:28
Copy link
Member

@anarute anarute left a comment

Choose a reason for hiding this comment

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

Other than the naming nit, looks good to me! I also tested locally and it works well.

frontend/src/infra/template/createTemplate.ts Show resolved Hide resolved
Copy link
Collaborator

@dmtrek14 dmtrek14 left a comment

Choose a reason for hiding this comment

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

I agree with @anarute on the naming, but this otherwise looks good to me.

@negreirosleo negreirosleo merged commit d1565b5 into main Jan 3, 2024
2 checks passed
@negreirosleo negreirosleo deleted the create-template-modal branch January 3, 2024 11:56
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.

3 participants