Updating dependencies and fixing issues on update.

This commit is contained in:
Bradley Shellnut 2021-10-04 11:12:27 -07:00
parent e84e20e0f1
commit ca57a2390b
14 changed files with 14820 additions and 171 deletions

View file

@ -46,24 +46,31 @@ export default function Event({ event }) {
</div>
{showSchedule &&
scheduleEvents &&
scheduleEvents.map(({ name, start, end, venueName }) => (
<ScheduleStyle key={name} className="schedule-event">
<div>
{start && (
<h3>
{start}
{end && ` - {end}`}
</h3>
)}
</div>
<div>
{name && <h3>{name}</h3>}
{venueName && (
<div dangerouslySetInnerHTML={{ __html: venueName }} />
)}
</div>
</ScheduleStyle>
))}
scheduleEvents.map(
({
name: eventName,
start: eventStart,
end: eventEnd,
venueName: eventVenueName,
}) => (
<ScheduleStyle key={name} className="schedule-event">
<div>
{eventStart && (
<h3>
{eventStart}
{eventEnd && ` - {end}`}
</h3>
)}
</div>
<div>
{eventName && <h3>{eventName}</h3>}
{eventVenueName && (
<div dangerouslySetInnerHTML={{ __html: eventVenueName }} />
)}
</div>
</ScheduleStyle>
)
)}
</EventStyles>
);
}

View file

@ -7,6 +7,9 @@ const Layout = ({ children }) => (
<Head>
<title>NN By the Sea</title>
</Head>
<noscript>
<h1>Please enable JavaScript to view our site.</h1>
</noscript>
<main>
<div className="container">{children}</div>
</main>

View file

@ -18,5 +18,7 @@ export default function WeddingStart() {
update: 60000,
});
return <>{timeAsDays}</>;
return (
<span style={{ color: '#e64c44', fontSize: '3.157rem' }}>{timeAsDays}</span>
);
}

14732
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -10,49 +10,53 @@
},
"dependencies": {
"babel-core": "^6.26.3",
"babel-plugin-styled-components": "^1.12.0",
"babel-plugin-styled-components": "^1.13.2",
"bcryptjs": "^2.4.3",
"cloudinary-build-url": "^0.2.1",
"dotenv": "^10.0.0",
"escape-html": "^1.0.3",
"jsonwebtoken": "^8.5.1",
"mongodb": "^3.6.9",
"mongoose": "^5.12.13",
"next": "^10.2.3",
"mongodb": "^4.1.2",
"mongoose": "^6.0.8",
"next": "^11.1.2",
"next-iron-session": "^4.2.0",
"next-with-apollo": "^5.1.1",
"next-with-apollo": "^5.2.1",
"normalize.css": "^8.0.1",
"nprogress": "^0.2.0",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"styled-components": "^5.3.0",
"styled-components": "^5.3.1",
"swr": "^0.5.6",
"waait": "^1.0.5"
},
"devDependencies": {
"@babel/core": "^7.14.3",
"@babel/preset-env": "^7.14.4",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.28.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-config-wesbos": "^2.0.0-beta.7",
"eslint-plugin-html": "^6.1.2",
"eslint-plugin-import": "^2.23.4",
"eslint-config-wesbos": "^2.0.1",
"eslint-plugin-html": "^6.2.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.0",
"eslint-plugin-react-hooks": "^4.2.0",
"prettier": "^2.3.1",
"typescript": "^4.3.2"
"prettier": "^2.4.1",
"typescript": "^4.4.3"
},
"eslintConfig": {
"extends": [
"wesbos"
]
],
"rules": {
"react/prop-types": 0
}
},
"//": "This is our babel config, I prefer this over a .babelrc file",
"babel": {
@ -108,4 +112,4 @@
}
}
}
}
}

View file

@ -8,7 +8,7 @@ export default function FourOhFourPage() {
</Head>
<h1>Sorry page not found!</h1>
<p>404.</p>
<p>You just hit a route that doesn&#39;t exist.</p>
<p>You just hit a route that doesn't exist.</p>
</>
);
}

View file

