Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-co committed May 9, 2024
1 parent 966922c commit d48f6e5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
8 changes: 6 additions & 2 deletions React/test-feedback/src/components/feed/FeedForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ export const FeedForm = (props) => {
}
}

const handleRating = (e) => {
console.log(e)
}

return (
<Card>
<form onSubmit={handleSubmit} >
<h2>How would you rate your service with us?</h2>
<FeedRating onChange={(e) => setRating(e.rating)} />
<FeedRating setRating = {(rating) => setRating(rating)} />
<div className="input-group">
<input
onChange={handleChange}
type="text"
value={text}
placeholder="Write a review"
/>
<Button type={'submit'} isDisabled={isDisabled} >
<Button type = 'submit' isDisabled={isDisabled} >
Send
</Button>
</div>
Expand Down
9 changes: 7 additions & 2 deletions React/test-feedback/src/components/feed/FeedRating.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import React, { useState } from 'react'

export const FeedRating = (props) => {
const [rating, setRating] = useState()
// const [rating, setRating] = useState()
const [selected, setSelected] = useState(10)

const handleChange = (e) => {
setSelected(e.target.value)
props.setRating(e.target.value)
}

return (
<ul className='rating'>
{
Array.from({ length: 10 }, (_, i) => (
<li key={i}>
<input type="radio" value={i + 1} id={i + 1} checked={selected == i + 1} onChange={() => setSelected(i + 1)} />
<input type="radio" value={i + 1} id={i + 1} checked={selected == i + 1} onChange={handleChange} />
<label htmlFor={i + 1}>{i + 1}</label>
</li>
)
Expand Down
8 changes: 3 additions & 5 deletions React/test-feedback/src/components/shared/Button.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { useEffect } from 'react'

export const Button = (props, { version = 'secondary', type = 'button' }) => {
useEffect(() => {
console.log(version, type)
}, [])
export const Button = (props, { version = 'primary', type = 'button' }) => {

return (
<button type={type} disabled={props.isDisabled} className={`btn btn-${version}`}>
<button type={props.type ? props.type : type} disabled={props.isDisabled} className={`btn btn-${props.version ? props.version : version}`}>
{props.children}
</button>
)
Expand Down
5 changes: 2 additions & 3 deletions React/test-feedback/src/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ export const Home = () => {
setFeed(feed.filter(f => f.id != id))
}

const addFeed = (feed) => {
console.log(feed)
setFeed(feed.push(feed))
const addFeed = (newFeed) => {
setFeed([newFeed, ...feed])
}

return (
Expand Down

0 comments on commit d48f6e5

Please sign in to comment.