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
| const Joi = require("joi"); | |
| const registerValidationSchema = Joi.object().keys({ | |
| name: Joi.string() | |
| .min(2) | |
| .max(30) | |
| .required(), | |
| email: Joi.string() | |
| .email() | |
| .required(), |
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
| router.post("/register", (req, res) => { | |
| const userProps = req.body; | |
| const { email } = userProps; | |
| User.findOne({ email }) | |
| .then(user => { | |
| if (user) { | |
| return res.status(400).json({ errormessage: "User already exists." }); | |
| } else { | |
| const avatar = gravatar.url(email, { |
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 { addBudget } from 'actions'; | |
| import { connect } from 'react-redux'; | |
| import BudgetForm 'components/Budgets/BudgetForm'; | |
| class BudgetCreate extends React.Component { | |
| onSubmit = formValues => { | |
| this.props.addBudget(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
| const mongoose = require('mongoose'); | |
| const { Schema } = mongoose; | |
| const TransactionSchema = require('./Transaction'); | |
| const budgetSchema = new Schema({ | |
| title: String, | |
| description: String, | |
| amount: { type: Number, default: 0 }, | |
| startDate: Date, | |
| endDate: Date, |
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 axios from 'axios'; | |
| class FetchActionCreators { | |
| constructor(endpoint, actions) { | |
| const [REQUEST, SUCCESS, FAILURE] = actions; | |
| this.actions = { | |
| REQUEST, | |
| SUCCESS, | |
| FAILURE, |
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
| ///Click func | |
| handleOnClick(e) { | |
| e.preventDefault(); | |
| //save input value | |
| let inputValue = this.refs.inputfield.value; | |
| if(inputValue === '') return; | |
| //pass input value to callback | |
| this.props.addTodo(inputValue) | |
| } |
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
| // Dependencies | |
| var express = require('express'); | |
| var mongoose = require('mongoose'); | |
| var bodyParser = require('body-parser'); | |
| // Define our Todo Model | |
| var Todo = mongoose.model('Todo', { | |
| text: String | |
| }); |
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 dotProp from 'dot-prop-immutable'; | |
| //save string values to vars | |
| const ADD_TODO = 'ADD_TODO'; | |
| let nextId = 0; | |
| //the action is whats performed to alter state | |
| //addItem is an action creator and nees to return an action | |
| export const AddTodo = (text) => { | |
| return { | |
| type: ADD_TODO, |
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, { Component } from 'react'; | |
| import ListItem from '../components/ListItem'; | |
| export default class List extends Component { | |
| // renderTodos() { | |
| // return this.props.items.map((item) => { | |
| // return ( | |
| // <Listitem key={item.id}> | |
| // {item.text} |
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
| filterMovies: function() { | |
| var moviePosters = []; | |
| for (var i; i <= 5; i++) { | |
| if(apiData.rating >= 8) { | |
| return moviePosters.push(apiData.Poster[i]); | |
| } else { | |
| return; | |
| } | |
| } | |
| }, |
NewerOlder