@ -4,8 +4,8 @@ import { ServerStyleSheet } from 'styled-components';
export default class MyDocument extends Document {
static getInitialProps({ renderPage }) {
const sheet = new ServerStyleSheet();
const page = renderPage((App) => (props) =>
sheet.collectStyles(<App {...props} />)
const page = renderPage(
(App) => (props) => sheet.collectStyles(<App {...props} />)
);
const styleTags = sheet.getStyleElement();
return { ...page, styleTags };

View file

@ -1,3 +1,4 @@
import escape from 'escape-html';
import withSession from '../../lib/session';
import Group from '../../models/Group';
import Guest from '../../models/Guest';
@ -60,7 +61,7 @@ export default withSession(async (req, res) => {
try {
// TODO: REMOVE THIS WHEN TAKING YOUR SITE TO PRODUCTION
if (process.env.SITE_ENV === 'TEST_SITE') {
console.log('DONE!')
console.log('DONE!');
res.status(200).json(JSON.stringify({ message: 'SUCCESS' }));
} else {
const { groupId, guests, note } = body;
@ -70,8 +71,8 @@ export default withSession(async (req, res) => {
const accepted = guest?.rsvpStatus === 'accepted';
guestData.rsvpStatus =
guest?.rsvpStatus !== 'invited' ? guest?.rsvpStatus : 'invited';
guestData.dietaryNotes = guest?.dietaryNotes;
guestData.songRequests = guest?.songRequests;
guestData.dietaryNotes = escape(guest?.dietaryNotes);
guestData.songRequests = escape(guest?.songRequests);
guestData.plusOne =
(guestData?.hasPlusOne && guest?.plusOne && accepted) || false;
guestData.plusOneFirstName =
@ -81,7 +82,7 @@ export default withSession(async (req, res) => {
guestData.save();
}
await Group.findByIdAndUpdate(groupId, {
note,
note: escape(note),
});
res.status(200).json(JSON.stringify({ message: 'SUCCESS' }));
}

View file

@ -1,4 +1,5 @@
import bcrypt from 'bcryptjs';
import escape from 'escape-html';
import withSession from '../../lib/session';
import connectDb from '../../utils/db';
import User from '../../models/User';
@ -14,7 +15,7 @@ export default withSession(async (req, res) => {
}
try {
if (username && password && penguin && penguin === 'penguin') {
if (username && password && penguin && escape(penguin) === 'penguin') {
let isAuthorized = false;
// TODO: REMOVE THIS IF GOING TO PRODUCTION
@ -24,7 +25,7 @@ export default withSession(async (req, res) => {
await req.session.save();
res.json(user);
} else {
const userData = await User.findOne({ username });
const userData = await User.findOne({ username: escape(username) });
const savedPassword = userData?.password || '';
isAuthorized = await compare(password, savedPassword);
if (isAuthorized) {

View file

@ -1,3 +1,4 @@
import escape from 'escape-html';
import withSession from '../../lib/session';
import connectDb from '../../utils/db.js';
import Guest from '../../models/Guest';
@ -25,8 +26,8 @@ export default withSession(async (req, res) => {
try {
const result = await Guest.findOne({
firstName: { $regex: new RegExp(firstName.trim(), 'i') },
lastName: { $regex: new RegExp(lastName.trim(), 'i') },
firstName: { $regex: new RegExp(escape(firstName.trim()), 'i') },
lastName: { $regex: new RegExp(escape(lastName.trim()), 'i') },
});
// console.log(JSON.stringify(result));
res.status(200).json({ status: 'SUCCESS', groupId: result.group });

View file

@ -1,37 +0,0 @@
import useUser from '../lib/useUser'
import Layout from '../components/Layout'
const SgProfile = () => {
const { user } = useUser({ redirectTo: '/login' })
if (!user || user.isLoggedIn === false) {
return <Layout>Loading...</Layout>
}
return (
<Layout>
<h1>Your GitHub profile</h1>
<h2>
This page uses{' '}
<a href="https://nextjs.org/docs/basic-features/pages#static-generation-recommended">
Static Generation (SG)
</a>{' '}
and the <a href="/api/user">/api/user</a> route (using{' '}
<a href="https://github.com/zeit/swr">SWR</a>)
</h2>
<p style={{ fontStyle: 'italic' }}>
Public data, from{' '}
<a href={githubUrl(user.login)}>{githubUrl(user.login)}</a>, reduced to
`login` and `avatar_url`.
</p>
<pre>{JSON.stringify(user, null, 2)}</pre>
</Layout>
)
}
function githubUrl(login) {
return `https://api.github.com/users/${login}`
}
export default SgProfile

View file

@ -1,61 +0,0 @@
import PropTypes from 'prop-types';
import Layout from '../components/Layout';
import withSession from '../lib/session';
const SsrProfile = ({ user }) => (
<Layout>
<h1>Your GitHub profile</h1>
<h2>
This page uses{' '}
<a href="https://nextjs.org/docs/basic-features/pages#server-side-rendering">
Server-side Rendering (SSR)
</a>{' '}
and{' '}
<a href="https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering">
getServerSideProps
</a>
</h2>
{user?.isLoggedIn && (
<>
<p style={{ fontStyle: 'italic' }}>
Public data, from{' '}
<a href={githubUrl(user.login)}>{githubUrl(user.login)}</a>, reduced
to `login` and `avatar_url`.
</p>
<pre>{JSON.stringify(user, null, 2)}</pre>
</>
)}
</Layout>
);
export const getServerSideProps = withSession(async ({ req, res }) => {
const user = req.session.get('user');
if (!user) {
return {
redirect: {
destination: '/login',
permanent: false,
},
};
}
return {
props: { user: req.session.get('user') },
};
});
export default SsrProfile;
function githubUrl(login) {
return `https://api.github.com/users/${login}`;
}
SsrProfile.propTypes = {
user: PropTypes.shape({
isLoggedIn: PropTypes.bool,
login: PropTypes.string,
avatarUrl: PropTypes.string,
}),
};

View file

@ -163,9 +163,8 @@ export default function SingleGroupPage({ group }) {
return initial;
}
const { inputs, handleChange, clearForm, resetForm } = useForm(
getInitialFormData
);
const { inputs, handleChange, clearForm, resetForm } =
useForm(getInitialFormData);
if (!user || user.isLoggedIn === false) {
return <Layout>Loading...</Layout>;
@ -288,7 +287,7 @@ export default function SingleGroupPage({ group }) {
gap: '1rem',
}}
>
{group.guests.map((guest) =>
{group?.guests?.map((guest) =>
!guest.isPlusOne ? (
<QuestionStyles key={`${guest?.id}-dietaryNotes`}>
<p>
@ -320,7 +319,7 @@ export default function SingleGroupPage({ group }) {
gap: '1rem',
}}
>
{group.guests.map((guest) =>
{group?.guests?.map((guest) =>
!guest?.isPlusOne ? (
<QuestionStyles key={`${guest?.id}-songRequests`}>
<p>
@ -391,18 +390,20 @@ export async function getServerSideProps({ params }) {
if (process.env.SITE_ENV === 'TEST_SITE') {
const group = {};
group.id = params.id;
group.guests = [{
id: 'TEST_GUEST_ID_12345',
firstName: 'Test',
lastName: 'Lastname',
rsvpStatus: false,
dietaryNotes: '',
songRequests: '',
hasPlusOne: true,
plusOne: false,
plusOneFirstName: '',
plusOneLastName: '',
}];
group.guests = [
{
id: 'TEST_GUEST_ID_12345',
firstName: 'Test',
lastName: 'Lastname',
rsvpStatus: false,
dietaryNotes: '',
songRequests: '',
hasPlusOne: true,
plusOne: false,
plusOneFirstName: '',
plusOneLastName: '',
},
];
group.note = '';
return { props: { group } };
}

View file

@ -9,12 +9,7 @@ async function connectDb() {
if (mongoose.connection.readyState >= 1) {
return;
}
return mongoose.connect(url, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
useCreateIndex: true,
});
return mongoose.connect(url);
}
export default connectDb;