Commit 17856fc7 authored by d.arizona's avatar d.arizona

change source

parent d1de1d22
{
"root": true,
"extends": "@notum-cz/eslint-config-notum-react/hooks",
"rules": {
"no-console": "off",
"prettier/prettier": "error",
"no-param-reassign": [
"error",
{
"props": true,
"ignorePropertyModificationsFor": [
"state",
"acc",
"e",
"ctx",
"req",
"request",
"res",
"response",
"$scope",
"registration"
]
}
],
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"no-alert": "off",
"@typescript-eslint/no-use-before-define": "off",
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
"no-shadow": "off"
},
"overrides": [
{
"files": ["**/store/**/*.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
]
}
# Tia-dev This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
semangat sist.. ## Available Scripts
\ No newline at end of file
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br />
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t 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 you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t 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/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `npm run build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
This diff is collapsed.
{ {
"name": "tia-dev", "name": "my-app",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@babel/core": "^7.11.0",
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
"@lingui/cli": "^2.9.1",
"@lingui/core": "^2.9.1",
"@lingui/macro": "^2.9.1",
"@lingui/react": "^2.9.1",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@notum-cz/eslint-config-notum-react": "^1.3.0",
"@sentry/browser": "^5.20.1",
"@testing-library/jest-dom": "^4.2.4", "@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0", "@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1", "@testing-library/user-event": "^7.2.1",
"@types/jest": "^24.9.1",
"@types/lingui__macro": "^2.7.3",
"@types/lingui__react": "^2.8.2",
"@types/node": "^12.12.53",
"@types/react": "^16.9.44",
"@types/react-dom": "^16.9.8",
"@types/react-redux": "^7.1.9",
"@types/react-router-dom": "^5.1.5",
"@types/redux-logger": "^3.0.8",
"babel-core": "^7.0.0-bridge.0",
"bootstrap": "^4.5.0",
"immer": "^6.0.9",
"jscpd": "^3.3.1",
"prettier": "^2.0.5",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"react-hook-form": "^5.7.2", "react-scripts": "3.4.1"
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.1",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"ts-action": "^11.0.0",
"ts-action-immer": "^3.0.3",
"typescript": "^3.7.5",
"use-immer": "^0.4.1"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject", "eject": "react-scripts eject"
"lint": "eslint src/ --ext .tsx,.ts",
"lint:fix": "eslint --fix src/ --ext .tsx,.ts",
"add-locale": "lingui add-locale",
"extract": "lingui extract",
"compile": "lingui compile",
"duplicity": "jscpd --ignore '**/*.min.js,**/*.map' ./src"
}, },
"eslintConfig": { "eslintConfig": {
"extends": "react-app" "extends": "react-app"
......
import React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
import React from "react"; import React from 'react';
import { render } from "@testing-library/react"; import { render } from '@testing-library/react';
import App from "./App"; import App from './App';
test("renders learn react link", () => { test('renders learn react link', () => {
const { getByText } = render(<App />); const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i); const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument(); expect(linkElement).toBeInTheDocument();
......
import React, { Suspense } from "react";
import "./App.css";
import { I18nProvider } from "@lingui/react";
import { useSelector } from "react-redux";
import { BrowserRouter as Router, Switch, Route, Link } from "react-router-dom";
import { getSelectedLanguage } from "./store/general/selectors";
import routes from "./router";
import { AppLanguages } from "./helpers/constants/languages";
import catalogCs from "./plugins/locales/cs/messages";
import catalogEn from "./plugins/locales/en/messages";
const catalogs: { [key in AppLanguages]: any } = {
cs: catalogCs,
en: catalogEn,
};
function App(): JSX.Element {
const language = useSelector(getSelectedLanguage);
const renderLoading = (text: string): JSX.Element => {
return <h1>{text}</h1>;
};
return (
<Suspense fallback={renderLoading("Aplikace se nacita")}>
<I18nProvider language={language} catalogs={catalogs}>
<Router>
<div>
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
</ul>
</nav>
{/* A <Switch> looks through its children <Route>s and
renders the first one that matches the current URL. */}
<Switch>
{routes.map((route) => (
<Route key={route.path} path={route.path} {...route.props} />
))}
</Switch>
</div>
</Router>
</I18nProvider>
</Suspense>
);
}
export default App;
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="6" viewBox="0 0 8 6">
<g fill="none" fill-rule="evenodd">
<path d="M0 0H23.977V24H0z" transform="rotate(90 13.5 2.5)"/>
<path fill="#4B4B4B" d="M8.998 10.02L15.002 8.998 13.975 14.998z" transform="rotate(90 13.5 2.5) rotate(45 12 11.998)"/>
</g>
</svg>
This diff is collapsed.
export enum AppLanguages {
EN = "en",
CS = "cs",
}
export const DEFAULT_LANGUAGE = AppLanguages.EN;
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
import React from "react";
import ReactDOM from "react-dom";
import "bootstrap/dist/css/bootstrap.min.css"
import * as Sentry from "@sentry/browser";
import { Provider } from "react-redux";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import store from "./store";
if (process.env.NODE_ENV === "production") {
Sentry.init({ dsn: process.env.SENTRY_DNS });
}
ReactDOM.render(
// TODO: Add <React.StrictMode> when lingui@v3 will be released
<Provider store={store}>
{/* See https://emotion.sh/docs/theming for more info */}
{/* <ThemeProvider theme={theme}> */}
<App />
{/* </ThemeProvider> */}
</Provider>,
document.getElementById("root")
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
import React from "react";
import { Trans } from "@lingui/macro";
const Home: React.FC = () => {
return (
<div>
<Trans render="h1">About</Trans>
</div>
);
};
export default Home;
import React from 'react';
import clsx from 'clsx';
import { makeStyles, useTheme } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import List from '@material-ui/core/List';
import CssBaseline from '@material-ui/core/CssBaseline';
import Typography from '@material-ui/core/Typography';
import Divider from '@material-ui/core/Divider';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import InboxIcon from '@material-ui/icons/MoveToInbox';
import MailIcon from '@material-ui/icons/Mail';
const drawerWidth = 240;
const useStyles = makeStyles((theme) => ({
root: {
display: 'flex',
},
appBar: {
zIndex: theme.zIndex.drawer + 1,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
},
appBarShift: {
marginLeft: drawerWidth,
width: `calc(100% - ${drawerWidth}px)`,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
},
menuButton: {
marginRight: 36,
},
hide: {
display: 'none',
},
drawer: {
width: drawerWidth,
flexShrink: 0,
whiteSpace: 'nowrap',
},
drawerOpen: {
width: drawerWidth,
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
},
drawerClose: {
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
overflowX: 'hidden',
width: theme.spacing(7) + 1,
[theme.breakpoints.up('sm')]: {
width: theme.spacing(9) + 1,
},
},
toolbar: {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
padding: theme.spacing(0, 1),
// necessary for content to be below app bar
...theme.mixins.toolbar,
},
content: {
flexGrow: 1,
padding: theme.spacing(3),
},
}));
export default function MiniDrawer() {
const classes = useStyles();
const theme = useTheme();
const [open, setOpen] = React.useState(false);
const handleDrawerOpen = () => {
setOpen(true);
};
const handleDrawerClose = () => {
setOpen(false);
};
return (
<div className={classes.root}>
<CssBaseline />
<AppBar
position="fixed"
className={clsx(classes.appBar, {
[classes.appBarShift]: open,
})}
>
<Toolbar style={{ flex: 1, backgroundColor: 'white' }}>
<IconButton
color="default"
aria-label="open drawer"
onClick={handleDrawerOpen}
edge="start"
className={clsx(classes.menuButton, {
[classes.hide]: open,
})}
>
<MenuIcon />
</IconButton>
<div style={{ backgroundColor: 'white', height: '70px', display: 'flex', flex: 1, placeContent: 'flex-end' }}>
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', paddingRight: 20, paddingLeft: 20 }}>
<div style={{ width: 44, height: 44, backgroundColor: '#354960', borderRadius: 30, marginRight: 10 }} />
<Typography style={{ color: 'black' }}>Tommy</Typography>
<img src={require('../assets/dropdown-white.svg')} alt="React Logo" style={{ marginLeft: 15 }} />
</div>
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', paddingRight: 10, paddingLeft: 10, borderLeftColor: '#c2c2c2', borderLeftWidth: .2, borderLeftStyle: 'solid' }}>
<img src={require('../assets/search.png')} alt="React Logo" style={{ height: 18, width: 18 }} />
</div>
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', paddingRight: 20, paddingLeft: 20, borderLeftColor: '#c2c2c2', borderLeftWidth: .2, borderLeftStyle: 'solid' }}>
<img src={require('../assets/flagEnglish.png')} alt="React Logo" style={{ height: 32, width: 32 }} />
<Typography style={{ color: 'black' }}>EN</Typography>
</div>
</div>
</Toolbar>
</AppBar>
<Drawer
variant="permanent"
className={clsx(classes.drawer, {
[classes.drawerOpen]: open,
[classes.drawerClose]: !open,
})}
classes={{
paper: clsx({
[classes.drawerOpen]: open,
[classes.drawerClose]: !open,
}),
}}
>
<div className={classes.toolbar}>
<IconButton onClick={handleDrawerClose}>
{theme.direction === 'rtl' ? <ChevronRightIcon /> : <ChevronLeftIcon />}
</IconButton>
</div>
<Divider />
<List>
{['Inbox', 'Starred', 'Send email', 'Drafts'].map((text, index) => (
<ListItem button key={text}>
<ListItemIcon>{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}</ListItemIcon>
<ListItemText primary={text} />
</ListItem>
))}
</List>
<Divider />
<List>
{['All mail', 'Trash', 'Spam'].map((text, index) => (
<ListItem button key={text}>
<ListItemIcon>{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}</ListItemIcon>
<ListItemText primary={text} />
</ListItem>
))}
</List>
</Drawer>
<main className={classes.content}>
<div className={classes.toolbar} />
<Typography paragraph>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Rhoncus dolor purus non enim praesent elementum
facilisis leo vel. Risus at ultrices mi tempus imperdiet. Semper risus in hendrerit
gravida rutrum quisque non tellus. Convallis convallis tellus id interdum velit laoreet id
donec ultrices. Odio morbi quis commodo odio aenean sed adipiscing. Amet nisl suscipit
adipiscing bibendum est ultricies integer quis. Cursus euismod quis viverra nibh cras.
Metus vulputate eu scelerisque felis imperdiet proin fermentum leo. Mauris commodo quis
imperdiet massa tincidunt. Cras tincidunt lobortis feugiat vivamus at augue. At augue eget
arcu dictum varius duis at consectetur lorem. Velit sed ullamcorper morbi tincidunt. Lorem
donec massa sapien faucibus et molestie ac.
</Typography>
<Typography paragraph>
Consequat mauris nunc congue nisi vitae suscipit. Fringilla est ullamcorper eget nulla
facilisi etiam dignissim diam. Pulvinar elementum integer enim neque volutpat ac
tincidunt. Ornare suspendisse sed nisi lacus sed viverra tellus. Purus sit amet volutpat
consequat mauris. Elementum eu facilisis sed odio morbi. Euismod lacinia at quis risus sed
vulputate odio. Morbi tincidunt ornare massa eget egestas purus viverra accumsan in. In
hendrerit gravida rutrum quisque non tellus orci ac. Pellentesque nec nam aliquam sem et
tortor. Habitant morbi tristique senectus et. Adipiscing elit duis tristique sollicitudin
nibh sit. Ornare aenean euismod elementum nisi quis eleifend. Commodo viverra maecenas
accumsan lacus vel facilisis. Nulla posuere sollicitudin aliquam ultrices sagittis orci a.
</Typography>
</main>
</div>
);
}
import "../styles/Sidebar.css";
import React from "react";
export const Sidebar = ({ width, height, children }) => {
const [xPosition, setX] = React.useState(-width);
const toggleMenu = () => {
if (xPosition < 0) {
setX(0);
} else {
setX(-width);
}
};
React.useEffect(() => {
setX(0);
}, []);
return (
<React.Fragment>
<div
className="side-bar"
style={{
transform: `translatex(${xPosition}px)`,
width: width,
minHeight: height
}}
>
<button
onClick={() => toggleMenu()}
className="toggle-menu"
style={{
transform: `translate(${width}px, 20vh)`
}}
></button>
<div className="content">{children}</div>
</div>
</React.Fragment>
);
};
\ No newline at end of file
{
"About": {
"origin": [
[
"src/pages/About.tsx",
5
]
]
}
}
\ No newline at end of file
{
"Home": {
"origin": [
[
"src/pages/Home.tsx",
5
]
]
}
}
\ No newline at end of file
/* eslint-disable */module.exports={languageData:{"plurals":function(n,ord){var s=String(n).split("."),i=s[0],v0=!s[1];if(ord)return"other";return n==1&&v0?"one":i>=2&&i<=4&&v0?"few":!v0?"many":"other"}},messages:{"About":"O nas","Home":"Domu"}};
\ No newline at end of file
{
"About": "O nas",
"Home": "Domu"
}
\ No newline at end of file
/* eslint-disable */module.exports={languageData:{"plurals":function(n,ord){var s=String(n).split("."),v0=!s[1],t0=Number(s[0])==n,n10=t0&&s[0].slice(-1),n100=t0&&s[0].slice(-2);if(ord)return n10==1&&n100!=11?"one":n10==2&&n100!=12?"two":n10==3&&n100!=13?"few":"other";return n==1&&v0?"one":"other"}},messages:{"About":"About","Home":"Home"}};
\ No newline at end of file
{
"About": "About",
"Home": "Home"
}
\ No newline at end of file
// / <reference types="react-scripts" />
declare module "*.svg" {
const content: any;
export default content;
}
declare module "*.png" {
const value: any;
export default value;
}
\ No newline at end of file
import { RouteProps } from "react-router-dom";
import { lazy } from "react";
export interface Route {
path: string;
props: RouteProps;
}
const routes: Route[] = [
{
path: "/",
props: {
component: lazy(() => import("../pages/Home")),
exact: true,
},
},
{
path: "/about",
props: {
component: lazy(() => import("../pages/About")),
exact: true,
},
},
];
export default routes;
...@@ -11,26 +11,17 @@ ...@@ -11,26 +11,17 @@
// opt-in, read https://bit.ly/CRA-PWA // opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean( const isLocalhost = Boolean(
window.location.hostname === "localhost" || window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address. // [::1] is the IPv6 localhost address.
window.location.hostname === "[::1]" || window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4. // 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match( window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
) )
); );
type Config = { export function register(config) {
onSuccess?: (registration: ServiceWorkerRegistration) => void; if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
onUpdate?: (registration: ServiceWorkerRegistration) => void;
};
export function register(config?: Config): void {
if (
process.env.NODE_ENV === "production" &&
"serviceWorker" in navigator &&
process.env.PUBLIC_URL
) {
// The URL constructor is available in all browsers that support SW. // The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) { if (publicUrl.origin !== window.location.origin) {
...@@ -40,7 +31,7 @@ export function register(config?: Config): void { ...@@ -40,7 +31,7 @@ export function register(config?: Config): void {
return; return;
} }
window.addEventListener("load", () => { window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) { if (isLocalhost) {
...@@ -51,8 +42,8 @@ export function register(config?: Config): void { ...@@ -51,8 +42,8 @@ export function register(config?: Config): void {
// service worker/PWA documentation. // service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => { navigator.serviceWorker.ready.then(() => {
console.log( console.log(
"This web app is being served cache-first by a service " + 'This web app is being served cache-first by a service ' +
"worker. To learn more, visit https://bit.ly/CRA-PWA" 'worker. To learn more, visit https://bit.ly/CRA-PWA'
); );
}); });
} else { } else {
...@@ -63,24 +54,24 @@ export function register(config?: Config): void { ...@@ -63,24 +54,24 @@ export function register(config?: Config): void {
} }
} }
function registerValidSW(swUrl: string, config?: Config): void { function registerValidSW(swUrl, config) {
navigator.serviceWorker navigator.serviceWorker
.register(swUrl) .register(swUrl)
.then((registration) => { .then(registration => {
registration.onupdatefound = (): void => { registration.onupdatefound = () => {
const installingWorker = registration.installing; const installingWorker = registration.installing;
if (installingWorker == null) { if (installingWorker == null) {
return; return;
} }
installingWorker.onstatechange = (): void => { installingWorker.onstatechange = () => {
if (installingWorker.state === "installed") { if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) { if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched, // At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older // but the previous service worker will still serve the older
// content until all client tabs are closed. // content until all client tabs are closed.
console.log( console.log(
"New content is available and will be used when all " + 'New content is available and will be used when all ' +
"tabs for this page are closed. See https://bit.ly/CRA-PWA." 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
); );
// Execute callback // Execute callback
...@@ -91,7 +82,7 @@ function registerValidSW(swUrl: string, config?: Config): void { ...@@ -91,7 +82,7 @@ function registerValidSW(swUrl: string, config?: Config): void {
// At this point, everything has been precached. // At this point, everything has been precached.
// It's the perfect time to display a // It's the perfect time to display a
// "Content is cached for offline use." message. // "Content is cached for offline use." message.
console.log("Content is cached for offline use."); console.log('Content is cached for offline use.');
// Execute callback // Execute callback
if (config && config.onSuccess) { if (config && config.onSuccess) {
...@@ -102,25 +93,25 @@ function registerValidSW(swUrl: string, config?: Config): void { ...@@ -102,25 +93,25 @@ function registerValidSW(swUrl: string, config?: Config): void {
}; };
}; };
}) })
.catch((error) => { .catch(error => {
console.error("Error during service worker registration:", error); console.error('Error during service worker registration:', error);
}); });
} }
function checkValidServiceWorker(swUrl: string, config?: Config): void { function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page. // Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, { fetch(swUrl, {
headers: { "Service-Worker": "script" }, headers: { 'Service-Worker': 'script' },
}) })
.then((response) => { .then(response => {
// Ensure service worker exists, and that we really are getting a JS file. // Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get("content-type"); const contentType = response.headers.get('content-type');
if ( if (
response.status === 404 || response.status === 404 ||
(contentType != null && contentType.indexOf("javascript") === -1) (contentType != null && contentType.indexOf('javascript') === -1)
) { ) {
// No service worker found. Probably a different app. Reload the page. // No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then((registration) => { navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => { registration.unregister().then(() => {
window.location.reload(); window.location.reload();
}); });
...@@ -132,18 +123,18 @@ function checkValidServiceWorker(swUrl: string, config?: Config): void { ...@@ -132,18 +123,18 @@ function checkValidServiceWorker(swUrl: string, config?: Config): void {
}) })
.catch(() => { .catch(() => {
console.log( console.log(
"No internet connection found. App is running in offline mode." 'No internet connection found. App is running in offline mode.'
); );
}); });
} }
export function unregister(): void { export function unregister() {
if ("serviceWorker" in navigator) { if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready navigator.serviceWorker.ready
.then((registration) => { .then(registration => {
registration.unregister(); registration.unregister();
}) })
.catch((error) => { .catch(error => {
console.error(error.message); console.error(error.message);
}); });
} }
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
// allows you to do things like: // allows you to do things like:
// expect(element).toHaveTextContent(/react/i) // expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom // learn more: https://github.com/testing-library/jest-dom
import "@testing-library/jest-dom/extend-expect"; import '@testing-library/jest-dom/extend-expect';
import { combineReducers } from "redux";
import * as general from "./general/reducers";
export interface CombinedState {
general: general.State;
}
export const initialState: CombinedState = {
general: general.initialState,
};
export const reducer = combineReducers<CombinedState>({
general: general.generalReducer,
});
import { reducer } from "ts-action";
import {
AppLanguages,
DEFAULT_LANGUAGE,
} from "../../helpers/constants/languages";
export interface State {
language: AppLanguages;
}
export const initialState: State = {
language: DEFAULT_LANGUAGE,
};
export const generalReducer = reducer<State>(initialState);
import { AppLanguages } from "../../helpers/constants/languages";
import { CombinedState } from "../combinedReducers";
export const getSelectedLanguage = (state: CombinedState): AppLanguages =>
state.general.language;
import { applyMiddleware, createStore } from "redux";
import logger from "redux-logger";
import thunk from "redux-thunk";
import { reducer } from "./combinedReducers";
const store = createStore(reducer, applyMiddleware(logger, thunk));
export default store;
.side-bar {
height: 100% !important;
display: flex;
flex-direction: column;
border-right: 1px solid;
border-radius: 0;
border-color: rgba(64, 194, 133, 0.693);
background-color: rgb(255, 255, 255);
transition: 0.8s ease;
}
.toggle-menu {
height: 50px;
border-top-right-radius: 10rem;
border-bottom-right-radius: 9rem;
width: 10px;
position: absolute;
outline: none;
z-index: 1;
background-color: rgba(64, 194, 133, 0.693);
border-color: rgba(64, 194, 133, 0.693);
border-left: 0;
}
\ No newline at end of file
https://create-react-app.dev/docs/running-tests/
\ No newline at end of file
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"src"
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment