Merge branch 'master' of github.com:BradNut/weddingsite

This commit is contained in:
Bradley Shellnut 2021-11-18 17:45:20 -08:00
commit 3b27635906
17 changed files with 63 additions and 233 deletions

View file

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

View file

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

View file

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

82
package-lock.json generated
View file

@ -2056,36 +2056,6 @@
} }
} }
}, },
"node_modules/@next/swc-darwin-arm64": {
"version": "11.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-11.1.2.tgz",
"integrity": "sha512-hZuwOlGOwBZADA8EyDYyjx3+4JGIGjSHDHWrmpI7g5rFmQNltjlbaefAbiU5Kk7j3BUSDwt30quJRFv3nyJQ0w==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "11.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-11.1.2.tgz",
"integrity": "sha512-PGOp0E1GisU+EJJlsmJVGE+aPYD0Uh7zqgsrpD3F/Y3766Ptfbe1lEPPWnRDl+OzSSrSrX1lkyM/Jlmh5OwNvA==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-gnu": { "node_modules/@next/swc-linux-x64-gnu": {
"version": "11.1.2", "version": "11.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-11.1.2.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-11.1.2.tgz",
@ -2101,21 +2071,6 @@
"node": ">= 10" "node": ">= 10"
} }
}, },
"node_modules/@next/swc-win32-x64-msvc": {
"version": "11.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-11.1.2.tgz",
"integrity": "sha512-e/pIKVdB+tGQYa1cW3sAeHm8gzEri/HYLZHT4WZojrUxgWXqx8pk7S7Xs47uBcFTqBDRvK3EcQpPLf3XdVsDdg==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@node-rs/helper": { "node_modules/@node-rs/helper": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/@node-rs/helper/-/helper-1.2.1.tgz", "resolved": "https://registry.npmjs.org/@node-rs/helper/-/helper-1.2.1.tgz",
@ -4857,19 +4812,6 @@
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true "dev": true
}, },
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": { "node_modules/function-bind": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@ -9943,30 +9885,12 @@
"integrity": "sha512-hsoJmPfhVqjZ8w4IFzoo8SyECVnN+8WMnImTbTKrRUHOVJcYMmKLL7xf7T0ft00tWwAl/3f3Q3poWIN2Ueql/Q==", "integrity": "sha512-hsoJmPfhVqjZ8w4IFzoo8SyECVnN+8WMnImTbTKrRUHOVJcYMmKLL7xf7T0ft00tWwAl/3f3Q3poWIN2Ueql/Q==",
"requires": {} "requires": {}
}, },
"@next/swc-darwin-arm64": {
"version": "11.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-11.1.2.tgz",
"integrity": "sha512-hZuwOlGOwBZADA8EyDYyjx3+4JGIGjSHDHWrmpI7g5rFmQNltjlbaefAbiU5Kk7j3BUSDwt30quJRFv3nyJQ0w==",
"optional": true
},
"@next/swc-darwin-x64": {
"version": "11.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-11.1.2.tgz",
"integrity": "sha512-PGOp0E1GisU+EJJlsmJVGE+aPYD0Uh7zqgsrpD3F/Y3766Ptfbe1lEPPWnRDl+OzSSrSrX1lkyM/Jlmh5OwNvA==",
"optional": true
},
"@next/swc-linux-x64-gnu": { "@next/swc-linux-x64-gnu": {
"version": "11.1.2", "version": "11.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-11.1.2.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-11.1.2.tgz",
"integrity": "sha512-YcDHTJjn/8RqvyJVB6pvEKXihDcdrOwga3GfMv/QtVeLphTouY4BIcEUfrG5+26Nf37MP1ywN3RRl1TxpurAsQ==", "integrity": "sha512-YcDHTJjn/8RqvyJVB6pvEKXihDcdrOwga3GfMv/QtVeLphTouY4BIcEUfrG5+26Nf37MP1ywN3RRl1TxpurAsQ==",
"optional": true "optional": true
}, },
"@next/swc-win32-x64-msvc": {
"version": "11.1.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-11.1.2.tgz",
"integrity": "sha512-e/pIKVdB+tGQYa1cW3sAeHm8gzEri/HYLZHT4WZojrUxgWXqx8pk7S7Xs47uBcFTqBDRvK3EcQpPLf3XdVsDdg==",
"optional": true
},
"@node-rs/helper": { "@node-rs/helper": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/@node-rs/helper/-/helper-1.2.1.tgz", "resolved": "https://registry.npmjs.org/@node-rs/helper/-/helper-1.2.1.tgz",
@ -12063,12 +11987,6 @@
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true "dev": true
}, },
"fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"optional": true
},
"function-bind": { "function-bind": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",

View file

@ -56,7 +56,10 @@
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
"wesbos" "wesbos"
] ],
"rules": {
"react/prop-types": 0
}
}, },
"//": "This is our babel config, I prefer this over a .babelrc file", "//": "This is our babel config, I prefer this over a .babelrc file",
"babel": { "babel": {

View file

@ -8,7 +8,7 @@ export default function FourOhFourPage() {
</Head> </Head>
<h1>Sorry page not found!</h1> <h1>Sorry page not found!</h1>
<p>404.</p> <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 { export default class MyDocument extends Document {
static getInitialProps({ renderPage }) { static getInitialProps({ renderPage }) {
const sheet = new ServerStyleSheet(); const sheet = new ServerStyleSheet();
const page = renderPage((App) => (props) => const page = renderPage(
sheet.collectStyles(<App {...props} />) (App) => (props) => sheet.collectStyles(<App {...props} />)
); );
const styleTags = sheet.getStyleElement(); const styleTags = sheet.getStyleElement();
return { ...page, styleTags }; return { ...page, styleTags };

View file

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

View file

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

View file

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

View file

@ -129,13 +129,13 @@ export default function PartyPage() {
{weddingParty.map((party, index) => ( {weddingParty.map((party, index) => (
<PartyCard className="card" key={index}> <PartyCard className="card" key={index}>
<h2 className="center">{party.name}</h2> <h2 className="center">{party.name}</h2>
<CustomNextImage <CustomNextImage
src="https://via.placeholder.com/1200x1600.png" src="https://via.placeholder.com/1200x1600.png"
alt={`${party.name} - ${party.title}`} alt={`${party.name} - ${party.title}`}
objectFit="cover" objectFit="cover"
width="1200" width="1200"
height="1600" height="1600"
/> />
<h3 className="center">{party.title}</h3> <h3 className="center">{party.title}</h3>
</PartyCard> </PartyCard>
))} ))}

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

@ -36,9 +36,7 @@ export default function QandAPage() {
<QAStyles> <QAStyles>
<ol> <ol>
<li>Question 1</li> <li>Question 1</li>
<p> <p>Answer 1</p>
Answer 1
</p>
<li>How do I get to the venue?</li> <li>How do I get to the venue?</li>
<p> <p>
See more detailed info on our{' '} See more detailed info on our{' '}

View file

@ -297,7 +297,7 @@ export default function SingleGroupPage({ group }) {
gap: '1rem', gap: '1rem',
}} }}
> >
{group.guests.map((guest) => {group?.guests?.map((guest) =>
!guest.isPlusOne ? ( !guest.isPlusOne ? (
<QuestionStyles key={`${guest?.id}-dietaryNotes`}> <QuestionStyles key={`${guest?.id}-dietaryNotes`}>
<p> <p>
@ -329,7 +329,7 @@ export default function SingleGroupPage({ group }) {
gap: '1rem', gap: '1rem',
}} }}
> >
{group.guests.map((guest) => {group?.guests?.map((guest) =>
!guest?.isPlusOne ? ( !guest?.isPlusOne ? (
<QuestionStyles key={`${guest?.id}-songRequests`}> <QuestionStyles key={`${guest?.id}-songRequests`}>
<p> <p>

View file

@ -78,9 +78,7 @@ export default function TravelAndStayPage() {
<div> <div>
<h2>Hotel Information</h2> <h2>Hotel Information</h2>
<h2>Do I need to book a hotel room?</h2> <h2>Do I need to book a hotel room?</h2>
<p> <p>Answer</p>
Answer
</p>
<p>There are also hotels in the area such as:</p> <p>There are also hotels in the area such as:</p>
<ul> <ul>
<li> <li>
@ -104,7 +102,8 @@ export default function TravelAndStayPage() {
Example 1 <RiExternalLinkLine /> Example 1 <RiExternalLinkLine />
</a> </a>
</li> </li>
<p>Travel Time: X minute drive (X miles)</p><li> <p>Travel Time: X minute drive (X miles)</p>
<li>
<a <a
href="https://www.hotelexample.com/" href="https://www.hotelexample.com/"
aria-label="Name of Hotel" aria-label="Name of Hotel"

View file

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