This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| import Datepicker from '../components/datepicker'; | |
| export const FormComponent = ({ handleSubmit, onSubmit, formValues, change }) => { | |
| return ( | |
| <div className="flex flex-column justify-center items-center"> | |
| <h1>My Very own Form</h1> | |
| <form | |
| className="w-80" | |
| onSubmit={handleSubmit(onSubmit)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import moment from 'moment'; | |
| import { SingleDatePicker } from 'react-dates'; | |
| import 'react-dates/lib/css/_datepicker.css'; | |
| export class Datepicker extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| date: moment(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { Field } from 'redux-form'; | |
| import Text from '../components/text'; | |
| import Select from '../components/select'; | |
| import Radio from '../components/radio'; | |
| import Checkbox from '../components/checkbox'; | |
| export const FormComponent = ({ handleSubmit, onSubmit, formValues }) => { | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { connect } from 'react-redux'; | |
| import { reduxForm, getFormValues } from 'redux-form'; | |
| import FormComponent from './form.component'; | |
| export const FormContainer = props => { | |
| const submitForm = (formValues) => { | |
| console.log('submitting Form: ', formValues); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| <Field | |
| name="wantsFries" | |
| label="Would you like fries with that?" | |
| component={Checkbox} | |
| /> | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| export const Checkbox = props => { | |
| return ( | |
| <div className="flex items-center mv4 w-100"> | |
| <input | |
| {...props.input} | |
| className="mr2" | |
| type="checkbox" | |
| checked={props.input.value} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 4. Implement a function pipe() that takes several functions as arguments and returns a new | |
| // function that will pass its argument to the first function, then pass the result to the second, then | |
| // pass the result of the second to the third, and so on, finally returning the output of the last | |
| // function. In other words, calling pipe(foo, bar, baz)(1, 2, 3) would be equivalent to | |
| // calling baz(bar(foo(1,2,3))). | |
| const pipe = (...fns) => { | |
| return ( | |
| fns.reduce( | |
| (a, b) => (...args) => b(a(...args)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Improve this React Component | |
| const JSON_URL = 'https://jsonplaceholder.typicode.com/comments'; | |
| class CommentList extends React.Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| comments: [] | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| from django.contrib.auth.models import AbstractUser | |
| class User(AbstractUser): | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| from users.models import User | |
| class Todo(models.Model): | |
| created = models.DateTimeField(auto_now_add=True) | |
| name = models.CharField(max_length=100, unique=True, blank=False, null=False) | |
| user = models.ForeignKey('users.User', related_name='todos', on_delete=models.CASCADE, null=False) | |
| class Meta: |