Skip to content

Commit

Permalink
[fix]: Se corrigió la funcion de Crear meta.
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoT4l committed Jan 12, 2024
1 parent 12f317b commit d3b0a68
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/components/list/Goal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styles from './Goal.module.css';
import {Link} from "react-router-dom";


function Goal({ id, details, period, icon, frequency, finish, completed }) {

return (
Expand Down
1 change: 0 additions & 1 deletion src/components/list/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ function List() {
</>
);
}

export default List;
9 changes: 5 additions & 4 deletions src/components/new/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {useContext, useEffect, useState} from 'react';
import {Context} from "../../services/Memory";
import {useNavigate, useParams} from "react-router-dom";


function Details() {

const {id} = useParams();
Expand Down Expand Up @@ -30,8 +31,8 @@ function Details() {
const [state, dispatch] = useContext(Context);

const onChange = (e, prop) => {
setForm(estate => ({
...estate,
setForm(prevEstate => ({
...prevEstate,
[prop]: e.target.value
}))
}
Expand All @@ -43,7 +44,7 @@ function Details() {

if (!id) return;
if (!goalMemory) {
return navigate('/notFound');
return navigate('/list');
}
setForm(goalMemory);
}, [id, state.objects, navigate]);
Expand Down Expand Up @@ -139,7 +140,7 @@ function Details() {
onChange={(e) => {onChange(e, 'icon')}}
>
{icons.map((icon) => {
return <option key={icon} value={icon}>{icon}</option>
return <option key={icon} /*value={icon}*/>{icon}</option>
})}
</select>
</label>
Expand Down
8 changes: 6 additions & 2 deletions src/services/Memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ const reducer = (state, action) => {
orderList: [...state.orderList, id],
objects: {
...state.objects,
[id]: action.goal
[id]: {
...action.goal,
id
}
}
}
}
Expand All @@ -90,9 +93,10 @@ const reducer = (state, action) => {
}
case 'DELETE_GOAL': {
const id = action.goal.id;
const newOrder = state.orderList.filter((goalId) => goalId !== id);
delete state.objects[id];
return {
orderList: state.orderList.filter((goalId) => goalId !== id),
orderList: newOrder,
objects: { ...state.objects }
}
}
Expand Down

0 comments on commit d3b0a68

Please sign in to comment.