Skip to content
This repository has been archived by the owner on Dec 25, 2022. It is now read-only.

Commit

Permalink
Init project
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen Manh Tung committed Aug 7, 2022
1 parent ddb2b5c commit bd12454
Show file tree
Hide file tree
Showing 29 changed files with 15,631 additions and 11,378 deletions.
26,331 changes: 15,059 additions & 11,272 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@nextui-org/react": "^1.0.0-beta.9",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"antd": "^4.22.3",
"nanoid": "^4.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"build": "CI= react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Expand Down
Binary file added public/AdonisGM.ico
Binary file not shown.
Binary file removed public/favicon.ico
Binary file not shown.
46 changes: 25 additions & 21 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<!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" />
<!--

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/AdonisGM.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#ffffff" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet">
<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" />
<!--
<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.
Expand All @@ -24,12 +26,13 @@
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>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
<title>Quizlet learn</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.
Expand All @@ -39,5 +42,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>
Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
18 changes: 4 additions & 14 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
{
"short_name": "React App",
"short_name": "Quizlet learn",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"src": "AdonisGM.ico",
"sizes": "200x200",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"theme_color": "#ffffff",
"background_color": "#ffffff"
}
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

32 changes: 14 additions & 18 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import logo from './logo.svg';
import './App.css';
import { Route, Routes } from 'react-router-dom';
import HomeScreen from './screens/HomeScreen';
import CreateScreen from './screens/CreateScreen';
import Layout from './components/Layout/Layout';
import NotFoundScreen from './screens/NotFoundScreen';
import DetailCourseScreen from './screens/DetailCourseScreen';

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>
<Routes>
<Route path={'/'} element={<Layout />}>
<Route path={'/'} element={<HomeScreen title={'Home | AdonisGM'}/>} />
<Route path={'/create'} element={<CreateScreen title={'Create course | AdonisGM'}/>} />
<Route path={'/course/:id'} element={<DetailCourseScreen title={'Detail course | AdonisGM'}/>} />
</Route>
<Route path={'*'} element={<NotFoundScreen title={'Not found | AdonisGM'}/>} />
</Routes>
);
}

Expand Down
8 changes: 0 additions & 8 deletions src/App.test.js

This file was deleted.

93 changes: 93 additions & 0 deletions src/components/Create/Create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {
Input,
Textarea,
Spacer,
Text,
Button,
Grid,
Switch,
} from '@nextui-org/react';
import { useRef, useState } from 'react';
import { nanoid } from 'nanoid';
import { useNavigate } from 'react-router-dom';

const Create = () => {
const [isValidName, setIsValidName] = useState(true);
const [isValidContent, setIsValidContent] = useState(true);
const [firstExtract, setFirstExtract] = useState('-----');
const [secondExtract, setSecondExtract] = useState('\n\n\n');
const [isSuccess, setIsSuccess] = useState(false);

const nameRef = useRef();
const contentRef = useRef();

const navigate = useNavigate();

const handleCreate = () => {
const name = nameRef.current.value.trim();
const content = contentRef.current.value.trim();

setIsValidName(name.length > 0);
setIsValidContent(content.length > 0);

if (name.length > 0 && content.length > 0) {
const list = content.split(secondExtract);
const listObject = list.map((item) => {
const [answer, question] = item.split(firstExtract);
return {
i: nanoid(6),
answer,
question,
lastAnswerCorrect: true,
numberOfAttempts: 0,
};
});
// save to local storage
localStorage.setItem(
nanoid(15),
JSON.stringify({
name: name,
data: listObject,
createdAt: new Date(),
learnedAt: null,
})
);
}
navigate('/');
};

return (
<div>
<Text h1>Create course</Text>
<Spacer />
<Input
status={isValidName ? 'default' : 'error'}
css={{ width: '100%' }}
label="Name of course"
ref={nameRef}
/>
<Spacer />
<Textarea
status={isValidContent ? 'default' : 'error'}
css={{ width: '100%' }}
label="Export course content"
rows={15}
ref={contentRef}
/>
{/* <Spacer />
<Switch checked={true} />
<Grid.Container>
<Grid xs={3}>
<Input label="Name of course" />
</Grid>
<Grid xs={3}>
<Input label="Name of course" />
</Grid>
</Grid.Container> */}
<Spacer />
<Button onPress={handleCreate}>Create</Button>
</div>
);
};

export default Create;
Empty file.
Loading

0 comments on commit bd12454

Please sign in to comment.