Merge pull request #1 from codevictory/v01

Version one
This commit is contained in:
Veikko Lintujärvi
2022-01-04 22:15:31 +02:00
committed by GitHub
81 changed files with 4406 additions and 492 deletions

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Veikko Lintujärvi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,46 +1,25 @@
# Getting Started with Create React App
# Wedding application
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
Supports relatively secure way to collect visitor registrations to [Firebase](https://firebase.google.com/) without backend. Also offers wedding info website in multiple languages (instructions how it works coming later...).
## Available Scripts
## Local development
In the project directory, you can run:
```
root/directory$ npm install && npm start
```
### `yarn start`
## Firestore setup
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
To be added...
The page will reload if you make edits.\
You will also see any lint errors in the console.
## Deployment
### `yarn test`
Via GitHub actions and Firebase hosting.
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
Setup to be specified.
### `yarn build`
## About usage
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
Feel free to fork, use and change this at will.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `yarn eject`
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
Please mention this repo in footer or something. Clearer instructions to be specified.

3331
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,30 +3,32 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"antd": "^4.16.13",
"firebase": "^9.1.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-intl": "^5.21.1",
"react-router-dom": "^5.3.0",
"react-scripts": "4.0.3",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
"recoil": "^0.5.2",
"sass": "^1.43.4",
"typescript": "^4.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"extract-intl": "NODE_ENV=development extract-messages -l=en,fi,sk -o src/translations -d en --flat false 'src/**/!(*.test).js'"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
"react-app"
]
},
"browserslist": {
@@ -43,5 +45,9 @@
},
"optionalDependencies": {
"fsevents": "^2.3.2"
},
"devDependencies": {
"@types/react-router-dom": "^5.3.1",
"extract-react-intl-messages": "^4.1.1"
}
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -1,43 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Lintu ja Maslo</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Lintu ja Maslo</title>
</head>
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

BIN
public/logo192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
public/logo512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -20,6 +20,6 @@
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
"theme_color": "#a7ab81",
"background_color": "#efefea"
}

View File

