Skip to content

Commit 5380447

Browse files
author
DKWA
committed
First commit
1 parent b910636 commit 5380447

23 files changed

+1574
-1272
lines changed

.eslintcache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"/Users/devinkarlwaynealmonor/Desktop/assassins-creed-app/src/index.js":"1","/Users/devinkarlwaynealmonor/Desktop/assassins-creed-app/src/App.js":"2","/Users/devinkarlwaynealmonor/Desktop/assassins-creed-app/src/reportWebVitals.js":"3"},{"size":599,"mtime":1611027312000,"results":"4","hashOfConfig":"5"},{"size":8662,"mtime":1611211897524,"results":"6","hashOfConfig":"5"},{"size":362,"mtime":1610936875407,"results":"7","hashOfConfig":"5"},{"filePath":"8","messages":"9","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"10"},"1jcci97",{"filePath":"11","messages":"12","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"13","messages":"14","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"10"},"/Users/devinkarlwaynealmonor/Desktop/assassins-creed-app/src/index.js",[],["15","16"],"/Users/devinkarlwaynealmonor/Desktop/assassins-creed-app/src/App.js",[],"/Users/devinkarlwaynealmonor/Desktop/assassins-creed-app/src/reportWebVitals.js",[],{"ruleId":"17","replacedBy":"18"},{"ruleId":"19","replacedBy":"20"},"no-native-reassign",["21"],"no-negated-in-lhs",["22"],"no-global-assign","no-unsafe-negation"]

package-lock.json

Lines changed: 885 additions & 1249 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
"@testing-library/jest-dom": "^5.11.9",
77
"@testing-library/react": "^11.2.3",
88
"@testing-library/user-event": "^12.6.0",
9+
"axios": "^0.21.1",
910
"react": "^17.0.1",
1011
"react-dom": "^17.0.1",
12+
"react-font-face": "^0.2.1",
13+
"react-router-dom": "^5.2.0",
1114
"react-scripts": "4.0.1",
1215
"web-vitals": "^0.2.4"
1316
},

src/Adewale.webp

405 KB
Loading

src/Altair_Ibn.webp

267 KB
Loading

src/Amunet.webp

109 KB
Loading

src/App.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@
3636
transform: rotate(360deg);
3737
}
3838
}
39+

src/App.js

Lines changed: 268 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,272 @@
1-
import logo from './logo.svg';
1+
//import logo from './logo.svg';
22
import './App.css';
3+
import React from 'react';
4+
import axios from 'axios';
5+
import img from './Altair_Ibn.webp';
6+
import img2 from './Ezio_Auditore.webp';
7+
import img3 from './Connor-Kenway.webp';
8+
import img4 from './Aveline_Grandpré.webp';
9+
import img5 from './Edward_Kenway.webp';
10+
import img6 from './Adewale.webp';
11+
import img7 from './Arno_Dorian.webp';
12+
import img8 from './Shao_Jun.webp';
13+
import img9 from './Evie_Frie.webp';
14+
import img10 from './Jacob_Frye.webp';
15+
import img11 from './Bayek_Siwa.webp';
16+
import img12 from './Amunet.webp';
317

4-
function App() {
5-
return (
6-
<div className="App">
7-
<header className="App-header">
8-
<img src={logo} className="App-logo" alt="logo" />
9-
<p>
10-
Edit <code>src/App.js</code> and save to reload.
11-
</p>
12-
<a
13-
className="App-link"
14-
href="https://reactjs.org"
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
>
18-
Learn React
19-
</a>
20-
</header>
21-
</div>
22-
);
23-
}
2418

