Skip to content

Commit

Permalink
add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
annarhughes committed Oct 24, 2023
1 parent 0aec55f commit 99a17f0
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 75 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ root: true
extends:
- "plugin:react/recommended"
- airbnb
- prettier
globals:
Atomics: readonly
SharedArrayBuffer: readonly
Expand Down
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all"
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@
"@material-ui/icons": "^4.9.1",
"add": "^2.0.6",
"axios": "^0.21.0",
"eslint-config-prettier": "^9.0.0",
"firebase": "^9.9.4",
"firebaseui": "^6.0.1",
"html-to-pdfmake": "^2.1.2",
"http-proxy-middleware": "^1.0.6",
"md5": "^2.3.0",
"next": "11",
"pdfmake": "^0.1.68",
"prettier": "^3.0.3",
"prop-types": "^15.7.2",
"react": "17.0.2",
"react-cookie-consent": "^6.1.0",
Expand Down
139 changes: 64 additions & 75 deletions src/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
import { Box, Button, makeStyles, Typography } from "@material-ui/core";
import CssBaseline from "@material-ui/core/CssBaseline";
import LinkUi from "@material-ui/core/Link";
import { ThemeProvider } from "@material-ui/core/styles";
import "firebaseui/dist/firebaseui.css";
import dynamic from "next/dynamic";
import Link from "next/link";
import { useRouter } from "next/router";
import PropTypes from "prop-types";
import React, { useEffect, useRef, useState } from "react";
import CookieConsent, { getCookieConsentValue } from "react-cookie-consent";
import { useAuthState } from "react-firebase-hooks/auth";
import { hotjar } from "react-hotjar";
import { Provider } from "react-redux";
import Head from "../components/Head";
import Header from "../components/Header";
import Loading from "../components/Loading";
import firebase from "../config/firebase";
import analyticsEvent from "../shared/analyticsEvent";
import { axiosGet } from "../shared/axios";
import isBrowser from "../shared/browserCheck";
import useWindowDimensions from "../shared/dimensions";
import { useStore } from "../store/store";
import "../styles/hotjarNPS.css";
import theme from "../styles/theme";
import { Box, Button, makeStyles, Typography } from '@material-ui/core';
import CssBaseline from '@material-ui/core/CssBaseline';
import LinkUi from '@material-ui/core/Link';
import { ThemeProvider } from '@material-ui/core/styles';
import 'firebaseui/dist/firebaseui.css';
import dynamic from 'next/dynamic';
import Link from 'next/link';
import { useRouter } from 'next/router';
import PropTypes from 'prop-types';
import React, { useEffect, useRef, useState } from 'react';
import CookieConsent, { getCookieConsentValue } from 'react-cookie-consent';
import { useAuthState } from 'react-firebase-hooks/auth';
import { hotjar } from 'react-hotjar';
import { Provider } from 'react-redux';
import Head from '../components/Head';
import Header from '../components/Header';
import Loading from '../components/Loading';
import firebase from '../config/firebase';
import analyticsEvent from '../shared/analyticsEvent';
import { axiosGet } from '../shared/axios';
import isBrowser from '../shared/browserCheck';
import useWindowDimensions from '../shared/dimensions';
import { useStore } from '../store/store';
import '../styles/hotjarNPS.css';
import theme from '../styles/theme';

const Footer = dynamic(() => import("../components/Footer"), { ssr: false });
const Footer = dynamic(() => import('../components/Footer'), { ssr: false });

