Skip to content

Commit

Permalink
♻️ rename
Browse files Browse the repository at this point in the history
  • Loading branch information
h-campos committed Apr 27, 2023
1 parent a6eae65 commit 17cdcae
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/components/ScoreBoard/ScoreBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ type ScoreBoardProps = {
close: () => void
}

interface Data {
interface Scores {
name: string
score: string
}

export const ScoreBoard: FC<ScoreBoardProps> = ({ close }) => {
const [data, setData] = useState<Data[]>([])
const [scores, setScores] = useState<Scores[]>([])

useEffect(() => {
const keys = Object.keys(localStorage)
const allData: Data[] = keys.map((key) => {
const allScores: Scores[] = keys.map((key) => {
const value = localStorage.getItem(key)
return { name: key, score: value as string }
})
setData(allData)
setScores(allScores)
}, [])

const removeScore = (name: string) => {
const filteredData = data.filter((item) => item.name !== name)
setData(filteredData)
const filteredData = scores.filter((item) => item.name !== name)
setScores(filteredData)
localStorage.removeItem(name)
}

Expand All @@ -46,7 +46,7 @@ export const ScoreBoard: FC<ScoreBoardProps> = ({ close }) => {
<div className='w-full h-0.5 bg-black'></div>
</div>
<div className='w-full flex flex-col items-start justify-center gap-2'>
{data.map((score) => {
{scores.map((score) => {
return (
<div
key={uuid()}
Expand Down

1 comment on commit 17cdcae

@vercel
Copy link

@vercel vercel bot commented on 17cdcae Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.