Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
todo-app
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
Syed Abdul Rahman
todo-app
Commits
3cf242ab
Commit
3cf242ab
authored
May 28, 2025
by
Syed Abdul Rahman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes in cors handling
parent
c96c5244
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
35 deletions
+14
-35
db.json
db.json
+6
-31
App.tsx
src/App.tsx
+8
-4
No files found.
db.json
View file @
3cf242ab
{
"todos"
:
[
{
"id"
:
"
5250
"
,
"title"
:
"
qwer
"
,
"id"
:
"
a904
"
,
"title"
:
"
Buy groceries tomorrow
"
,
"completed"
:
false
},
{
"id"
:
"a
eb0
"
,
"title"
:
"
qwr
e"
,
"id"
:
"a
175
"
,
"title"
:
"
Travel to head offic
e"
,
"completed"
:
false
},
{
"id"
:
"7e99"
,
"title"
:
"qwer"
,
"completed"
:
false
},
{
"id"
:
"4dca"
,
"title"
:
"qwer"
,
"completed"
:
false
},
{
"id"
:
"2c46"
,
"title"
:
"qwre"
,
"completed"
:
false
},
{
"id"
:
"224e"
,
"title"
:
"qwer"
,
"completed"
:
false
},
{
"id"
:
"023a"
,
"title"
:
"qre"
,
"completed"
:
false
},
{
"id"
:
"91d5"
,
"title"
:
"qwer"
,
"id"
:
"2753"
,
"title"
:
"Get phone from head office"
,
"completed"
:
false
}
]
...
...
src/App.tsx
View file @
3cf242ab
...
...
@@ -17,7 +17,11 @@ function App() {
},
[])
const
fetchTodos
=
async
()
=>
{
const
response
=
await
fetch
(
'http://localhost:3000/todos'
);
const
response
=
await
fetch
(
'http://localhost:3000/todos'
,
{
headers
:
{
'Content-Type'
:
'application/json'
,
},
});
if
(
!
response
.
ok
)
{
console
.
log
(
"Error fetching data"
)
}
...
...
@@ -43,7 +47,7 @@ function App() {
}
}
const
toggleTodo
=
async
(
todoItem
:
any
,
e
:
any
)
=>
{
const
toggleTodo
=
async
(
todoItem
:
any
,
e
:
any
)
=>
{
e
.
stopPropagation
()
console
.
log
(
todoItem
,
"todoItem.completed"
)
await
fetch
(
`http://localhost:3000/todos/
${
todoItem
.
id
}
`
,
{
...
...
@@ -84,7 +88,7 @@ function App() {
e.stopPropagation()
}
const onSaveEdit = async(e: any, todoId: any) => {
const onSaveEdit = async
(e: any, todoId: any) => {
e.stopPropagation();
await fetch(`
http
:
//localhost:3000/todos/${todoId}`, {
method
:
'PATCH'
,
...
...
@@ -110,7 +114,7 @@ function App() {
<div className='checklist-item'>
<div className='checklist-item__content' onClick={() => editTodo(ele.id)}>
<input type='checkbox' checked={ele.completed} className='custom-checkbox'
onClick={(e) => e.stopPropagation()} onChange={(e) => toggleTodo(ele,
e)} />
<input type='checkbox' checked={ele.completed} className='custom-checkbox'
onClick={(e) => e.stopPropagation()} onChange={(e) => toggleTodo(ele,
e)} />
{editingTodoId === ele.id ? (
<input type='text' value={editableTitle} className='checklist-item__editable-input' onChange={(e) => setEditableTitle(e.target.value)} />
) : (
...
...
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