Skip to content

Instantly share code, notes, and snippets.

View acomito's full-sized avatar

Anthony Comito acomito

View GitHub Profile
export default function Home() {
const { loading, data } = useQuery(CURRENT_USER, {
variables: {}
})
if (!data) {
// redirect to a hosted auth0 login page
return <Redirect to="/api/login" />
}
const File = () => {
return (
<FormItem label="Year Built" error={this.state.yearError}>
<NumberInput
min={0}
onChange={(yearBuilt) => {
// *********** clear your error message here
this.setState({ yearError: null })
import React, { useState } from 'react'
const FilesArea = ({ defaultFiles }) => {
const [localFiles, setLocalFiles] = useState([]);
const onUpload = (e) => {
let file = e.target.files[0];
let uploadedFilesLength = defaultFiles.length + localFiles.length; // figure out how many files the've uploaded thus far
// TOP LEVEL IMPORTS
import React from 'react';
import styled, {keyframes} from 'styled-components';
const pulse = keyframes`
0% {
transform: scale(0.9);
box-shadow: 0 0 0 0 rgba(124, 196, 250, .7)
}
70% {
import React from 'react';
import MY_MUTATION from 'ApolloClient/Mutations/myMutation.js'
import { graphql } from 'react-apollo'
class MyFunctionComponent extends React.PureComponent {
handleOnClick = async () => {
await this.props.myMutation({})
}
import React from 'react';
import MY_MUTATION from 'ApolloClient/Mutations/myMutation.js'
import { useMutation } from 'react-apollo'
const MyFunctionComponent = () => {
const [myMutation] = useMutation(MY_MUTATION);
const handleOnClick = async () => {
await myMutation({})
// ********************************************************
// Mutations/resolvers/createTask.js
import Users from 'collections/Users/model';
import Tasks from 'collections/Tasks/model';
const createTask = async (root, args, context) => {
let user = await Users.findOne({
_id: args.params.userId,
});
const schema = new Mongo.Schema({
...baseFields, // baseFields includes createdAt, createdBy, updatedAt, updatedBy
id: String,
title: String, // "Task Created"
description: String, // "Anthony created a task for Jessica"
activityType: {
// list of all possible types
type: String,
enum: [
'noteAdded', // when somebody adds a note