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

Template for form inputs (prepare for graphql mutation) #132

Open
5 tasks
jozef-slezak opened this issue Jun 28, 2021 · 1 comment
Open
5 tasks

Template for form inputs (prepare for graphql mutation) #132

jozef-slezak opened this issue Jun 28, 2021 · 1 comment
Assignees

Comments

@jozef-slezak
Copy link
Contributor

jozef-slezak commented Jun 28, 2021

Goal:

  • refactoring of existing code: instead of typescript factory that create AST use templates + refactoring rules
  • read template into AST and apply refactoring rules (using a script)

Templates

Read info/background from #138.

Let's have multiple templates and preserve existing logic using them:

  • Template for input string
  • Template for integer
  • Template for decimal
  • Template for date
  • Template for time
  • Template for date time
function StringInputTemplate({value, handleChange, error})
<TextField 
      label={T('label')} 
      placeholder={T('placeholder')} 
      value={value} 
      onChange={handleChange}
      error={error}
      helperText={error}
/>

Refactoring rules:

  • try to replace translation T('label') if not missing with real messageID and T('messageID') with a particular translation framework (react-intl and potentially react-i18n)
  • try to replace translation T('placeholder') if not missing with real messageID and T('messageID') with a particular translation framework (react-intl and potentially react-i18n)
  • inline all prop value occurences with for example value={formik.values.email} (in case of using formik)
  • inline all prop handleChange with for example onChange={formik.handleChange} (in case of using formik)
  • inline all prop errorwith for example error={formik.touched.email && Boolean(formik.errors.email)} and in this case also helperText={formik.touched.email && formik.errors.email}

https://codesandbox.io/s/github/formik/formik/tree/master/examples/with-material-ui?from-embed

Next steps will be:

  • template detail page that queries graphql by PK
  • introduce graphql mutation in the template
@jozef-slezak jozef-slezak changed the title Template for form inputs Template for form inputs (prepare for graphql mutation) Jun 28, 2021
@jozef-slezak jozef-slezak pinned this issue Jul 22, 2021
@cunderlikp
Copy link

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

No branches or pull requests

3 participants