19+
20+
21+
22+
import {
23+
BrowserRouter as Router,
24+
Switch,
25+
Route,
26+
Link,
27+
} from "react-router-dom";
28+
29+
const AC_URL = "https://assassins-creed-api.herokuapp.com/Assassins-Creed-Characters"
30+
31+
class App extends React.Component{
32+
constructor(props){
33+
super(props);
34+
this.state = {} }
35+
render(){
36+
return(
37+
<Router>
38+
<div>
39+
<ul>
40+
<li>
41+
<Link to="/" class="TG">The Guild</Link>
42+
</li>
43+
<br>
44+
</br>
45+
<li>
46+
<Link to="/Assassins-Creed-Characters" class= "AI">Assassin's Info</Link>
47+
</li>
48+
</ul>
49+
<Switch>
50+
<Route path ="/Assassins-Creed-Characters">
51+
<Assassins />
52+
</Route>
53+
<Route path ="/">
54+
<Home />
55+
</Route>
56+
</Switch>
57+
</div>
58+
</Router>
59+
);
60+
}
61+
}
62+
63+
class Home extends React.Component{
64+
render(){
65+
return(
66+
<div>
67+
<h1> the Assassin's Guild </h1>
68+
<h2>
69+
<div>
70+
71+
<img src = {img} class="img" height= "375px" alt="assassin"></img>
72+
73+
<img src = {img2} class="img2" height ="375px" alt= "assassin2"></img>
74+
75+
<img src = {img3} class="img3" height ="375px" alt= "assassin3"></img>
76+
77+
<img src = {img4} class="img4" height ="375px" alt= "assassin4"></img>
78+
79+
<img src = {img5} class="img5" height ="375px" alt= "assassin5"></img>
80+
81+
<img src = {img6} class="img6"height ="375px" alt= "assassin6"></img>
82+
83+
<img src = {img7} class="img7" height ="375px" alt= "assassin7"></img>
84+
85+
<img src = {img8} class="img8" height ="375px" alt= "assassin8"></img>
86+
87+
<img src = {img9} class="img9" height ="375px" alt= "assassin9"></img>
88+
89+
<img src = {img10} class="img10" height ="375px" alt= "assassin10"></img>
90+
91+
<img src = {img11} class="img11" height ="375px" alt= "assassin11"></img>
92+
93+
<img src = {img12} class="img12" height ="375px" alt= "assassin12"></img>
94+
95+
96+
97+
</div>
98+
</h2>
99+
</div>
100+
101+
)
102+
}
103+
}
104+
105+
class Assassins extends React.Component {
106+
constructor(props) {
107+
super(props);
108+
this.state = {}
109+
this.handleChange = this.handleChange.bind(this);
110+
this.handleSubmit = this.handleSubmit.bind(this);
111+
this.selectAssassin = this.selectAssassin.bind(this);
112+
this.editAssassin = this.editAssassin.bind(this);
113+
this.submitEditedAssassin = this.submitEditedAssassin.bind(this);
114+
}
115+
async getAssassins() {
116+
try {
117+
const res = await axios.get(AC_URL);
118+
this.setState({ assassins: res.data });
119+
} catch(e) {
120+
console.error(e);
121+
122+
}
123+
}
124+
125+
componentDidMount() {
126+
this.getAssassins();
127+
}
128+
handleChange(e) {
129+
const { name, value } = e.target;
130+
this.setState({ [name]: value })
131+
}
132+
133+
async handleSubmit(e) {
134+
e.preventDefault();
135+
const {name, quote, birth, death, country} = this.state;
136+
const assassin = {name, quote, birth, death, country};
137+
138+
try {
139+
const res = await axios.post(AC_URL, assassin);
140+
console.log(res.data);
141+
142+
const updateRes = await axios.get(AC_URL);
143+
this.setState({assassins: updateRes.data});
144+
} catch(e){
145+
console.error(e.message);
146+
}
147+
}
148+
149+
async handleDelete (id) {
150+
console.log(AC_URL + id);
151+
try {
152+
const res = await axios.delete(AC_URL + id); // target assassin id
153+
console.log(res.data);
154+
155+
const updateRes = await axios.get(AC_URL);
156+
this.setState({ assassins: updateRes.data });
157+
} catch(e) {
158+
console.error(e.message)
159+
}
160+
}
161+
162+
163+
selectAssassin(selectedAssassin){
164+
this.setState({ selectedAssassin});
165+
}
166+
167+
editAssassin(e){
168+
const {name, value } = e.target;
169+
this.setState({...this.state, selectedAssassin:{
170+
...this.state.selectedAssassin,[name]: value}})
171+
}
172+
173+
async submitEditedAssassin(e){
174+
e.preventDefault();
175+
try{
176+
const editedAssassin = this.state.selectedAssassin;
177+
console.log(editedAssassin)
178+
const focusAssassin = AC_URL + editedAssassin.id
179+
//eslint-disable-next-line
180+
const res = await axios.patch(focusAssassin, editedAssassin);
181+
const resRefresh = await axios.get(AC_URL);
182+
this.setState({ assassins: resRefresh.data});
183+
} catch(e){
184+
console.log(e);
185+
}
186+
}
187+
188+
render() {
189+
return (
190+
<div className="Assassins-Creed-Characters">
191+
<ul>
192+
{/* render info */}
193+
{
194+
this.state.assassins && this.state.assassins.map(assassin => <li key = {assassin.id}> <br></br>
195+
196+
<ul><button class="deleteB" onClick={ () => this.handleDelete(assassin.id)}>Delete Assassin</button> <br></br><br></br>
197+
<button class ="editB" onClick={ () => this.selectAssassin(assassin)}>Edit Assassin</button> </ul> <br></br> <br></br>
198+
199+
<div class ="assassinNames"> {assassin.name} <br></br> <br></br> </div>
200+
<div class= "assassinQuotes"> {assassin.quote} <br></br><br></br> </div>
201+
<div class="assassinBirths">{assassin.birth} <br></br> <br></br> </div>
202+
<div class="assassinDeaths">{assassin.death} <br></br> <br></br> </div>
203+
<div class="assassinCountries"> {assassin.country} <br></br><br></br> </div>
204+
205+
</li>
206+
)
207+
}
208+
209+
</ul>
210+
<form className="new-assassin-form"
211+
onChange={ this.handleChange }
212+
onSubmit={ this.handleSubmit }>
213+
<label class="labelName">
214+
Assassin's Name:
215+
<input type="text" name="name" />
216+
</label>
217+
<label class="labelQuote">
218+
Assassin's Quote:
219+
<input type="text" name="quote" />
220+
</label>
221+
<label class="labelBirth">
222+
Assassin's Birth:
223+
<input type="text" name="birth" />
224+
</label>
225+
<label class="labelDeath">
226+
Assassin's Death:
227+
<input type="text" name="death" />
228+
</label>
229+
<label class ='labelCountry'>
230+
Assassin's Country:
231+
<input type="text" name="country" />
232+
</label>
233+
</form>
234+
<hr></hr>
235+
{
236+
this.state.selectedAssassin && <form className ="assassin-edit-form"
237+
onChange = { this.editAssassin }
238+
onSubmit = { this.submitEditedAssassin}>
239+
240+
<label> <br></br> <div class ="editFormTitle">Edit Form </div> <br></br> <br></br>
241+
242+
Assassin Names:
243+
<input class="editFormName" type="text" name="name" defaultValue={ this.state.selectedAssassin.name } />
244+
</label>
245+
<label>
246+
Assassin's Quote:
247+
<input type="text" name="quote" defaultValue={ this.state.selectedAssassin.quote } />
248+
</label>
249+
<label>
250+
Assassin's Birth:
251+
<input type="text" name="birth" defaultValue={ this.state.selectedAssassin.birth } />
252+
</label>
253+
<label>
254+
Assassin's Death:
255+
<input type="text" name="death" defaultValue={ this.state.selectedAssassin.death } />
256+
</label>
257+
<label>
258+
Assassin's Country:
259+
<input type="text" name="country" defaultValue={ this.state.selectedAssassin.country } />
260+
</label>
261+
<label><input type="submit" class="submitB" /></label>
262+
</form>
263+
}
264+
</div>
265+
)
266+
}
267+
}
268+
269+
270+
271+
25272
export default App;

src/Arno_Dorian.webp

1.06 MB
Loading

src/Aveline_Grandpré.webp

63.9 KB
Loading

0 commit comments

Comments
 (0)