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
// Inside onChange handler | |
// .... | |
// #1 There are too many files! | |
if (files.length > 3) { | |
const msg = 'Only 3 images can be uploaded at a time' | |
return this.toast(msg, 'custom', 2000, toastColor) | |
} | |
const types = ['image/png', 'image/jpeg', 'image/gif'] |
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
app.post('/image-upload-single', (req, res) => { | |
const path = Object.values(Object.values(req.files)[0])[0].path | |
cloudinary.uploader.upload(path) | |
.then(image => res.json([image])) | |
}) |
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 { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | |
import { faTimesCircle } from '@fortawesome/free-solid-svg-icons' | |
export default props => | |
props.images.map((image, i) => | |
<div key={i} className='fadein'> | |
<div | |
onClick={() => props.removeImage(image.public_id)} | |
className='delete' |
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 { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | |
import { faBowlingBall } from '@fortawesome/free-solid-svg-icons' | |
export default () => | |
<div className='spinner fadein'> | |
<FontAwesomeIcon icon={faBowlingBall} size='5x' color='#3B5998' /> | |
</div> |
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
require('dotenv').config() | |
const express = require('express') | |
const cloudinary = require('cloudinary') | |
const formData = require('express-form-data') | |
const cors = require('cors') | |
const { CLIENT_ORIGIN } = require('./config') | |
const app = express() | |
cloudinary.config({ |
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 Spinner from './Spinner' | |
import Images from './Images' | |
import Buttons from './Buttons' | |
import { API_URL } from './config' | |
import './App.css' | |
export default class App extends Component { | |
state = { |
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 nums = [] | |
for (let i = 0; i <= 10000; i++) { | |
nums.push(i) | |
} | |
const nums2 = [...nums, 10000] | |
// previously written functions for duplicates | |
// duplicates2, duplicates3, duplicates4 |
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 nums = [2, 6, 3, 10] | |
const nums2 = [2, 4, 1, 2] | |
const duplicates4 = arr => { | |
// Start with an empty Object as a | |
// record keeper | |
const obj = {} | |
for (let i = 0; i < arr.length; i++) { |
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 nums = [2, 6, 3, 10] | |
const nums2 = [2, 4, 1, 2] | |
const duplicates3 = arr => { | |
for (let i = 0; i < arr.length; i++) { | |
const num = arr[i] | |
// We take a slice of the remaining Array | |
// and see if that includes the num | |
// it must be a duplicate |