const useStyles = makeStyles({
screenContainer: {
margin: 0,
[theme.breakpoints.up("sm")]: {
height: "100vh",
[theme.breakpoints.up('sm')]: {
height: '100vh',
},
},

desktopScreenContainer: {},
backgroundBlue: {
background: "url('/backgroundBlue.png')",
backgroundSize: "100% 100%",
backgroundRepeat: "no-repeat",
backgroundSize: '100% 100%',
backgroundRepeat: 'no-repeat',
},
backgroundPeach: {
background: "url('/backgroundPeach.png')",
backgroundSize: "100% 100%",
backgroundRepeat: "no-repeat",
backgroundSize: '100% 100%',
backgroundRepeat: 'no-repeat',
},
cookieContainer: {
position: "static !important",
display: "flex",
flexWrap: "wrap",
position: 'static !important',
display: 'flex',
flexWrap: 'wrap',
},
cookieButtonContainer: {
display: "flex",
display: 'flex',
},
cookieButton: {
margin: 5,
Expand All @@ -61,9 +61,9 @@ const useStyles = makeStyles({
height: 40,
},
cookieContent: {
display: "flex",
justifyContent: "space-between",
width: "100%",
display: 'flex',
justifyContent: 'space-between',
width: '100%',
},
});

Expand All @@ -73,14 +73,14 @@ function App({ Component, pageProps }) {
const { height, width } = useWindowDimensions();
const [user] = isBrowser ? useAuthState(firebase.auth()) : [{}];
const [isLoading, setIsLoading] = useState(false);
const [background, setBackground] = useState("Peach");
const [background, setBackground] = useState('Peach');

const containerRef = useRef();
const scrollTopRef = useRef();

useEffect(() => {
// Remove the server-side injected CSS.
const jssStyles = document.querySelector("#jss-server-side");
const jssStyles = document.querySelector('#jss-server-side');
if (jssStyles) {
jssStyles.parentElement.removeChild(jssStyles);
}
Expand All @@ -91,7 +91,7 @@ function App({ Component, pageProps }) {
// or if the router changes (i.e the user navigates)
const checkTermsAcceptance = async (u) => {
const idToken = await u.getIdToken();
const serverUser = await axiosGet("/profile", {
const serverUser = await axiosGet('/profile', {
headers: {
authorization: `Bearer ${idToken}`,
},
Expand All @@ -102,13 +102,13 @@ function App({ Component, pageProps }) {
checkTermsAcceptance(user).then((termsAccepted) => {
// If there is a verified user but they haven't accepted the terms, reroute them to sign-in
if (!termsAccepted) {
router.push("/sign-in");
router.push('/sign-in');
}
if (
process.env.NEXT_PUBLIC_ENV === "production" &&
getCookieConsentValue("ConsentToCookie") === "true"
process.env.NEXT_PUBLIC_ENV === 'production' &&
getCookieConsentValue('ConsentToCookie') === 'true'
) {
hotjar.identify("USER_ID", { userProperty: user.id });
hotjar.identify('USER_ID', { userProperty: user.id });
}
});
} else if (user && !user.emailVerified) {
Expand All @@ -118,33 +118,31 @@ function App({ Component, pageProps }) {
}, [user]);

useEffect(() => {
router.events.on("routeChangeStart", () => {
router.events.on('routeChangeStart', () => {
setIsLoading(true);
});
router.events.on("routeChangeComplete", () => {
analyticsEvent("page_view");
router.events.on('routeChangeComplete', () => {
analyticsEvent('page_view');
setIsLoading(false);
});
router.events.on("routeChangeError", () => {
router.events.on('routeChangeError', () => {
setIsLoading(false);
});

if (process.env.NEXT_PUBLIC_ENV === "production") {
if (process.env.NEXT_PUBLIC_ENV === 'production') {
hotjar.initialize(Number(process.env.NEXT_PUBLIC_HOTJAR_ID), 6);
}
}, []);

useEffect(() => {
const routesWithoutBackgrounds = ["/settings", "/saved", "/themes/[slug]"];
const routesWithBlueBackgrounds = [
"/resources/[resourceSlug]/items/[itemId]",
];
const routesWithoutBackgrounds = ['/settings', '/saved', '/themes/[slug]'];
const routesWithBlueBackgrounds = ['/resources/[resourceSlug]/items/[itemId]'];
if (routesWithoutBackgrounds.includes(router.pathname)) {
setBackground("None");
setBackground('None');
} else if (routesWithBlueBackgrounds.includes(router.pathname)) {
setBackground("Blue");
setBackground('Blue');
} else {
setBackground("Peach");
setBackground('Peach');
}
}, [router]);

Expand Down Expand Up @@ -199,23 +197,18 @@ function App({ Component, pageProps }) {
>
<Box color="primary.light">
<Typography color="textPrimary">
We use cookies on YSM for a number of reasons that include
making our sites secure, robust and analysing how our site
is being used, which allows us to create more diverse
content.{" "}
We use cookies on YSM for a number of reasons that include making our sites
secure, robust and analysing how our site is being used, which allows us to
create more diverse content.{' '}
<Link href="/info/cookies" passHref>
<LinkUi
component="a"
color="inherit"
underline="always"
>
<LinkUi component="a" color="inherit" underline="always">
Learn More.
</LinkUi>
</Link>
</Typography>
<Typography color="textPrimary">
You can choose to accept or reject this kind of tracking.
We love you either way.
You can choose to accept or reject this kind of tracking. We love you either
way.
</Typography>
</Box>
<img
Expand All @@ -225,7 +218,7 @@ function App({ Component, pageProps }) {
/>
</CookieConsent>
</Box>
{process.env.NEXT_PUBLIC_ENV === "staging" ? (
{process.env.NEXT_PUBLIC_ENV === 'staging' ? (
<Box bgcolor="error.main" p={2}>
<Typography align="center" color="textPrimary">
You are currently viewing the staging environment.
Expand All @@ -242,11 +235,7 @@ function App({ Component, pageProps }) {
className={classes[`background${background}`]}
>
<Box ref={scrollTopRef} />
{isLoading ? (
<Loading />
) : (
<Component {...pageProps} container={containerRef} />
)}
{isLoading ? <Loading /> : <Component {...pageProps} container={containerRef} />}
</Box>

<Footer />
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3939,6 +3939,11 @@ eslint-config-airbnb@^18.2.0:
object.assign "^4.1.2"
object.entries "^1.1.2"

eslint-config-prettier@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz#eb25485946dd0c66cd216a46232dc05451518d1f"
integrity sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==

eslint-import-resolver-node@^0.3.7:
version "0.3.9"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz#d4eaac52b8a2e7c3cd1903eb00f7e053356118ac"
Expand Down Expand Up @@ -6487,6 +6492,11 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==

prettier@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643"
integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==

pretty-format@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812"
Expand Down

0 comments on commit 99a17f0

Please sign in to comment.