@@ -1,14 +0,0 @@
.App {
text-align: center;
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

1
src/App.scss Normal file
View File

@@ -0,0 +1 @@
@import 'antd/dist/antd.variable.min.css';

View File

@@ -1,14 +1,34 @@
import './App.css';
import './App.scss';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import { useRecoilValue } from 'recoil';
import { currentLanguage } from './atoms/language';
import { Main } from './pages/Main';
import { Registration } from './pages/Registration';
import { Confirmation } from './pages/Confirmation';
import { IntlProvider } from 'react-intl';
import { localization } from './constants/localization';
import { ConfigProvider } from 'antd';
export default function App() {
const language = useRecoilValue(currentLanguage);
ConfigProvider.config({
theme: {
primaryColor: '#a7ab81',
},
});
function App() {
return (
<div className="App">
<header className="App-header">
<h1>Lintu ja Maslo</h1>
<p><i>Elokuussa 2022</i></p>
</header>
</div>
<IntlProvider locale={language} messages={localization[language]}>
<Router>
<Switch>
<Route path='/' exact component={Main} />
<Route path='/confirmation' exact component={Confirmation} />
<Route path='/:page' exact component={Main} />
<Route path='/registration/:id' component={Registration} />
</Switch>
</Router>
</IntlProvider>
);
}
export default App;

View File

@@ -1,4 +1,7 @@
import { initializeApp } from "firebase/app";
import { getFirestore, setDoc, doc } from "firebase/firestore";
import { Visitor } from './model/visitor';
const firebaseConfig = {
apiKey: "AIzaSyBcE9X0ueyczUqpjm0bK9UDrzvDmB96pr4",
@@ -9,4 +12,29 @@ const firebaseConfig = {
appId: "1:110340750803:web:89f5187720e77fc2788326"
};
const app = initializeApp(firebaseConfig);
initializeApp(firebaseConfig);
const db = getFirestore();
export const addVisitor = async (visitor: Visitor): Promise<string> => {
try {
await setDoc(doc(db, "visitors", visitor.name), {
invitationId: visitor.invitationId,
allergies: visitor.allergies,
welcomeDrink: visitor.welcomeDrink,
preferences: visitor.preferences
});
} catch(error: any) {
return error.code;
}
return 'success';
}
export const submitInvitation = async (invitationId: string): Promise<string> => {
try {
await setDoc(doc(db, "submitted", invitationId), {});
} catch(error: any) {
return error.code;
}
return 'success';
}

6
src/atoms/language.ts Normal file
View File

@@ -0,0 +1,6 @@
import { atom } from 'recoil';
export const currentLanguage = atom<string>({
key: "currentLanguage",
default: "fi"
})

3
src/colors.scss Normal file
View File

@@ -0,0 +1,3 @@
$brown-text: #c1a57c;
$green-text: #a7ab81;
$background: #efefea;

View File

@@ -0,0 +1,43 @@
@import '../colors.scss';
.DateAndPlace {
text-align: center;
text-transform: uppercase;
margin-bottom: 1rem;
h2 {
font-family: 'Montserrat-Medium';
color: $brown-text !important;
margin-bottom: -0.7rem !important;
&.large {
font-size: 2rem !important;
}
&.small {
font-size: 1.4rem !important;
}
}
h3 {
color: $brown-text !important;
&.large {
font-size: 1.4rem !important;
}
&.small {
font-size: 0.8rem !important;
}
}
}
@media screen and (max-width: 600px) {
.DateAndPlace {
h2.large {
font-size: 1.5rem !important;
}
h3.large {
font-size: 1rem !important;
}
}
}

View File

@@ -0,0 +1,17 @@
import './DateAndPlace.scss';
import { FormattedMessage } from 'react-intl';
export const DateAndPlace = (props: { size: string }) => {
return (
<div className='DateAndPlace'>
<h2 className={props.size}>
<FormattedMessage id='common.datetime' />
</h2>
<h3 className={props.size}>
<FormattedMessage id='common.place' />
</h3>
</div>
);
};

View File

@@ -0,0 +1,5 @@
.Diamond {
margin-bottom: 1rem;
margin-left: 2rem;
margin-right: 2rem;
}

View File

@@ -0,0 +1,18 @@
import './Diamond.scss';
export const Diamond = () => {
return (
<svg
className='Diamond'
width='9'
height='9'
fill='#c1a57c'
viewBox='0 0 16 16'
>
<path
fill-rule='evenodd'
d='M6.95.435c.58-.58 1.52-.58 2.1 0l6.515 6.516c.58.58.58 1.519 0 2.098L9.05 15.565c-.58.58-1.519.58-2.098 0L.435 9.05a1.482 1.482 0 0 1 0-2.098L6.95.435z'
/>
</svg>
);
};

14
src/components/Info.scss Normal file
View File

@@ -0,0 +1,14 @@
@import '../colors.scss';
.Info {
h1 {
font-size: 4rem;
}
h2 {
font-size: 2rem;
color: $green-text;
margin-left: 3rem;
margin-right: 3rem;
}
}

15
src/components/Info.tsx Normal file
View File

@@ -0,0 +1,15 @@
import { FormattedMessage } from 'react-intl';
import './Info.scss';
export const Info = () => {
return (
<section className='Info'>
<h1>
<FormattedMessage id='main.info' />
</h1>
<h2>
<FormattedMessage id='main.toBeDecided' />
</h2>
</section>
);
};

View File

@@ -0,0 +1,24 @@
@import '../colors.scss';
.LanguagePicker {
text-align: center;
color: $brown-text !important;
font-family: 'Montserrat-Medium';
button {
text-transform: uppercase;
border: none;
background-color: $background;
width: 3rem;
}
button:hover {
background-color: #e4e4de;
}
}
@media screen and (max-width: 600px) {
.LanguagePicker {
font-size: 1.6rem;
}
}

View File

@@ -0,0 +1,15 @@
import { useRecoilState } from 'recoil';
import { currentLanguage } from '../atoms/language';
import './LanguagePicker.scss';
export const LanguagePicker = () => {
const [lang, setLang] = useRecoilState(currentLanguage);
return (
<h1 className='LanguagePicker'>
<button onClick={(e) => setLang('fi')}>fi</button> |{' '}
<button onClick={(e) => setLang('sk')}>sk</button> |{' '}
<button onClick={(e) => setLang('en')}>en</button>
</h1>
);
};

14
src/components/Menu.scss Normal file
View File

@@ -0,0 +1,14 @@
@import '../colors.scss';
.Menu {
h1 {
font-size: 4rem;
}
h2 {
font-size: 2rem;
color: $green-text;
margin-left: 3rem;
margin-right: 3rem;
}
}

15
src/components/Menu.tsx Normal file
View File

@@ -0,0 +1,15 @@
import { FormattedMessage } from 'react-intl';
import './Menu.scss';
export const Menu = () => {
return (
<section className='Menu'>
<h1>
<FormattedMessage id='main.menu' />
</h1>
<h2>
<FormattedMessage id='main.toBeDecided' />
</h2>
</section>
);
};

View File

@@ -0,0 +1,19 @@
.NavBar {
display: flex;
justify-content: space-around;
align-items: center;
margin-bottom: 1em;
font-size: 2rem;
.Diamond {
margin-right: 1rem;
margin-left: 1rem;
margin-bottom: 0;
}
}
@media screen and (max-width: 600px) {
.NavBar {
flex-direction: column;
}
}

22
src/components/NavBar.tsx Normal file
View File

@@ -0,0 +1,22 @@
import './NavBar.scss';
import { Link } from 'react-router-dom';
import { Diamond } from './Diamond';
import { FormattedMessage } from 'react-intl';
export const NavBar = () => {
return (
<div className='NavBar'>
<Link to='/menu'>
<FormattedMessage id='main.menu' />
</Link>
<Diamond />
<Link to='/program'>
<FormattedMessage id='main.program' />
</Link>
<Diamond />
<Link to='/info'>
<FormattedMessage id='main.info' />
</Link>
</div>
);
};

View File

View File

@@ -0,0 +1,10 @@
import "./NotFound.scss";
export const NotFound = () => {
return (
<section>
<h1>Page not found</h1>
<p>Check the link address...</p>
</section>
)
}

View File

@@ -0,0 +1,14 @@
@import '../colors.scss';
.Program {
h1 {
font-size: 4rem;
}
h2 {
font-size: 2rem;
color: $green-text;
margin-left: 3rem;
margin-right: 3rem;
}
}

View File

@@ -0,0 +1,16 @@
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router-dom';
import './Program.scss';
export const Program = () => {
return (
<section className='Program'>
<h1>
<FormattedMessage id='main.program' />
</h1>
<h2>
<FormattedMessage id='main.toBeDecided' />
</h2>
</section>
);
};

View File

@@ -0,0 +1,93 @@
@import '../colors.scss';
form#registration {
max-width: 24.5em;
padding: 1em;
display: flex;
flex-direction: column;
align-items: center;
}
.visitors {
display: flex;
width: 72vw;
flex-wrap: wrap;
justify-content: space-evenly;
}
.visitor {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 1em;
margin-bottom: 1em;
padding: 1em;
border-radius: 5px;
background-color: $background;
width: 400px;
font-family: 'Montserrat-Medium';
label {
color: $brown-text !important;
}
input,
label,
span {
font-size: 1.3rem;
height: unset;
}
.ant-form-item {
width: 100%;
.ant-form-item-label {
width: 100%;
text-align: left;
}
.ant-select-arrow svg {
padding-bottom: 7px;
}
.anticon-close svg {
padding-top: 3px;
}
}
}
.addVisitorButton {
font-family: 'Montserrat-Medium';
color: $green-text !important;
font-size: 1.5rem !important;
height: unset !important;
background-color: transparent;
text-transform: uppercase;
border-width: 0.2rem;
border-color: $green-text;
:hover {
background-color: $background !important;
}
}
.submitButton {
font-family: 'Montserrat-Medium';
color: $green-text !important;
font-size: 2rem !important;
height: unset !important;
background-color: transparent;
text-transform: uppercase;
border-width: 0.2rem;
border-color: $green-text;
:hover {
background-color: $background !important;
}
}
@media screen and (max-width: 600px) {
.submitButton {
max-width: 100%;
white-space: break-spaces;
}
}

298
src/components/RegForm.tsx Normal file
View File

@@ -0,0 +1,298 @@
import { Button, Form, Input, Modal, notification, Select } from 'antd';
import { useParams } from 'react-router';
import './RegForm.scss';
import { addVisitor, submitInvitation } from '../api';
import { arrayToString } from './utils';
import { Visitor } from '../model/visitor';
import { FormattedMessage, useIntl } from 'react-intl';
import { useState } from 'react';
import { withRouter } from 'react-router-dom';
const { Option } = Select;
interface ParamTypes {
id: string;
}
interface FormValues {
visitors: Visitor[];
}
const preferences = ['vegan', 'vegetarian', 'everything'].map((preference) => {
return (
<Option key={preference} value={preference}>
<FormattedMessage id={'registration.form.preferences.' + preference} />
</Option>
);
});
const allergies = ['lactose', 'dairy', 'gluten', 'wheat'].map((allergy) => {
return (
<Option key={allergy} value={allergy}>
<FormattedMessage id={'registration.form.allergies.' + allergy} />
</Option>
);
});
const welcomeDrinks = ['alcoholBubbles', 'alcoholFreeBubbles'].map(
(welcomeDrink) => {
return (
<Option key={welcomeDrink} value={welcomeDrink}>
<FormattedMessage
id={'registration.form.welcomeDrink.' + welcomeDrink}
/>
</Option>
);
}
);
const RegForm = ({ history }: any) => {
const { id } = useParams<ParamTypes>();
const intl = useIntl();
const [visitorCount, setVisitorCount] = useState(0);
const [isSubmitModalVisible, setIsSubmitModalVisible] = useState(false);
const [isDeclineModalVisible, setIsDeclineModalVisible] = useState(false);
const [isDeclined, setIsDeclined] = useState(false);
var decodedInvitationId = atob(id);
const onSubmit = (values: FormValues) => {
let responseCode: string = '';
values.visitors = values.visitors ?? [];
values.visitors.map((visitor) => {
addVisitor({
...visitor,
allergies: visitor.allergies ? arrayToString(visitor.allergies) : '',
preferences: visitor.preferences ?? '',
welcomeDrink: visitor.welcomeDrink ?? '',
invitationId: (visitor.invitationId = decodedInvitationId),
}).then((res) => (responseCode = res));
});
submitInvitation(decodedInvitationId).then((res) => (responseCode = res));
responseCode !== 'success' ? showError() : history.push('/confirmation');
};
const onDecline = () => {
let responseCode: string = '';
submitInvitation(decodedInvitationId).then((res) => (responseCode = res));
responseCode !== 'success' ? showError() : history.push('/confirmation');
};
const onSubmitOk = () => {
form.submit();
setIsSubmitModalVisible(false);
};
const onSubmitCancel = () => {
setIsSubmitModalVisible(false);
};
const onDeclineOk = () => {
form.submit();
setIsDeclineModalVisible(false);
};
const onDeclineCancel = () => {
setIsDeclineModalVisible(false);
};
const showError = () => {
notification.error({
message: intl.formatMessage({ id: 'registration.error.title' }),
description: intl.formatMessage({ id: 'registration.error.text' }),
duration: 0,
placement: 'bottomLeft',
});
};
const [form] = Form.useForm();
return (
<>
<Form
form={form}
name='registration'
onFinish={isDeclined ? onDecline : onSubmit}
autoComplete='off'
>
<Form.List name='visitors'>
{(fields, { add, remove }) => (
<>
<div className='visitors'>
{fields.map((field) => (
<div className='visitor' key={field.key}>
<Form.Item
label={intl.formatMessage({
id: 'registration.form.name',
})}
name={[field.name, 'name']}
fieldKey={[field.fieldKey, 'name']}
rules={[
{
required: true,
message: intl.formatMessage({
id: 'registration.form.name.missing',
}),
},
]}
>
<Input
placeholder={intl.formatMessage({
id: 'registration.form.name.placeholder',
})}
/>
</Form.Item>
<Form.Item
name={[field.name, 'allergies']}
label={intl.formatMessage({
id: 'registration.form.allergies',
})}
fieldKey={[field.fieldKey, 'allergies']}
>
<Select
mode='tags'
placeholder={intl.formatMessage({
id: 'registration.form.allergies.placeholder',
})}
>
{allergies}
</Select>
</Form.Item>
<Form.Item
name={[field.name, 'preferences']}
label={intl.formatMessage({
id: 'registration.form.preferences',
})}
fieldKey={[field.fieldKey, 'preferences']}
initialValue='everything'
>
<Select>{preferences}</Select>
</Form.Item>
<Form.Item
name={[field.name, 'welcomeDrink']}
label={intl.formatMessage({
id: 'registration.form.welcomeDrink',
})}
rules={[
{
required: true,
message: intl.formatMessage({
id: 'registration.form.welcomeDrink.missing',
}),
},
]}
fieldKey={[field.fieldKey, 'welcomeDrink']}
>
<Select
placeholder={intl.formatMessage({
id: 'registration.form.welcomeDrink.placeholder',
})}
>
{welcomeDrinks}
</Select>
</Form.Item>
<Button
danger
onClick={() => {
remove(field.name);
setVisitorCount(visitorCount - 1);
}}
shape='round'
size='large'
>
<FormattedMessage id='registration.form.remove' />
</Button>
</div>
))}
</div>
<Form.Item>
<Button
className='addVisitorButton'
size='large'
onClick={() => {
add();
setVisitorCount(visitorCount + 1);
}}
shape='round'
>
<FormattedMessage id='registration.addVisitor' />
</Button>
</Form.Item>
</>
)}
</Form.List>
{visitorCount == 0 ? (
<Form.Item>
<Button
className='submitButton'
onClick={(_) => {
setIsDeclined(true);
setIsDeclineModalVisible(true);
}}
type='dashed'
shape='round'
>
<FormattedMessage id='registration.form.decline' />
</Button>
</Form.Item>
) : (
<Form.Item>
<Button
className='submitButton'
onClick={(_) => setIsSubmitModalVisible(true)}
size='large'
shape='round'
>
<FormattedMessage id='registration.form.submit' />
</Button>
</Form.Item>
)}
</Form>
<Modal
title={intl.formatMessage(
{
id: 'registration.form.submitModal.title',
},
{ visitorCount: visitorCount }
)}
visible={isSubmitModalVisible}
onOk={onSubmitOk}
onCancel={onSubmitCancel}
okText={intl.formatMessage({
id: 'registration.form.submitModal.save',
})}
cancelText={intl.formatMessage({
id: 'registration.form.submitModal.back',
})}
>
<p>
<FormattedMessage id='registration.form.submitModal.description' />
</p>
</Modal>
<Modal
title={intl.formatMessage({
id: 'registration.form.declineModal.title',
})}
visible={isDeclineModalVisible}
onOk={onDeclineOk}
onCancel={onDeclineCancel}
okText={intl.formatMessage({
id: 'registration.form.declineModal.save',
})}
cancelText={intl.formatMessage({
id: 'registration.form.declineModal.back',
})}
>
<p>
<FormattedMessage id='registration.form.declineModal.description' />
</p>
</Modal>
</>
);
};
export default withRouter(RegForm);

View File

@@ -0,0 +1,39 @@
@import '../colors.scss';
.App-header {
display: flex;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
margin-top: 2rem;
gap: 1rem;
h1 {
color: $green-text !important;
text-transform: uppercase;
font-size: 3rem;
font-family: 'Montserrat-Light';
span {
color: $brown-text;
font-size: 0.5em;
}
}
}
@media screen and (max-width: 600px) {
.Diamond {
margin: 0;
width: 0;
height: 0;
}
.App-header {
flex-direction: column;
h1 {
font-size: 2rem;
margin-bottom: -3rem;
}
}
}

View File

@@ -0,0 +1,21 @@
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router-dom';
import { DateAndPlace } from './DateAndPlace';
import { Diamond } from './Diamond';
import './RegistrationHeader.scss';
export const RegistrationHeader = () => {
return (
<header className='App-header'>
<h1>
<Link to='/'>
<FormattedMessage id='common.lintu' />
<span> &amp; </span>
<FormattedMessage id='common.maslo' />
</Link>
</h1>
<Diamond />
<DateAndPlace size='small' />
</header>
);
};

3
src/components/utils.ts Normal file
View File

@@ -0,0 +1,3 @@
export const arrayToString = (str: string) => {
return str.toString().replaceAll(",", ", ");
}

View File

@@ -0,0 +1,6 @@
import { LanguageItem } from '../types/languageItem';
export const languageItems: LanguageItem[] = [
{ label: "Suomi", value: "fi" },
{ label: "Englanti", value: "en" }
];

View File

@@ -0,0 +1,6 @@
export const common: Record<string, string> = {
"common.lintu": "Lintu",
"common.maslo": "Maslo",
"common.datetime": "August 27",
"common.place": "Seurantalo | Livonsaari"
}

View File

@@ -0,0 +1,6 @@
export const common: Record<string, string> = {
"common.lintu": "Lintu",
"common.maslo": "Maslo",
"common.datetime": "Elokuun 27",
"common.place": "Seurantalo | Livonsaari"
}

View File

@@ -0,0 +1,5 @@
export const confirmation: Record<string, string> = {
"confirmation.title": "Your answer is registered",
"confirmation.text": "Please let Iveta or Veikko know if there comes up any changes in your plans. The given link does not work any longer after this.",
"confirmation.link": "More wedding related info can be found in here",
}

View File

@@ -0,0 +1,5 @@
export const confirmation: Record<string, string> = {
"confirmation.title": "Vastuksesi on vahvistettu",
"confirmation.text": "Ilmoitathan Ivetalle tai Veikolle mikäli suunnitelmiisi tulee muutos. Antamamme linkki ei toimi enää tämän jälkeen.",
"confirmation.link": "Lisää juhliin liittyvää infoa löytyy täältä",
}

View File

@@ -0,0 +1,13 @@
import { common } from "./common/en";
import { registration } from './registration/en';
import { main } from "./main/en";
import { confirmation } from './confirmation/en';
const en: Record<string, string> = {
...common,
...registration,
...main,
...confirmation
}
export default en;

View File

@@ -0,0 +1,13 @@
import { common } from "./common/fi";
import { registration } from "./registration/fi";
import { main } from "./main/fi";
import { confirmation } from './confirmation/fi';
const fi: Record<string, string> = {
...common,
...registration,
...main,
...confirmation
}
export default fi;

View File

@@ -0,0 +1,7 @@
import fi from "./fi";
import en from "./en";
export const localization: { [key: string]: Record<string, string> } = {
fi,
en
}

View File

@@ -0,0 +1,8 @@
export const main: Record<string, string> = {
"main.program": "Program",
"main.menu": "Menu",
"main.info": "Info",
"main.saveTheLink": "Save the link",
"main.welcome": "Tervetuloa! Welcome! Vitajte!",
"main.toBeDecided": "To be specified"
}

View File

@@ -0,0 +1,8 @@
export const main: Record<string, string> = {
"main.program": "Ohjelma",
"main.menu": "Menu",
"main.info": "Info",
"main.saveTheLink": "Laita linkki talteen",
"main.welcome": "Tervetuloa! Welcome! Vitajte!",
"main.toBeDecided": "Selviää myöhemmin"
}

View File

@@ -0,0 +1,49 @@
export const registration: Record<string, string> = {
"registration.welcome": "Welcome to our wedding table",
"registration.datetime": "27th of August",
"registration.place": "Seurantalo in Livonsaari",
"registration.questions": "If you have any question about:\n\ndirections\naccomodation\nwhatever else\n\ncontact us on emails veikko@lintujarvi.fi or maslakova.iveta@gmail.com",
"registration.about": "We will be updating the program and menu in",
"registration.saveTheLink": "Save the link",
"registration.fillInBefore": "Please fill the visitors until the end of April",
"registration.addVisitor": "Add visitor",
"registration.form.submit": "Submit",
"registration.form.decline": "Decline invitation",
"registration.form.remove": "Remove",
"registration.form.name": "Name",
"registration.form.name.placeholder": "Full or nickname",
"registration.form.name.missing": "Missing name",
"registration.form.allergies": "Food allergies (select or write)",
"registration.form.allergies.placeholder": "Everything goes",
"registration.form.allergies.lactose": "Lactose",
"registration.form.allergies.dairy": "Dairy",
"registration.form.allergies.gluten": "Gluten",
"registration.form.allergies.wheat": "Wheat",
"registration.form.preferences": "Food preferences",
"registration.form.preferences.everything": "Everything goes",
"registration.form.preferences.vegan": "Vegan",
"registration.form.preferences.vegetarian": "Vegetarian",
"registration.form.welcomeDrink": "Welcome drink",
"registration.form.welcomeDrink.placeholder": "What fancy you?",
"registration.form.welcomeDrink.missing": "Missing welcome drink",
"registration.form.welcomeDrink.alcoholBubbles": "Alcohol bubbles",
"registration.form.welcomeDrink.alcoholFreeBubbles": "Alcohol-free bubbles",
"registration.form.submitModal.title": "You want to add {visitorCount} visitors?",
"registration.form.submitModal.description": "The link will not work after the submit.",
"registration.form.submitModal.save": "Yes, please",
"registration.form.submitModal.back": "No, something is missing...",
"registration.form.declineModal.title": "You are sure you cannot attend?",
"registration.form.declineModal.description": "Sad to hear that. The link will not work after the submit.",
"registration.form.declineModal.save": "Unfortunately yes",
"registration.form.declineModal.back": "Let me still think about this...",
"registration.error.title": "Link is no longer valid",
"registration.error.text": "Your registration is already filled in. Apologies for the excess form filling...",
}

View File

@@ -0,0 +1,49 @@
export const registration: Record<string, string> = {
"registration.welcome": "Tervetuloa häihimme",
"registration.datetime": "Elokuun 27. päivänä",
"registration.place": "Livonsaaren Seurantalolle",
"registration.questions": "Jos sinulla on mitään kysymyksiä:\n\nAjo-ohjeista\nmajoituksesta\nmistä tahansa muusta\n\nlaitathan mailia veikko@lintujarvi.fi tai maslakova.iveta@gmail.com",
"registration.about": "Päivitämme menua ja ohjelmaa osoitteeseen",
"registration.saveTheLink": "Laita linkki talteen",
"registration.fillInBefore": "Lisääthän teiltä osallistuvat henkilöt huhtikuun loppuun mennessä",
"registration.addVisitor": "Lisää osallistuja",
"registration.form.submit": "Vahvista",
"registration.form.decline": "Kieltäydyn kutsusta",
"registration.form.remove": "Poista",
"registration.form.name": "Nimi",
"registration.form.name.placeholder": "Koko tai lempinimi",
"registration.form.name.missing": "Nimi puuttuu",
"registration.form.allergies": "Ruoka-allergiat (valitse tai kirjoita)",
"registration.form.allergies.placeholder": "Kaikki käy",
"registration.form.allergies.lactose": "Laktoosi",
"registration.form.allergies.dairy": "Maitotuotteet",
"registration.form.allergies.gluten": "Gluteeni",
"registration.form.allergies.wheat": "Vehnä",
"registration.form.preferences": "Erikoisruokavalio",
"registration.form.preferences.everything": "Kaikki käy",
"registration.form.preferences.vegan": "Vegaaninen",
"registration.form.preferences.vegetarian": "Kasvis",
"registration.form.welcomeDrink": "Tervetuliasmalja",
"registration.form.welcomeDrink.placeholder": "Mitä saisi olla?",
"registration.form.welcomeDrink.missing": "Tervetulias malja puuttuu",
"registration.form.welcomeDrink.alcoholBubbles": "Holillista kuplivaa",
"registration.form.welcomeDrink.alcoholFreeBubbles": "Holitonta kuplivaa",
"registration.form.submitModal.title": "Lisätään siis {visitorCount} vierasta listalle?",
"registration.form.submitModal.description": "Tämä linkki lakkaa toimimasta tallennuksen jälkeen.",
"registration.form.submitModal.save": "Tallenna",
"registration.form.submitModal.back": "Takaisin",
"registration.form.declineModal.title": "Et siis tosiaankaan pääse paikalle?",
"registration.form.declineModal.description": "Harmin paikka. Tämä linkki lakkaa toimimasta tallennuksen jälkeen.",
"registration.form.declineModal.save": "Valitettavasti en",
"registration.form.declineModal.back": "Takaisin",
"registration.error.title": "Linkki ei ole enää voimassa",
"registration.error.text": "Ilmoittautumisesi on jo kirjattu. Pahoittelu ylimääräisestä lomakkeen täyttelystä...",
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
src/img/bg-flowers.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 KiB

BIN
src/img/lintujamaslo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
src/img/main-bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 KiB

View File

@@ -1,13 +0,0 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

33
src/index.scss Normal file
View File

@@ -0,0 +1,33 @@
@import './colors.scss';
@font-face {
font-family: 'Montserrat-Medium';
src: url(./fonts/Montserrat/Montserrat-Medium.ttf);
}
@font-face {
font-family: 'Montserrat-Light';
src: url(./fonts/Montserrat/Montserrat-Light.ttf);
}
body {
margin: 0;
font-family: 'Montserrat-Light', 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif !important;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: $green-text !important;
background-color: $background !important;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
#root {
background-image: url('./img/bg-flowers.png');
background-repeat: no-repeat;
background-size: cover;
min-height: 100%;
}

View File

@@ -1,17 +1,17 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import { RecoilRoot } from 'recoil';
import './index.scss';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { ConfigProvider } from 'antd';
ReactDOM.render(
<React.StrictMode>
<App />
<RecoilRoot>
<ConfigProvider>
<App />
</ConfigProvider>
</RecoilRoot>
</React.StrictMode>,
document.getElementById('root')
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

7
src/model/visitor.ts Normal file
View File

@@ -0,0 +1,7 @@
export type Visitor = {
name: string;
invitationId: string;
allergies: any;
welcomeDrink: any;
preferences: string;
}

View File

@@ -0,0 +1,36 @@
@import '../colors.scss';
.Confirmation {
text-align: center;
display: flex;
align-items: center;
flex-direction: column;
padding-top: 1rem;
font-size: 1.5rem;
h1 {
color: $brown-text;
font-size: 3.2rem;
}
p {
max-width: 48%;
}
a {
color: $brown-text;
font-family: 'Montserrat-Medium';
.infoLink {
text-decoration: underline;
}
}
}
@media screen and (max-width: 600px) {
.Confirmation {
p {
max-width: 90%;
}
}
}

View File

@@ -0,0 +1,23 @@
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router-dom';
import './Confirmation.scss';
export const Confirmation = () => {
return (
<div className='Confirmation'>
<h1>
<FormattedMessage id='confirmation.title' />
</h1>
<p>
<FormattedMessage id='confirmation.text' />
</p>
<Link to='/'>
&gt;{' '}
<span className='infoLink'>
<FormattedMessage id='confirmation.link' />
</span>{' '}
&lt;
</Link>
</div>
);
};

82
src/pages/Main.scss Normal file
View File

@@ -0,0 +1,82 @@
@import '../colors.scss';
.Main {
text-align: center;
display: flex;
align-items: center;
flex-direction: column;
.Main-container {
display: flex;
flex-direction: column;
align-items: center;
border: 2px solid;
border-color: $brown-text;
border-radius: 300px;
padding-right: 10rem;
padding-left: 10rem;
.logo-container {
margin-top: 3rem;
}
.Main-title {
line-height: 4rem;
font-family: 'Montserrat-Light';
color: $green-text !important;
font-size: 5rem;
text-transform: uppercase;
margin-bottom: 0px;
}
.Main-and {
color: $brown-text;
font-size: 3rem;
margin-top: 0em;
margin-bottom: 0em;
}
.content {
h1 {
color: $brown-text;
font-size: 3.2rem;
}
}
}
.extraText {
color: $brown-text;
font-size: 1.1rem;
text-transform: uppercase;
margin-bottom: 8px;
margin-top: 8px;
letter-spacing: 2px;
}
}
@media screen and (max-width: 600px) {
.extraText {
max-width: 50%;
font-weight: bold;
}
.Main {
.Main-container {
border-radius: 91px;
padding-right: 2rem;
padding-left: 2rem;
width: 90%;
.Main-title {
line-height: 2rem;
font-size: 4rem;
text-transform: uppercase;
margin-bottom: 0px;
}
.logo-container {
margin-bottom: 3rem;
}
}
}
}

66
src/pages/Main.tsx Normal file
View File

@@ -0,0 +1,66 @@
import './Main.scss';
import { Link, useParams } from 'react-router-dom';
import { Menu } from '../components/Menu';
import { NavBar } from '../components/NavBar';
import { Program } from '../components/Program';
import { NotFound } from '../components/NotFound';
import { LanguagePicker } from '../components/LanguagePicker';
import { FormattedMessage } from 'react-intl';
import { DateAndPlace } from '../components/DateAndPlace';
import { Info } from '../components/Info';
interface MainParams {
page: string;
}
export const Main = () => {
const { page } = useParams<MainParams>();
return (
<div className='Main'>
<LanguagePicker />
<p className='extraText'>
<FormattedMessage id='main.saveTheLink' />
</p>
<section className='Main-container'>
<article className='logo-container'>
<Link to='/'>
<h1 className='Main-title'>
<FormattedMessage id='common.lintu' />
</h1>
<h2 className='Main-and'>
<span> &amp; </span>
</h2>
<h1 className='Main-title'>
<FormattedMessage id='common.maslo' />
</h1>
</Link>
</article>
<article>
<NavBar />
</article>
{page ? (
<article className='content'>
{page === 'menu' ? (
<Menu />
) : page === 'program' ? (
<Program />
) : page === 'info' ? (
<Info />
) : (
<NotFound />
)}
</article>
) : (
<article>
<DateAndPlace size='large' />
</article>
)}
</section>
<p className='extraText'>
<FormattedMessage id='main.welcome' />
</p>
</div>
);
};

View File

@@ -0,0 +1,89 @@
@import '../colors.scss';
.Registration {
display: flex;
align-items: center;
flex-direction: column;
white-space: pre-line;
text-align: center;
.Registration-main {
display: flex;
flex-direction: column;
align-items: center;
max-width: 50%;
text-transform: uppercase;
.Registration-welcome {
margin-bottom: 0;
text-align: center;
}
img {
max-width: 60%;
}
h1 {
font-family: 'Montserrat-Medium';
text-align: center;
color: $brown-text;
font-size: 2.3rem;
}
h2 {
color: $brown-text !important;
font-family: 'Montserrat-Light';
margin-top: -1rem;
font-size: 2rem;
}
}
.Registration-desc {
max-width: 23rem;
margin-top: 3rem;
text-transform: uppercase;
max-width: 30%;
p {
font-size: 1.5rem;
color: $brown-text !important;
font-weight: bold;
}
}
.Registration-form {
display: flex;
justify-content: center;
}
}
@media screen and (max-width: 600px) {
.Registration {
.Registration-main {
max-width: 80%;
.Registration-welcome {
color: $green-text !important;
margin-bottom: 28px;
margin-top: 0px;
}
}
.Registration-desc {
max-width: 90%;
p {
font-family: 'Montserrat-Medium';
font-weight: unset;
}
}
h2 {
font-size: 1.5rem !important;
text-align: center;
}
h1 {
font-size: 2rem !important;
}
}
}

View File

@@ -0,0 +1,47 @@
import './Registration.scss';
import { FormattedMessage } from 'react-intl';
import RegForm from '../components/RegForm';
import { RegistrationHeader } from '../components/RegistrationHeader';
import { LanguagePicker } from '../components/LanguagePicker';
import { Link } from 'react-router-dom';
export const Registration = () => {
return (
<>
<RegistrationHeader />
<LanguagePicker />
<main className='Registration'>
<div className='Registration-main'>
<h1 className='Registration-welcome'>
<FormattedMessage id='registration.welcome' />
</h1>
<h1>
<FormattedMessage id='registration.datetime' />
</h1>
<h2>
<FormattedMessage id='registration.place' />
</h2>
</div>
<div className='Registration-desc'>
<p>
<FormattedMessage id='registration.questions' />
</p>
<p>
<FormattedMessage id='registration.about' />{' '}
<Link to='/'>lintujamaslo.net</Link>
</p>
<p>
&gt; <FormattedMessage id='registration.saveTheLink' /> &lt;
</p>
<p>
<FormattedMessage id='registration.fillInBefore' />
</p>
</div>
<div className='Registration-form'>
<RegForm />
</div>
</main>
</>
);
};

View File

@@ -1,15 +0,0 @@
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@@ -1,5 +0,0 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

View File

@@ -0,0 +1,4 @@
export type LanguageItem = {
label: string;
value: string;
}