diff --git a/week-9/petAdoption/package-lock.json b/week-9/petAdoption/package-lock.json index 4fcf73b0..b80f0b15 100644 --- a/week-9/petAdoption/package-lock.json +++ b/week-9/petAdoption/package-lock.json @@ -1,15 +1,17 @@ { - "name": "petadotion", + "name": "petadoption", "version": "0.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "petadotion", + "name": "petadoption", "version": "0.0.0", "dependencies": { + "prop-types": "^15.8.1", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "react-router-dom": "^6.27.0" }, "devDependencies": { "@eslint/js": "^9.11.1", @@ -916,6 +918,14 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@remix-run/router": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.20.0.tgz", + "integrity": "sha512-mUnk8rPJBI9loFDZ+YzPGdeniYK+FTmRD1TMCz7ev2SNIozyKKpnGgsxO34u6Z4z/t0ITuu7voi/AshfsGsgFg==", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.24.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz", @@ -3095,7 +3105,6 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -3327,7 +3336,6 @@ "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dev": true, "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -3369,8 +3377,7 @@ "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "dev": true + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/react-refresh": { "version": "0.14.2", @@ -3381,6 +3388,36 @@ "node": ">=0.10.0" } }, + "node_modules/react-router": { + "version": "6.27.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.27.0.tgz", + "integrity": "sha512-YA+HGZXz4jaAkVoYBE98VQl+nVzI+cVI2Oj/06F5ZM+0u3TgedN9Y9kmMRo2mnkSK2nCpNQn0DVob4HCsY/WLw==", + "dependencies": { + "@remix-run/router": "1.20.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.27.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.27.0.tgz", + "integrity": "sha512-+bvtFWMC0DgAFrfKXKG9Fc+BcXWRUO1aJIihbB79xaeq0v5UzfvnM5houGUm1Y461WVRcgAQ+Clh5rdb1eCx4g==", + "dependencies": { + "@remix-run/router": "1.20.0", + "react-router": "6.27.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/reflect.getprototypeof": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.6.tgz", diff --git a/week-9/petAdoption/package.json b/week-9/petAdoption/package.json index 555bb334..04330f31 100644 --- a/week-9/petAdoption/package.json +++ b/week-9/petAdoption/package.json @@ -10,8 +10,10 @@ "preview": "vite preview" }, "dependencies": { + "prop-types": "^15.8.1", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "react-router-dom": "^6.27.0" }, "devDependencies": { "@eslint/js": "^9.11.1", diff --git a/week-9/petAdoption/src/App.css b/week-9/petAdoption/src/App.css index b9d355df..e69de29b 100644 --- a/week-9/petAdoption/src/App.css +++ b/week-9/petAdoption/src/App.css @@ -1,42 +0,0 @@ -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} diff --git a/week-9/petAdoption/src/App.jsx b/week-9/petAdoption/src/App.jsx index fef914a7..b81e3a4e 100644 --- a/week-9/petAdoption/src/App.jsx +++ b/week-9/petAdoption/src/App.jsx @@ -1,11 +1,32 @@ +import { useState } from 'react'; +import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import './App.css'; +import Header from './components/Header'; +import PetAdoptionForm from './components/PetAdoptionForm'; +import DataPage from './pages/DataPage'; + +const App = () => { + const [formDataList, setFormDataList] = useState([]); + + -function App() { return ( -
-

Pet Adoption Project

-
+ +
+
+ + setFormDataList((prevList) => [...prevList, data])} />} + /> + } + /> + +
+
); -} +}; export default App; diff --git a/week-9/petAdoption/src/assets/backimg.jpg b/week-9/petAdoption/src/assets/backimg.jpg new file mode 100644 index 00000000..f3dd6c7d Binary files /dev/null and b/week-9/petAdoption/src/assets/backimg.jpg differ diff --git a/week-9/petAdoption/src/assets/react.svg b/week-9/petAdoption/src/assets/react.svg deleted file mode 100644 index 6c87de9b..00000000 --- a/week-9/petAdoption/src/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/week-9/petAdoption/src/components/Header.jsx b/week-9/petAdoption/src/components/Header.jsx index 041aba3e..ecbbdf80 100644 --- a/week-9/petAdoption/src/components/Header.jsx +++ b/week-9/petAdoption/src/components/Header.jsx @@ -1,8 +1,21 @@ -import React from 'react' + + +const header_styles = { + textAlign: 'center', + fontSize: '35px', + fontWeight: 'bold', + padding: '12px', + backgroundColor: 'rgba(173, 76, 241, 0.64)', + color: 'solid black', + position: 'fixed', + top: 0, + width: '100%', + zIndex: 1000, +}; const Header = () => { return ( -
Header
+
Pet Adoption Project
) } diff --git a/week-9/petAdoption/src/components/PetAdoptionForm.jsx b/week-9/petAdoption/src/components/PetAdoptionForm.jsx index 105375b4..a37d383f 100644 --- a/week-9/petAdoption/src/components/PetAdoptionForm.jsx +++ b/week-9/petAdoption/src/components/PetAdoptionForm.jsx @@ -1,9 +1,162 @@ -import React from 'react' +import { useState } from 'react'; +import PropTypes from 'prop-types'; +import {useNavigate} from 'react-router-dom'; -const PetAdoptionForm = () => { +const PetAdoptionForm = ({ onSubmit }) => { + const [formData, setFormData] = useState({ + petName: '', + petType: '', + breed: '', + yourName: '', + email: '', + phone: '', + }); + const navigate = useNavigate(); + + const handleChange = (e) => { + const { name, value } = e.target; + setFormData({ ...formData, [name]: value }); + }; + + const handleSubmit = (e) => { + e.preventDefault(); + onSubmit( formData); + setFormData({ + petName: '', + petType: '', + breed: '', + yourName: '', + email: '', + phone: '', + }); + navigate('/data'); + }; return ( -
PetAdoptionForm
- ) -} +
+
+ + + -export default PetAdoptionForm \ No newline at end of file + + + + + + + + + + + + + + + + +
+
+); +}; + +// Styles +const containerStyle = { + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + height: '80vh', + width: '80vw', + margin: '10vh auto', + padding: '20px', + boxSizing: 'border-box', +}; + +const formStyle = { + backgroundColor: 'rgba(173, 76, 241, 0.64)', + padding: '60px', + borderRadius: '8px', + width: '400px', + boxShadow: '0 4px 8px rgba(0, 0, 0, 0.2)', + marginTop: '50px', +}; + +const labelStyle = { +display: 'block', +marginBottom: '5px', +fontWeight: 'bold', +color: '#3A3A3A', +fontSize: '14px', +}; + +const inputStyle = { + width: '100%', + padding: '10px', + marginBottom: '15px', + borderRadius: '4px', + border: '1px solid #ccc', + fontSize: '14px', + boxSizing: 'border-box', +}; + + +const selectStyle = { + ...inputStyle, + appearance: 'none', +}; + +const buttonStyle = { +width: '100%', +padding: '10px', +backgroundColor: '#2F4F2F', +color: '#fff', +border: 'none', +borderRadius: '4px', +cursor: 'pointer', +fontSize: '16px', +}; +PetAdoptionForm.propTypes = { + onSubmit: PropTypes.func.isRequired, + formDataList: PropTypes.array +}; + +export default PetAdoptionForm diff --git a/week-9/petAdoption/src/components/TableData.jsx b/week-9/petAdoption/src/components/TableData.jsx index a68aaa33..2a00182b 100644 --- a/week-9/petAdoption/src/components/TableData.jsx +++ b/week-9/petAdoption/src/components/TableData.jsx @@ -1,9 +1,82 @@ -import React from 'react' +import PropTypes from 'prop-types'; -const TableData = () => { +const TableData = ({ data }) => { return ( -
TableData
- ) -} +
+

