Skip to content

Instantly share code, notes, and snippets.

@jinwook-k
jinwook-k / App.scss
Last active August 30, 2020 23:04
client/src/Stylesheets/...
@import "Header";
@import "WeatherForm";
@import "Container";
@import "WeatherPanels";
@font-face {
font-family: MajorMonoDisplay;
src: url("../assets/Fonts/MajorMonoDisplay-Regular.ttf");
}
@jinwook-k
jinwook-k / App.jsx
Created August 30, 2020 00:06
client/src/App.jsx
import React, {Component} from 'react';
import './Stylesheets/App.scss';
import Container from "./Components/Container";
class App extends Component {
render() {
return (
<div className="App">
<Container/>
@jinwook-k
jinwook-k / Container.jsx
Created August 30, 2020 08:11
client/src/Components...
import React, {Component} from "react";
import WeatherForm from "./WeatherForm";
import WeatherPanels from "./WeatherPanels";
class Container extends Component {
state = {
weatherData: ''
};
render() {
{
"name": "mern-weather-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server/server.js",
"server": "nodemon server/server.js",
"client": "cd client && npm run start",
"dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\""
@jinwook-k
jinwook-k / package.json
Created September 4, 2020 05:49
client/package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"bootstrap": "^4.5.0",
@jinwook-k
jinwook-k / WeatherForm.jsx
Last active September 23, 2020 16:28
client/src/Components/WeatherForm.jsx
// other imports
import axios from 'axios';
class WeatherForm extends Component {
// default state values
componentDidMount() {
this.refreshSavedWeather();
}
@jinwook-k
jinwook-k / index.js
Created September 4, 2020 21:37
client/src/actions
export const saveZipCode = (zipCode) => {
return {
type: "SAVE_ZIP",
payload: zipCode
}
}
export const saveWeatherData = (data) => {
return {
type: "SAVE_WEATHER_DATA",
// Get initial state from the previously saved data in local storage
let getHistoryFromLocal = () => {
let value = localStorage.getItem('WeatherHistory')
return JSON.parse(value) || [];
}
// Maintain a history list of queried weather data of 10
let getUpdatedHistory = (history, value) => {
let updateList = [...history];
if (updateList.length >= 10) {
@jinwook-k
jinwook-k / index.js
Created September 5, 2020 01:10
client/src
// other imports
...
// Adding redux and reducers
import { createStore } from 'redux'
import { Provider } from 'react-redux'
import rootReducer from './reducers'
// Creates our store to use our reducers and the chrome extension to debug the redux store
const store = createStore(
@jinwook-k
jinwook-k / WeatherForm.jsx
Last active September 23, 2020 16:41
client/src/Components
// imports
import {connect} from "react-redux";
import {saveZipCode, saveWeatherData, saveTemperature, updateHistory} from "../actions";
class WeatherForm extends Component {
// default state values
// componentDidMount()
refreshSavedWeather = () => {
if (localStorage.getItem("zipCode")) {