This repository has been archived by the owner on Dec 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nguyen Manh Tung
committed
Aug 7, 2022
1 parent
ddb2b5c
commit bd12454
Showing
29 changed files
with
15,631 additions
and
11,378 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.