Submitted Pet Adoption Applications

+ + + + + + + + + + + + + {data.map((entry, index) => ( + + + + + + + + + ))} + +
Pet NamePet TypeBreedYour NameEmailPhone
{entry.petName}{entry.petType}{entry.breed}{entry.yourName}{entry.email}{entry.phone}
+
+ ); +}; +TableData.propTypes = { + data: PropTypes.arrayOf( + PropTypes.shape({ + petName: PropTypes.string.isRequired, + petType: PropTypes.string.isRequired, + breed: PropTypes.string.isRequired, + yourName: PropTypes.string.isRequired, + email: PropTypes.string.isRequired, + phone: PropTypes.string.isRequired, + }) + ).isRequired, +}; -export default TableData \ No newline at end of file +// Styles +const tableContainerStyle = { + margin: '20px auto', + padding: '20px', + maxWidth: '80%', + marginTop:'80px', + backgroundColor: 'rgba(173, 76, 241, 0.64)', + borderRadius: '8px', + boxShadow: '0 4px 8px rgba(0, 0, 0, 0.2)', +}; + +const headerStyle = { + textAlign: 'center', + marginBottom: '20px', + color: '#3A3A3A', +}; + +const tableStyle = { + width: '100%', + borderCollapse: 'collapse', +}; + +const headerCellStyle = { + backgroundColor: '#F3C623', + padding: '10px', + border: '1px solid black', + fontWeight: 'bold', + textAlign: 'left', +}; + +const cellStyle = { + padding: '10px', + border: '1px solid black', +}; + +export default TableData; diff --git a/week-9/petAdoption/src/index.css b/week-9/petAdoption/src/index.css index 6119ad9a..3619218f 100644 --- a/week-9/petAdoption/src/index.css +++ b/week-9/petAdoption/src/index.css @@ -1,68 +1,8 @@ -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - body { + background-image: url('assets/backimg.jpg'); + background-size: cover; + background-position: center; + background-repeat: no-repeat; + height:100vh; margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } } diff --git a/week-9/petAdoption/src/main.jsx b/week-9/petAdoption/src/main.jsx index 89f91e54..89583b5b 100644 --- a/week-9/petAdoption/src/main.jsx +++ b/week-9/petAdoption/src/main.jsx @@ -1,10 +1,9 @@ -import { StrictMode } from 'react' + import { createRoot } from 'react-dom/client' import App from './App.jsx' import './index.css' createRoot(document.getElementById('root')).render( - - - , + + , ) diff --git a/week-9/petAdoption/src/pages/DataPage.jsx b/week-9/petAdoption/src/pages/DataPage.jsx new file mode 100644 index 00000000..f9c1d917 --- /dev/null +++ b/week-9/petAdoption/src/pages/DataPage.jsx @@ -0,0 +1,29 @@ +import TableData from '../components/TableData'; +import { useNavigate } from 'react-router-dom'; +import PropTypes from 'prop-types'; +const DataPage = ({ data }) => { + const navigate = useNavigate(); + + return ( +
+ +
+ +
+
+ ); +}; +DataPage.propTypes = { + data: PropTypes.arrayOf( + PropTypes.shape({ + petName: PropTypes.string.isRequired, + petType: PropTypes.string.isRequired, + breed: PropTypes.string.isRequired, + yourName: PropTypes.string.isRequired, + email: PropTypes.string.isRequired, + phone: PropTypes.string.isRequired, + }) + ).isRequired, +}; +export default DataPage; +