Project finished

This commit is contained in:
QkoSad
2024-09-30 15:31:42 +03:00
parent ac917e6e26
commit 6c8bfe44cd
10 changed files with 75 additions and 123 deletions
+8 -69
View File
@@ -1,70 +1,9 @@
# Getting Started with Create React App
# FeedBack APP
---
>Simple App that has a single for that has a rating and a review field. It works
with local database as file and uses json-server as back end
---
## Usage:
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
`npm run sever`
`npm start`
+18 -18
View File
@@ -1,19 +1,19 @@
{
"feedback":[
{
"id":3,
"rating":10,
"text":"This is feedback item 3 comfing from the backend"
},
{
"id":2,
"rating":10,
"text":"This is feedback item 2 comfing from the backend"
},
{
"id":1,
"rating":10,
"text":"This is feedback item 1 comfing from the backend"
}
]
}
"feedback": [
{
"id": 3,
"rating": 10,
"text": "This is feedback item 3 comfing from the backend"
},
{
"id": 2,
"rating": 10,
"text": "This is feedback item 2 comfing from the backend"
},
{
"id": 1,
"rating": 10,
"text": "This is feedback item 1 comfing from the backend"
}
]
}
+2 -2
View File
@@ -2,7 +2,7 @@
"name": "feed-app",
"version": "0.1.0",
"private": true,
"proxy":"http://localhost:5000",
"proxy": "http://localhost:4000",
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
@@ -22,7 +22,7 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"server": "json-server --watch db.json --port 5000",
"server": "json-server --watch db.json --port 4000",
"dev": "concurrently \"npm run server\" \"npm start\""
},
"eslintConfig": {
+4 -3
View File
@@ -21,18 +21,18 @@ function FeedbackForm() {
}
}, [feedbackEdit]);
const handleTextChange = ({target:{value}}) => {
const handleTextChange = ({ target: { value } }) => {
if (value === "") {
setBtnDisabled(true);
setMessage(null);
} else if (value.trim().length<10){
} else if (value.trim().length < 10) {
setMessage("Text must be at least 10 characters");
setBtnDisabled(true);
} else {
setMessage(null);
setBtnDisabled(false);
}
setText(value)
setText(value);
};
const handleSubmit = (e) => {
@@ -42,6 +42,7 @@ function FeedbackForm() {
text,
rating,
};
console.log(newFeedback);
if (feedbackEdit.edit === true) {
updateFeedback(feedbackEdit.item.id, newFeedback);
} else {
+1
View File
@@ -1,5 +1,6 @@
import { Link } from "react-router-dom";
import { FaQuestion } from "react-icons/fa";
function AboutIconLink() {
return (
<div className="about-link">
+19 -18
View File
@@ -1,20 +1,21 @@
import PropTypes from 'prop-types'
function Button ({children, version, type, isDisabled}){
return (
<button type={type} disabled={isDisabled} className={`btn btn-${version}`}>
{children}</button>
)
}
Button.defaultProps={
version: 'primavry',
type: 'button'
,
isDisabled:false
}
Button.propTypes ={
children: PropTypes.node.isRequired,
version:PropTypes.string,
type:PropTypes.string,
isDisabled:PropTypes.bool
import PropTypes from "prop-types";
function Button({ children, version, type, isDisabled }) {
return (
<button type={type} disabled={isDisabled} className={`btn btn-${version}`}>
{children}
</button>
);
}
Button.defaultProps = {
version: "primavry",
type: "button",
isDisabled: false,
};
Button.propTypes = {
children: PropTypes.node.isRequired,
version: PropTypes.string,
type: PropTypes.string,
isDisabled: PropTypes.bool,
};
export default Button;
+20 -12
View File
@@ -1,15 +1,23 @@
import PropTypes from 'prop-types'
function Card({children, reverse}){
//return (<div className={`card ${reverse && 'reverse'}`}>{children}</div>)
return (<div className='card' style={{backgroundColor: reverse ? 'rga(0,0,0,0.4)' :'#fff',
color: reverse ? '#fff' : '#000',}}>{children}</div> )
import PropTypes from "prop-types";
function Card({ children, reverse }) {
//return (<div className={`card ${reverse && 'reverse'}`}>{children}</div>)
return (
<div
className="card"
style={{
backgroundColor: reverse ? "rga(0,0,0,0.4)" : "#fff",
color: reverse ? "#fff" : "#000",
}}
>
{children}
</div>
);
}
Card.defaultProps = {
reverse:false
}
Card.propTypes={
children:PropTypes.node.isRequired,
reverse:PropTypes.bool
}
reverse: false,
};
Card.propTypes = {
children: PropTypes.node.isRequired,
reverse: PropTypes.bool,
};
export default Card;
+1
View File
@@ -5,6 +5,7 @@ function RatingSelect({ select }) {
const [selected, setSelected] = useState(10);
const { feedbackEdit } = useContext(FeedbackContext);
const handleChange = (e) => {
console.log(e,typeof e)
setSelected(+e.currentTarget.value);
select(+e.currentTarget.value);
};
+1 -1
View File
@@ -9,4 +9,4 @@ function Spinner() {
/>
);
}
export default Spinner
export default Spinner;
+1
View File
@@ -28,6 +28,7 @@ export const FeedbackProvider = ({ children }) => {
headers: { "Content-Type": "application/json" },
body: JSON.stringify(newFeedback),
});
console.log(response);
const data = await response.json();
setFeedback([data, ...feedback]);
};