-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from ES2-UFPI/henrique
Creating new class
- Loading branch information
Showing
20 changed files
with
424 additions
and
116 deletions.
There are no files selected for viewing
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 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,13 @@ | ||
import { Document, Model, model, Schema } from 'mongoose'; | ||
|
||
export interface IClass extends Document { | ||
className: string; | ||
classSummary: string; | ||
} | ||
|
||
const classSchema: Schema<IClass> = new Schema({ | ||
className: { type: String, required: true }, | ||
classSummary: { type: String, required: true }, | ||
}); | ||
|
||
export const Class: Model<IClass> = model<IClass>('Class', classSchema); |
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 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 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,63 @@ | ||
import { useState } from "react"; | ||
import { Wrapper } from "../../styles/Layout"; | ||
import { ButtonSaveClass, Class, Form } from "./styles"; | ||
|
||
|
||
export function CreateClass(){ | ||
|
||
const [className, setClassName] = useState<string>(''); | ||
const [classSummary, setClassSummary] = useState<string>(''); | ||
|
||
function hanldeSubmitClass(){ | ||
const classData = { | ||
className, | ||
classSummary | ||
} | ||
const requestOptions = { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify(classData) | ||
}; | ||
|
||
fetch('http://localhost:3000/createClass', requestOptions) | ||
.then(response => response.json()) | ||
.then(data => { | ||
console.log(data); | ||
// add code to handle successful class registration | ||
}) | ||
.catch(error => console.error(error)); | ||
} | ||
|
||
return ( | ||
<Class> | ||
<Wrapper> | ||
<Form onSubmit={e => e.preventDefault()}> | ||
<legend> | ||
<h2>Criar nova turma</h2> | ||
</legend> | ||
|
||
<label htmlFor="nameClass">Nome da turma:</label> | ||
<input type="text" placeholder="Nome da turma" | ||
value={className} onChange={(e) => setClassName(e.target.value)} /> | ||
|
||
<label htmlFor="dicipline">Diciplina: </label> | ||
<input type="text" placeholder="Qual diciplina?"/> | ||
|
||
<label htmlFor="menuDicipline">Ementa: </label> | ||
<textarea | ||
name="postContent" | ||
rows={4} | ||
cols={40} | ||
placeholder="Ementa da diciplina..." | ||
value={classSummary} onChange={(e) => setClassSummary(e.target.value)} | ||
/> | ||
</Form> | ||
|
||
<ButtonSaveClass onClick={hanldeSubmitClass}> | ||
Cadastrar Turma | ||
</ButtonSaveClass> | ||
|
||
</Wrapper> | ||
</Class> | ||
) | ||
} |
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,62 @@ | ||
import styled from "styled-components"; | ||
import { ContainerButtonGreen } from "../../components/ButtonGreen/styles"; | ||
|
||
export const Class = styled.div ` | ||
padding: 1rem 1rem; | ||
` | ||
|
||
export const Form = styled.form` | ||
width: 100%; | ||
background-color: var(--primary); | ||
padding: 2rem 3rem 3rem; | ||
margin: 3rem; | ||
border-radius: 2rem; | ||
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2); | ||
h2 { | ||
color: var(--secondary); | ||
font-size: 3rem; | ||
margin-bottom: 1rem; | ||
} | ||
label { | ||
color: var(--secondary); | ||
} | ||
input { | ||
display: block; | ||
margin: .5rem 0 1rem; | ||
padding: 2rem; | ||
width: 100%; | ||
border-radius: 2rem; | ||
border: none; | ||
height: 4rem; | ||
} | ||
textarea { | ||
display: block; | ||
box-sizing: border-box; | ||
border-radius: .8rem; | ||
border: none; | ||
width: 100%; | ||
padding: 1rem; | ||
line-height: 24px; | ||
box-shadow: 0 0 8px rgba(0, 0, 0, 0.1); | ||
&:focus { | ||
box-shadow: 0 0 8px rgba(0, 0, 0, 0.2); | ||
} | ||
} | ||
` | ||
|
||
export const ButtonSaveClass = styled(ContainerButtonGreen) ` | ||
padding: 1rem 4rem; | ||
border-radius: 2rem; | ||
font-size: 1.6rem; | ||
font-weight: bold; | ||
margin: 0; | ||
` |
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
Oops, something went wrong.