Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
Todo-Storybook
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Madhankumar
Todo-Storybook
Commits
3fc39fc9
Commit
3fc39fc9
authored
Sep 19, 2023
by
Madhankumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apicontext
parent
7bc8167f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
28 deletions
+23
-28
db.json
db.json
+0
-7
App.js
src/App.js
+1
-1
index.js
src/appcontext/index.js
+2
-7
index.js
src/components/base/checkbox/index.js
+4
-2
index.js
src/components/top-level/task/index.js
+16
-11
No files found.
db.json
View file @
3fc39fc9
...
...
@@ -11,12 +11,6 @@
"title"
:
"helloxxsxsxsxsxsxsxsxsxsxsxsxsxssssssssssssssssssssxssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssadddadsdsdsadasasasadasaadadadaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaavrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrryyyyy"
,
"isCompleted"
:
false
,
"id"
:
2
},
{
"sId"
:
1
,
"title"
:
"bbb"
,
"isCompleted"
:
true
,
"id"
:
6
}
]
}
\ No newline at end of file
src/App.js
View file @
3fc39fc9
...
...
@@ -11,7 +11,7 @@ function App() {
useEffect
(()
=>
{
getTask
();
},
[]);
console
.
log
(
"okpp"
,
task
);
return
(
<
div
className
=
"App"
>
<
Layout
count
=
{
task
?.
filter
((
e
)
=>
!
e
.
isCompleted
).
length
}
>
...
...
src/appcontext/index.js
View file @
3fc39fc9
...
...
@@ -9,7 +9,7 @@ import {
}
from
"../lib/api"
;
export
const
TodoContext
=
createContext
();
export
const
useAppContext
=
()
=>
useContext
(
TodoContext
);
export
function
TodoProvider
({
children
,
...
props
})
{
export
function
TodoProvider
({
children
})
{
const
[
task
,
setTask
]
=
useState
([]);
//POST METHOD
...
...
@@ -24,7 +24,6 @@ export function TodoProvider({ children, ...props }) {
//PATCH METHOD
async
function
updateremainder
(
id
)
{
try
{
console
.
log
(
"llll"
,
id
);
const
response
=
await
updateRemainder
(
id
);
setTask
(
response
);
...
...
@@ -78,9 +77,5 @@ export function TodoProvider({ children, ...props }) {
deleteTask
,
updatetitle
,
};
return
(
<
TodoContext
.
Provider
value
=
{
value
}
{...
props
}
>
{
children
}
<
/TodoContext.Provider
>
);
return
<
TodoContext
.
Provider
value
=
{
value
}
>
{
children
}
<
/TodoContext.Provider>
;
}
src/components/base/checkbox/index.js
View file @
3fc39fc9
import
React
from
"react"
;
import
"./checkbox.css"
;
function
Checkbox
({
isCompleted
,
onChange
,
...
props
})
{
const
Checkbox
=
React
.
memo
(({
isCompleted
,
onChange
,
...
props
})
=>
{
console
.
log
(
"checkbox"
);
const
handleChange
=
()
=>
{
isCompleted
=
!
isCompleted
;
onChange
(
isCompleted
?
"checked"
:
"unchecked"
);
...
...
@@ -15,6 +17,6 @@ function Checkbox({ isCompleted, onChange, ...props }) {
/
>
<
/div
>
);
}
}
);
export
default
Checkbox
;
src/components/top-level/task/index.js
View file @
3fc39fc9
import
{
FaTimesCircle
}
from
"react-icons/fa"
;
import
Checkbox
from
"../../base/checkbox"
;
import
"./task.css"
;
import
{
useEffect
,
useRef
,
useLayoutEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useRef
,
useLayoutEffect
,
useState
,
useCallback
,
}
from
"react"
;
function
Task
({
id
,
title
,
isCompleted
,
onDelete
,
onChange
,
onEdit
})
{
const
[
isedit
,
setIsEdit
]
=
useState
(
false
);
const
[
debouncetitle
,
setDebounceTitle
]
=
useState
(
title
);
const
[
ischeck
,
setIsCheck
]
=
useState
(
isCompleted
);
const
textarea_ref
=
useRef
(
null
);
const
handleDelete
=
(
e
)
=>
{
...
...
@@ -17,13 +23,12 @@ function Task({ id, title, isCompleted, onDelete, onChange, onEdit }) {
}
return
false
;
};
const
handleChange
=
()
=>
{
isCompleted
=
!
isCompleted
;
onChange
({
id
,
isCompleted
:
is
Completed
?
true
:
false
});
};
const
handleChange
=
useCallback
(
()
=>
{
setIsCheck
(
!
ischeck
)
;
onChange
({
id
,
isCompleted
:
is
check
?
true
:
false
});
}
,
[
ischeck
])
;
const
handleContent
=
(
e
)
=>
{
setIsEdit
(
true
);
setDebounceTitle
(
e
.
target
.
value
);
const
textarea
=
document
.
querySelector
(
"textarea"
);
textarea
.
addEventListener
(
"keyup"
,
(
e
)
=>
{
...
...
@@ -35,10 +40,10 @@ function Task({ id, title, isCompleted, onDelete, onChange, onEdit }) {
//debounce
useEffect
(()
=>
{
const
handler
=
setTimeout
(()
=>
{
if
(
isedit
)
{
if
(
textarea_ref
.
current
.
value
!=
title
)
{
onEdit
({
id
,
title
:
debouncetitle
});
}
},
3
000
);
},
2
000
);
return
()
=>
{
clearTimeout
(
handler
);
...
...
@@ -54,8 +59,8 @@ function Task({ id, title, isCompleted, onDelete, onChange, onEdit }) {
<
div
>
<
Checkbox
onChange
=
{
handleChange
}
checked
=
{
is
Completed
}
disabled
=
{
isCompleted
}
checked
=
{
is
check
}
// disabled={ischeck
}
/
>
<
textarea
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment