mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-19 11:12:00 +10:00
- run eslint --fix across project
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import firebase from "gatsby-plugin-firebase";
|
||||
import { debounce } from "lodash";
|
||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||
import UserContext from "./UserContext";
|
||||
import firebase from 'gatsby-plugin-firebase';
|
||||
import { debounce } from 'lodash';
|
||||
import React, { createContext, useContext, useEffect, useState } from 'react';
|
||||
import UserContext from './UserContext';
|
||||
|
||||
const defaultState = {
|
||||
isOffline: false,
|
||||
@ -22,8 +22,8 @@ const DatabaseProvider = ({ children }) => {
|
||||
const { user } = useContext(UserContext);
|
||||
|
||||
useEffect(() => {
|
||||
const connectedRef = firebase.database().ref(".info/connected");
|
||||
connectedRef.on("value", (snapshot) => {
|
||||
const connectedRef = firebase.database().ref('.info/connected');
|
||||
connectedRef.on('value', (snapshot) => {
|
||||
snapshot.val() === true ? setOffline(false) : setOffline(true);
|
||||
});
|
||||
}, []);
|
||||
@ -32,7 +32,7 @@ const DatabaseProvider = ({ children }) => {
|
||||
const snapshot = await firebase
|
||||
.database()
|
||||
.ref(`users/${user.uid}/resumes/${id}`)
|
||||
.once("value");
|
||||
.once('value');
|
||||
return snapshot.val();
|
||||
};
|
||||
|
||||
@ -40,10 +40,11 @@ const DatabaseProvider = ({ children }) => {
|
||||
const { id } = resume;
|
||||
const createdAt = firebase.database.ServerValue.TIMESTAMP;
|
||||
|
||||
let firstName, lastName;
|
||||
let firstName;
|
||||
let lastName;
|
||||
|
||||
if (!user.isAnonymous) {
|
||||
[firstName, lastName] = user.displayName.split(" ");
|
||||
[firstName, lastName] = user.displayName.split(' ');
|
||||
}
|
||||
|
||||
firebase
|
||||
@ -51,8 +52,8 @@ const DatabaseProvider = ({ children }) => {
|
||||
.ref(`users/${user.uid}/resumes/${id}`)
|
||||
.set({
|
||||
profile: {
|
||||
firstName: firstName || "",
|
||||
lastName: lastName || "",
|
||||
firstName: firstName || '',
|
||||
lastName: lastName || '',
|
||||
},
|
||||
...resume,
|
||||
createdAt,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { createNanoEvents } from "nanoevents";
|
||||
import React, { createContext } from "react";
|
||||
import ModalEvents from "../constants/ModalEvents";
|
||||
import { createNanoEvents } from 'nanoevents';
|
||||
import React, { createContext } from 'react';
|
||||
import ModalEvents from '../constants/ModalEvents';
|
||||
|
||||
const emitter = createNanoEvents();
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import arrayMove from "array-move";
|
||||
import { clone, findIndex, get, setWith } from "lodash";
|
||||
import arrayMove from 'array-move';
|
||||
import { clone, findIndex, get, setWith } from 'lodash';
|
||||
import React, {
|
||||
createContext,
|
||||
useCallback,
|
||||
useContext,
|
||||
useReducer,
|
||||
} from "react";
|
||||
import DatabaseContext from "./DatabaseContext";
|
||||
} from 'react';
|
||||
import DatabaseContext from './DatabaseContext';
|
||||
|
||||
const initialState = {};
|
||||
|
||||
@ -17,71 +17,73 @@ const ResumeProvider = ({ children }) => {
|
||||
|
||||
const memoizedReducer = useCallback(
|
||||
(state, { type, payload }) => {
|
||||
let newState, index, items;
|
||||
let newState;
|
||||
let index;
|
||||
let items;
|
||||
|
||||
switch (type) {
|
||||
case "on_add_item":
|
||||
delete payload.value.__temp;
|
||||
case 'on_add_item':
|
||||
delete payload.value.temp;
|
||||
items = get(state, payload.path, []);
|
||||
newState = setWith(
|
||||
clone(state),
|
||||
payload.path,
|
||||
[...items, payload.value],
|
||||
clone
|
||||
clone,
|
||||
);
|
||||
debouncedUpdate(newState);
|
||||
return newState;
|
||||
|
||||
case "on_edit_item":
|
||||
delete payload.value.__temp;
|
||||
case 'on_edit_item':
|
||||
delete payload.value.temp;
|
||||
items = get(state, payload.path);
|
||||
index = findIndex(items, ["id", payload.value.id]);
|
||||
index = findIndex(items, ['id', payload.value.id]);
|
||||
newState = setWith(
|
||||
clone(state),
|
||||
`${payload.path}[${index}]`,
|
||||
payload.value,
|
||||
clone
|
||||
clone,
|
||||
);
|
||||
debouncedUpdate(newState);
|
||||
return newState;
|
||||
|
||||
case "on_delete_item":
|
||||
case 'on_delete_item':
|
||||
items = get(state, payload.path);
|
||||
index = findIndex(items, ["id", payload.value.id]);
|
||||
index = findIndex(items, ['id', payload.value.id]);
|
||||
items.splice(index, 1);
|
||||
newState = setWith(clone(state), payload.path, items, clone);
|
||||
debouncedUpdate(newState);
|
||||
return newState;
|
||||
|
||||
case "on_move_item_up":
|
||||
case 'on_move_item_up':
|
||||
items = get(state, payload.path);
|
||||
index = findIndex(items, ["id", payload.value.id]);
|
||||
index = findIndex(items, ['id', payload.value.id]);
|
||||
items = arrayMove(items, index, index - 1);
|
||||
newState = setWith(clone(state), payload.path, items, clone);
|
||||
debouncedUpdate(newState);
|
||||
return newState;
|
||||
|
||||
case "on_move_item_down":
|
||||
case 'on_move_item_down':
|
||||
items = get(state, payload.path);
|
||||
index = findIndex(items, ["id", payload.value.id]);
|
||||
index = findIndex(items, ['id', payload.value.id]);
|
||||
items = arrayMove(items, index, index + 1);
|
||||
newState = setWith(clone(state), payload.path, items, clone);
|
||||
debouncedUpdate(newState);
|
||||
return newState;
|
||||
|
||||
case "on_input":
|
||||
case 'on_input':
|
||||
newState = setWith(clone(state), payload.path, payload.value, clone);
|
||||
debouncedUpdate(newState);
|
||||
return newState;
|
||||
|
||||
case "set_data":
|
||||
case 'set_data':
|
||||
return payload;
|
||||
|
||||
default:
|
||||
throw new Error();
|
||||
}
|
||||
},
|
||||
[debouncedUpdate]
|
||||
[debouncedUpdate],
|
||||
);
|
||||
|
||||
const [state, dispatch] = useReducer(memoizedReducer, initialState);
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import firebase from "gatsby-plugin-firebase";
|
||||
import React, { createContext, useContext, useRef } from "react";
|
||||
import { toast } from "react-toastify";
|
||||
import { isFileImage } from "../utils";
|
||||
import { useDispatch, useSelector } from "./ResumeContext";
|
||||
import UserContext from "./UserContext";
|
||||
import firebase from 'gatsby-plugin-firebase';
|
||||
import React, { createContext, useContext, useRef } from 'react';
|
||||
import { toast } from 'react-toastify';
|
||||
import { isFileImage } from '../utils';
|
||||
import { useDispatch, useSelector } from './ResumeContext';
|
||||
import UserContext from './UserContext';
|
||||
|
||||
const defaultState = {
|
||||
uploadPhotograph: async () => {},
|
||||
@ -22,7 +22,7 @@ const StorageProvider = ({ children }) => {
|
||||
const uploadPhotograph = async (file) => {
|
||||
if (!isFileImage(file)) {
|
||||
toast.error(
|
||||
"You tried to upload a file that was not an image. That won't look good on your resume. Please try again."
|
||||
"You tried to upload a file that was not an image. That won't look good on your resume. Please try again.",
|
||||
);
|
||||
return null;
|
||||
}
|
||||
@ -33,16 +33,16 @@ const StorageProvider = ({ children }) => {
|
||||
.put(file);
|
||||
|
||||
let progress = 0;
|
||||
toastId.current = toast("Firing up engines...", {
|
||||
toastId.current = toast('Firing up engines...', {
|
||||
progress,
|
||||
});
|
||||
|
||||
uploadTask.on(
|
||||
"state_changed",
|
||||
'state_changed',
|
||||
(snapshot) => {
|
||||
progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
|
||||
toast.update(toastId.current, {
|
||||
render: "Uploading...",
|
||||
render: 'Uploading...',
|
||||
progress,
|
||||
hideProgressBar: false,
|
||||
});
|
||||
@ -51,23 +51,23 @@ const StorageProvider = ({ children }) => {
|
||||
async () => {
|
||||
const downloadURL = await uploadTask.snapshot.ref.getDownloadURL();
|
||||
dispatch({
|
||||
type: "on_input",
|
||||
type: 'on_input',
|
||||
payload: {
|
||||
path: "profile.photograph",
|
||||
path: 'profile.photograph',
|
||||
value: downloadURL,
|
||||
},
|
||||
});
|
||||
|
||||
toast.update(toastId.current, {
|
||||
render:
|
||||
"Your photograph was uploaded successfully... and you look great!",
|
||||
'Your photograph was uploaded successfully... and you look great!',
|
||||
progress,
|
||||
autoClose: 5000,
|
||||
hideProgressBar: true,
|
||||
});
|
||||
|
||||
toastId.current = null;
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import { flatten } from "lodash";
|
||||
import React, { createContext, useState } from "react";
|
||||
import leftSections from "../data/leftSections";
|
||||
import { flatten } from 'lodash';
|
||||
import React, { createContext, useState } from 'react';
|
||||
import leftSections from '../data/leftSections';
|
||||
|
||||
const defaultState = {
|
||||
selected: "Pikachu",
|
||||
selected: 'Pikachu',
|
||||
setSelected: () => {},
|
||||
colors: {
|
||||
textColor: "#212121",
|
||||
primaryColor: "#f44336",
|
||||
backgroundColor: "#FFFFFF",
|
||||
textColor: '#212121',
|
||||
primaryColor: '#f44336',
|
||||
backgroundColor: '#FFFFFF',
|
||||
},
|
||||
blocks: [leftSections],
|
||||
setBlocks: () => {},
|
||||
@ -60,17 +60,17 @@ const TemplateProvider = ({ children }) => {
|
||||
newState[sInd] = items;
|
||||
setBlocks(newState);
|
||||
} else {
|
||||
const result = move(blocks[sInd], blocks[dInd], source, destination);
|
||||
const newResult = move(blocks[sInd], blocks[dInd], source, destination);
|
||||
const newState = [...blocks];
|
||||
newState[sInd] = result[sInd];
|
||||
newState[dInd] = result[dInd];
|
||||
newState[sInd] = newResult[sInd];
|
||||
newState[dInd] = newResult[dInd];
|
||||
setBlocks(newState);
|
||||
}
|
||||
};
|
||||
|
||||
const setFixedBlocks = (fixedBlocks) => {
|
||||
const newBlocks = blocks.map((x) =>
|
||||
x.filter((y) => !fixedBlocks.includes(y))
|
||||
x.filter((y) => !fixedBlocks.includes(y)),
|
||||
);
|
||||
setBlocks(newBlocks);
|
||||
};
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
import React, { createContext, useEffect, useState } from "react";
|
||||
import React, { createContext, useEffect, useState } from 'react';
|
||||
|
||||
const COLOR_CONFIG = {
|
||||
light: {
|
||||
"--color-primary": "#444",
|
||||
"--color-primary-dark": "#333",
|
||||
"--color-inverse": "#fff",
|
||||
"--color-inverse-dark": "#f5f5f5",
|
||||
"--color-secondary-light": "#f7fafc",
|
||||
"--color-secondary": "#edf2f7",
|
||||
"--color-secondary-dark": "#718096",
|
||||
'--color-primary': '#444',
|
||||
'--color-primary-dark': '#333',
|
||||
'--color-inverse': '#fff',
|
||||
'--color-inverse-dark': '#f5f5f5',
|
||||
'--color-secondary-light': '#f7fafc',
|
||||
'--color-secondary': '#edf2f7',
|
||||
'--color-secondary-dark': '#718096',
|
||||
},
|
||||
dark: {
|
||||
"--color-primary": "#f5f5f5",
|
||||
"--color-primary-dark": "#eeeeee",
|
||||
"--color-inverse": "#212121",
|
||||
"--color-inverse-dark": "#181818",
|
||||
"--color-secondary-light": "#2c2c2c",
|
||||
"--color-secondary": "#444",
|
||||
"--color-secondary-dark": "#888",
|
||||
'--color-primary': '#f5f5f5',
|
||||
'--color-primary-dark': '#eeeeee',
|
||||
'--color-inverse': '#212121',
|
||||
'--color-inverse-dark': '#181818',
|
||||
'--color-secondary-light': '#2c2c2c',
|
||||
'--color-secondary': '#444',
|
||||
'--color-secondary-dark': '#888',
|
||||
},
|
||||
};
|
||||
|
||||
@ -32,7 +32,7 @@ const ThemeProvider = ({ children }) => {
|
||||
const [darkMode, setDarkMode] = useState(defaultState.darkMode);
|
||||
|
||||
useEffect(() => {
|
||||
const isDarkMode = JSON.parse(localStorage.getItem("darkMode"));
|
||||
const isDarkMode = JSON.parse(localStorage.getItem('darkMode'));
|
||||
isDarkMode ? setDarkMode(true) : setDarkMode(false);
|
||||
}, []);
|
||||
|
||||
@ -45,7 +45,7 @@ const ThemeProvider = ({ children }) => {
|
||||
|
||||
const toggleDarkMode = () => {
|
||||
setDarkMode(!darkMode);
|
||||
localStorage.setItem("darkMode", JSON.stringify(!darkMode));
|
||||
localStorage.setItem('darkMode', JSON.stringify(!darkMode));
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import firebase from "gatsby-plugin-firebase";
|
||||
import { pick } from "lodash";
|
||||
import React, { createContext, useEffect, useState } from "react";
|
||||
import { toast } from "react-toastify";
|
||||
import useAuthState from "../hooks/useAuthState";
|
||||
import firebase from 'gatsby-plugin-firebase';
|
||||
import { pick } from 'lodash';
|
||||
import React, { createContext, useEffect, useState } from 'react';
|
||||
import { toast } from 'react-toastify';
|
||||
import useAuthState from '../hooks/useAuthState';
|
||||
|
||||
const defaultUser = {
|
||||
uid: null,
|
||||
@ -25,20 +25,20 @@ const UserProvider = ({ children }) => {
|
||||
const [user, setUser] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const user = JSON.parse(localStorage.getItem("user"));
|
||||
setUser(user);
|
||||
const localUser = JSON.parse(localStorage.getItem('user'));
|
||||
setUser(localUser);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (firebaseUser) {
|
||||
const user = pick(firebaseUser, Object.keys(defaultUser));
|
||||
localStorage.setItem("user", JSON.stringify(user));
|
||||
setUser(user);
|
||||
const remoteUser = pick(firebaseUser, Object.keys(defaultUser));
|
||||
localStorage.setItem('user', JSON.stringify(remoteUser));
|
||||
setUser(remoteUser);
|
||||
|
||||
const addUserToDatabase = async () => {
|
||||
const userRef = firebase.database().ref(`users/${user.uid}`);
|
||||
const snapshot = await userRef.once("value");
|
||||
!snapshot.val() && userRef.set(user);
|
||||
const userRef = firebase.database().ref(`users/${remoteUser.uid}`);
|
||||
const snapshot = await userRef.once('value');
|
||||
!snapshot.val() && userRef.set(remoteUser);
|
||||
};
|
||||
|
||||
addUserToDatabase();
|
||||
@ -57,7 +57,7 @@ const UserProvider = ({ children }) => {
|
||||
|
||||
const logout = async () => {
|
||||
await firebase.auth().signOut();
|
||||
localStorage.removeItem("user");
|
||||
localStorage.removeItem('user');
|
||||
setUser(null);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user