Skip to content

Commit 7021b7b

Browse files
authored
Merge branch 'main' into Header
Signed-off-by: Julia Undeutsch <54622834+YuriDevAT@users.noreply.github.com>
2 parents dc16efa + fa9d135 commit 7021b7b

File tree

4 files changed

+93
-4
lines changed

4 files changed

+93
-4
lines changed

public/images/download.svg

Lines changed: 4 additions & 0 deletions
Loading

src/App.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import React from "react";
21
import "./App.css";
32
import Header from "./components/Header/Header";
3+
import DownloadButton from "./components/DownloadButton";
4+
import ProgrammingExpertise from "./components/ProgrammingExpertise";
5+
46
function App() {
57
return (
6-
<div className="App">
7-
<Header />
8-
</div>
8+
<>
9+
<Header />
10+
<DownloadButton />
11+
<ProgrammingExpertise />
12+
</>
913
);
1014
}
1115

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { useState } from "react";
2+
3+
const initialState = {
4+
Title: "",
5+
SubTitle: "",
6+
City: "",
7+
Country: "",
8+
StartDate: "",
9+
EndDate: "",
10+
Description: "",
11+
};
12+
13+
const ProgrammingExpertise = () => {
14+
const [formState, setFormState] = useState(initialState);
15+
16+
const handleChange = (e, label) =>
17+
setFormState((prev) => ({ ...prev, [label]: e.target.value }));
18+
19+
const clearState = () => setFormState({ ...initialState });
20+
21+
const onSubmit = (e) => {
22+
e.preventDefault();
23+
localStorage.setItem("Programming Expertise", JSON.stringify(formState));
24+
};
25+
26+
console.log(JSON.parse(localStorage.getItem("Programming Expertise")));
27+
28+
const inputList = [
29+
{ label: "Title", type: "text", name: "title" },
30+
{ label: "SubTitle", type: "text", name: "subtitle" },
31+
{ label: "City", type: "text", name: "city" },
32+
{ label: "Country", type: "text", name: "country" },
33+
{ label: "StartDate", type: "date", name: "startdate" },
34+
{ label: "EndDate", type: "date", name: "enddate" },
35+
{ label: "Description", type: "text", name: "description" },
36+
].map(({ label, type, name }, index) => {
37+
return (
38+
<div key={`${label}${index}`}>
39+
<label htmlFor={name}>{label}</label>
40+
<input
41+
type={type}
42+
name={name}
43+
id={name}
44+
value={formState[label]}
45+
onChange={(e) => handleChange(e, label)}
46+
/>
47+
</div>
48+
);
49+
});
50+
return (
51+
<>
52+
<h1>Programming Expertise</h1>
53+
<form onSubmit={onSubmit}>
54+
{inputList}
55+
<button type="submit">Save</button>
56+
<button type="button" onClick={clearState}>
57+
Cancel
58+
</button>
59+
</form>
60+
</>
61+
);
62+
};
63+
export default ProgrammingExpertise;

src/components/DownloadButton.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
3+
const DownloadButton = () => {
4+
return (
5+
<button style={{
6+
display: "flex",
7+
alignItems: "center"
8+
}}>
9+
<img src='/images/download.svg' alt="" style={{
10+
padding: "5px"
11+
}}></img>
12+
Download
13+
14+
</button>
15+
);
16+
}
17+
18+
export default DownloadButton;

0 commit comments

Comments
 (0)