Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TodoList
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
Sakilesh J
TodoList
Commits
98c2977c
Commit
98c2977c
authored
Jun 04, 2024
by
Sakilesh J
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the changes
parent
7cd34a85
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
122 additions
and
224 deletions
+122
-224
todoTypes.ts
Types/todoTypes.ts
+12
-0
FormComponent.tsx
components/Top-Level/Form/FormComponent.tsx
+9
-9
form.module.css
components/Top-Level/Form/form.module.css
+7
-6
form.stories.tsx
components/Top-Level/Form/form.stories.tsx
+3
-2
Item.tsx
components/Top-Level/Item/Item.tsx
+12
-18
item.module.css
components/Top-Level/Item/item.module.css
+9
-2
item.stories.tsx
components/Top-Level/Item/item.stories.tsx
+3
-11
Button.stories.tsx
components/base/Button/Button.stories.tsx
+0
-4
Button.tsx
components/base/Button/Button.tsx
+1
-29
Heading.stories.tsx
components/base/Heading/Heading.stories.tsx
+0
-3
Heading.tsx
components/base/Heading/Heading.tsx
+7
-2
Input.stories.tsx
components/base/input/Input.stories.tsx
+5
-5
Input.tsx
components/base/input/Input.tsx
+3
-4
input.module.css
components/base/input/input.module.css
+6
-30
List.tsx
components/layout/List/List.tsx
+5
-10
list.stories.tsx
components/layout/List/list.stories.tsx
+5
-10
types.d.ts
components/types.d.ts
+0
-9
db.json
db.json
+7
-16
TodoOperations.ts
lib/TodoOperations.ts
+0
-0
getall.ts
lib/getall.ts
+0
-1
Todo.tsx
pages/Todo.tsx
+24
-49
data.ts
utils/data.ts
+4
-4
No files found.
Types/todoTypes.ts
0 → 100644
View file @
98c2977c
export
interface
TodoListItems
{
id
:
number
;
task
:
string
;
isCompleted
:
boolean
;
}
export
interface
ItemMethods
{
onDelete
:
(
id
:
number
)
=>
void
;
updateTask
:
(
id
:
number
,
task
:
string
,
isCompleted
:
boolean
)
=>
void
;
}
\ No newline at end of file
components/Top-Level/Form/FormComponent.tsx
View file @
98c2977c
...
@@ -6,35 +6,35 @@ import styles from "./form.module.css"
...
@@ -6,35 +6,35 @@ import styles from "./form.module.css"
interface
FormProps
{
interface
FormProps
{
handleSubmit
:
(
data
:
any
)
=>
Promise
<
void
>
;
onPost
:
(
input
:
string
)
=>
void
;
}
}
const
FormComponent
:
React
.
FC
<
FormProps
>
=
({
handleSubmi
t
})
=>
{
const
FormComponent
:
React
.
FC
<
FormProps
>
=
({
onPos
t
})
=>
{
const
[
input
,
setinput
]
=
useState
(
''
)
const
[
input
,
setinput
]
=
useState
(
''
)
const
[
isError
,
setisError
]
=
useState
(
false
)
const
[
isError
,
setisError
]
=
useState
(
false
)
const
onSubmit
=
(
e
:
React
.
SyntheticEvent
)
=>
{
const
handleSubmit
=
(
e
:
React
.
SyntheticEvent
)
=>
{
e
.
preventDefault
();
e
.
preventDefault
();
console
.
log
(
e
)
if
(
input
===
''
)
{
if
(
input
===
''
)
{
setisError
(
true
)
setisError
(
true
)
return
return
}
}
handleSubmi
t
(
input
)
onPos
t
(
input
)
}
}
const
handleChange
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleChange
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setinput
(
e
.
target
.
value
)
setinput
(
e
.
target
.
value
)
if
(
isError
)
{
if
(
isError
)
{
setisError
(
false
)
setisError
(
false
)
}
}
}
}
return
(
return
(
<
form
className=
{
styles
.
form
}
onSubmit=
{
on
Submit
}
>
<
form
className=
{
styles
.
form
}
onSubmit=
{
handle
Submit
}
>
<
div
className=
{
styles
.
i
w
rapper
}
>
<
div
className=
{
styles
.
i
nputW
rapper
}
>
<
Input
placeholder=
"Enter Item..."
<
Input
placeholder=
"Enter Item..."
onChange=
{
handleChange
}
ErrorMessage=
{
isError
?
"Enter the Field"
:
undefined
}
/>
onChange=
{
handleChange
}
ErrorMessage=
{
isError
?
"Enter the Field"
:
undefined
}
/>
</
div
>
</
div
>
<
div
className=
{
styles
.
b
w
rapper
}
>
<
div
className=
{
styles
.
b
uttonW
rapper
}
>
<
Button
size=
"sm"
>
<
Button
size=
"sm"
>
Submit
Submit
</
Button
>
</
Button
>
...
...
components/Top-Level/Form/form.module.css
View file @
98c2977c
.form
{
.form
{
display
:
flex
;
display
:
flex
;
padding
:
20
px
;
padding
:
17
px
;
width
:
100%
;
width
:
100%
;
flex-wrap
:
wrap
;
flex-wrap
:
wrap
;
gap
:
15px
;
gap
:
15px
;
background-color
:
white
;
background-color
:
white
;
}
}
.i
w
rapper
{
.i
nputW
rapper
{
min-width
:
80%
;
min-width
:
80%
;
max-height
:
50px
;
max-height
:
min-content
;
flex
:
1
;
flex
:
1
;
}
}
.i
w
rapper
>
input
{
.i
nputW
rapper
>
input
{
width
:
100%
;
width
:
100%
;
}
}
.b
w
rapper
>
button
{
.b
uttonW
rapper
>
button
{
min-width
:
100%
;
min-width
:
100%
;
}
}
.b
w
rapper
{
.b
uttonW
rapper
{
min-width
:
auto
;
min-width
:
auto
;
flex
:
1
;
flex
:
1
;
}
}
\ No newline at end of file
components/Top-Level/Form/form.stories.tsx
View file @
98c2977c
...
@@ -2,7 +2,7 @@ import { Meta, StoryObj } from "@storybook/react";
...
@@ -2,7 +2,7 @@ import { Meta, StoryObj } from "@storybook/react";
import
FormComponent
from
"./FormComponent"
;
import
FormComponent
from
"./FormComponent"
;
import
{
fn
}
from
"@storybook/test"
;
import
{
fn
}
from
"@storybook/test"
;
const
meta
:
Meta
<
typeof
FormComponent
>
=
{
const
meta
:
Meta
<
typeof
FormComponent
>
=
{
title
:
"Top-Level
/Form
"
,
title
:
"Top-Level"
,
component
:
FormComponent
,
component
:
FormComponent
,
}
}
...
@@ -12,6 +12,6 @@ type story = StoryObj<typeof meta>
...
@@ -12,6 +12,6 @@ type story = StoryObj<typeof meta>
export
const
Form
:
story
=
{
export
const
Form
:
story
=
{
args
:
{
args
:
{
handleSubmi
t
:
fn
()
onPos
t
:
fn
()
}
}
}
}
\ No newline at end of file
components/Top-Level/Item/Item.tsx
View file @
98c2977c
...
@@ -4,25 +4,25 @@ import styles from './item.module.css'
...
@@ -4,25 +4,25 @@ import styles from './item.module.css'
import
Input
from
'@/components/base/input/Input'
;
import
Input
from
'@/components/base/input/Input'
;
import
closeIcon
from
'@/public/icons/red-x-10333.svg'
;
import
closeIcon
from
'@/public/icons/red-x-10333.svg'
;
import
Image
from
'next/image'
;
import
Image
from
'next/image'
;
export
interface
ItemProps
{
import
{
ItemMethods
}
from
'@/Types/todoTypes'
;
interface
ItemProps
extends
ItemMethods
{
id
:
number
;
id
:
number
;
task
:
string
;
task
:
string
;
isCompleted
:
boolean
;
isCompleted
:
boolean
;
onClose
:
(
id
:
number
)
=>
void
;
updateTask
:
(
id
:
number
,
task
:
string
,
isCompleted
:
boolean
)
=>
void
;
}
}
const
Item
:
React
.
FC
<
ItemProps
>
=
({
task
,
isCompleted
,
on
Clos
e
,
updateTask
,
id
})
=>
{
const
Item
:
React
.
FC
<
ItemProps
>
=
({
task
,
isCompleted
,
on
Delet
e
,
updateTask
,
id
})
=>
{
const
[
isChecked
,
setisChecked
]
=
useState
(
isCompleted
)
const
[
isChecked
,
setisChecked
]
=
useState
(
isCompleted
)
useEffect
(()
=>
{
useEffect
(()
=>
{
setisChecked
(
isCompleted
)
setisChecked
(
isCompleted
)
},
[
isCompleted
])
},
[
isCompleted
])
const
handleChange
=
async
()
=>
{
const
handleChange
=
async
()
=>
{
const
res
:
any
=
await
updateTask
(
id
,
task
,
!
isCompleted
)
await
updateTask
(
id
,
task
,
!
isCompleted
)
if
(
res
)
{
setisChecked
(
!
isChecked
)
setisChecked
(
!
isChecked
)
}
}
}
const
handleItem
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleItem
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
...
@@ -30,22 +30,16 @@ const Item: React.FC<ItemProps> = ({ task, isCompleted, onClose, updateTask, id
...
@@ -30,22 +30,16 @@ const Item: React.FC<ItemProps> = ({ task, isCompleted, onClose, updateTask, id
}
}
const
handleClose
=
()
=>
{
const
handleClose
=
()
=>
{
on
Clos
e
(
id
)
on
Delet
e
(
id
)
}
}
return
(
return
(
<
div
className=
{
styles
.
item
s
}
>
<
div
className=
{
styles
.
item
}
>
<
input
type=
'checkbox'
checked=
{
isChecked
}
onChange=
{
handleChange
}
className=
{
styles
.
checkbox
}
/>
<
input
type=
'checkbox'
checked=
{
isChecked
}
onChange=
{
handleChange
}
className=
{
styles
.
checkbox
}
/>
<
Input
placeholder=
'Enter item...'
defaultValue=
{
task
}
onBlur=
{
handleItem
}
style=
{
{
<
Input
id=
"Todo-input"
placeholder=
'Enter item...'
defaultValue=
{
task
}
onBlur=
{
handleItem
}
style=
{
{
border
:
'none'
,
textDecoration
:
isChecked
?
'line-through'
:
'none'
boxShadow
:
'none'
,
padding
:
0
,
color
:
'gray'
,
fontSize
:
'18px'
,
textDecoration
:
isChecked
?
'line-through'
:
''
}
}
/>
}
}
/>
<
div
className=
{
styles
.
actions
}
onClick=
{
handleClose
}
>
<
div
className=
{
styles
.
actions
}
onClick=
{
handleClose
}
>
<
Image
src=
{
closeIcon
}
alt=
""
width=
{
22
}
height=
{
22
}
className=
{
styles
.
closeIcon
}
/>
<
Image
src=
{
closeIcon
}
alt=
""
width=
{
22
}
height=
{
22
}
className=
{
styles
.
closeIcon
}
/>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
components/Top-Level/Item/item.module.css
View file @
98c2977c
.item
s
{
.item
{
display
:
flex
;
display
:
flex
;
border-bottom
:
.01px
solid
rgb
(
236
,
231
,
231
);
border-bottom
:
.01px
solid
rgb
(
236
,
231
,
231
);
padding
:
10px
20px
;
padding
:
10px
20px
;
...
@@ -15,6 +15,14 @@
...
@@ -15,6 +15,14 @@
/* outline: 1px solid black; */
/* outline: 1px solid black; */
}
}
.item
>
div
>
input
{
border
:
none
;
box-shadow
:
none
;
padding
:
0
;
color
:
gray
;
font-size
:
18px
;
}
.actions
{
.actions
{
margin-left
:
auto
;
margin-left
:
auto
;
min-width
:
1.3rem
;
min-width
:
1.3rem
;
...
@@ -25,7 +33,6 @@
...
@@ -25,7 +33,6 @@
display
:
flex
;
display
:
flex
;
justify-content
:
center
;
justify-content
:
center
;
align-items
:
center
;
align-items
:
center
;
/* padding-top: 3px; */
}
}
.actions
:hover
{
.actions
:hover
{
...
...
components/Top-Level/Item/item.stories.tsx
View file @
98c2977c
...
@@ -4,13 +4,6 @@ import { fn } from "@storybook/test";
...
@@ -4,13 +4,6 @@ import { fn } from "@storybook/test";
const
meta
:
Meta
<
typeof
Item
>
=
{
const
meta
:
Meta
<
typeof
Item
>
=
{
title
:
"Top-Level"
,
title
:
"Top-Level"
,
component
:
Item
,
component
:
Item
,
argTypes
:
{
id
:
{
control
:
{
type
:
'text'
}
}
}
}
}
...
@@ -19,12 +12,11 @@ export default meta;
...
@@ -19,12 +12,11 @@ export default meta;
type
story
=
StoryObj
<
typeof
meta
>
type
story
=
StoryObj
<
typeof
meta
>
export
const
Item_
:
story
=
{
export
const
Item_
:
story
=
{
args
:
{
args
:
{
id
:
'1'
,
id
:
1
,
isCompleted
:
true
,
isCompleted
:
true
,
task
:
'Buy groceries'
,
task
:
'Buy groceries'
,
onComplete
:
fn
(),
onDelete
:
fn
(),
onChange
:
fn
(),
updateTask
:
fn
()
onClose
:
fn
()
},
},
}
}
...
...
components/base/Button/Button.stories.tsx
View file @
98c2977c
...
@@ -11,10 +11,6 @@ export default meta;
...
@@ -11,10 +11,6 @@ export default meta;
type
Story
=
StoryObj
<
typeof
meta
>
;
type
Story
=
StoryObj
<
typeof
meta
>
;
// interface TemplateProps {
// variant: 'primary' | 'light' | 'dark';
// }
const
Template
=
()
=>
{
const
Template
=
()
=>
{
return
(
return
(
<
div
>
<
div
>
...
...
components/base/Button/Button.tsx
View file @
98c2977c
...
@@ -19,35 +19,7 @@ export default function Button({
...
@@ -19,35 +19,7 @@ export default function Button({
children
,
children
,
...
rest
...
rest
}:
ButtonProps
)
{
}:
ButtonProps
)
{
// const classNames = cn(
// 'inline-flex items-center font-medium uppercase focus:outline-none',
// {
// /** backgrounds */
// 'bg-gray-200': disabled,
// 'bg-primary text-light shadow-primary':
// !disabled && !outline && variant === 'primary',
// 'bg-light text-dark shadow-light':
// !disabled && !outline && variant === 'light',
// 'bg-dark text-light shadow-dark':
// !disabled && !outline && variant === 'dark',
// /** outline */
// 'text-primary border-current border shadow-primary':
// !disabled && outline && variant === 'primary',
// 'text-light border-current border shadow-light':
// !disabled && outline && variant === 'light',
// 'text-dark border-current border shadow-dark':
// !disabled && outline && variant === 'dark',
// /** text */
// 'text-gray-400': disabled,
// /* size */
// 'text-sm px-8 py-3': size === 'sm',
// 'text-base px-9 py-3': size === 'md',
// /** block */
// 'w-full justify-center': block,
// /** hover, focus & active */
// 'hover:shadow-xl focus:shadow-glow active:translate-y-0.5': !disabled
// }
// );
const
classNames
=
`
${
style
.
btn
}
${
size
===
'sm'
?
style
.
sm
:
style
.
md
}
`
const
classNames
=
`
${
style
.
btn
}
${
size
===
'sm'
?
style
.
sm
:
style
.
md
}
`
return
typeof
href
===
'string'
?
(
return
typeof
href
===
'string'
?
(
...
...
components/base/Heading/Heading.stories.tsx
View file @
98c2977c
...
@@ -4,9 +4,6 @@ import Heading from "./Heading";
...
@@ -4,9 +4,6 @@ import Heading from "./Heading";
const
meta
:
Meta
<
typeof
Heading
>
=
{
const
meta
:
Meta
<
typeof
Heading
>
=
{
title
:
"Basic/Header"
,
title
:
"Basic/Header"
,
component
:
Heading
,
component
:
Heading
,
argTypes
:
{
count
:
{
count
:
'number'
}
},
}
}
export
default
meta
;
export
default
meta
;
...
...
components/base/Heading/Heading.tsx
View file @
98c2977c
import
React
from
'react'
import
React
from
'react'
import
styles
from
"./heading.module.css"
import
styles
from
"./heading.module.css"
interface
HeadingProps
{
interface
HeadingProps
{
count
:
number
;
count
?
:
number
;
}
}
const
Heading
:
React
.
FC
<
HeadingProps
>
=
({
count
})
=>
{
const
Heading
:
React
.
FC
<
HeadingProps
>
=
({
count
})
=>
{
return
(
return
(
<
div
className=
{
styles
.
heading
}
>
You have
{
count
!=
0
?
count
:
"no"
}
Todos
</
div
>
<
React
.
Fragment
>
{
count
!=
undefined
&&
<
div
className=
{
styles
.
heading
}
>
You have
{
count
!=
0
?
count
:
"no"
}
Todos
</
div
>
}
</
React
.
Fragment
>
)
)
}
}
...
...
components/base/input/Input.stories.tsx
View file @
98c2977c
import
{
Meta
,
StoryObj
}
from
"@storybook/react"
;
import
{
Meta
,
StoryObj
}
from
"@storybook/react"
;
import
Input
from
"./Input"
;
import
Input
from
"./Input"
;
import
{
fn
}
from
"@storybook/test"
;
import
{
fn
}
from
"@storybook/test"
;
import
React
from
"react"
;
const
meta
:
Meta
<
typeof
Input
>
=
{
const
meta
:
Meta
<
typeof
Input
>
=
{
title
:
"Basic"
,
component
:
Input
,
component
:
Input
,
title
:
"Basic/Input"
,
tags
:
[
"autodocs"
]
}
}
export
default
meta
export
default
meta
type
story
=
StoryObj
<
typeof
meta
>
;
type
story
=
StoryObj
<
typeof
meta
>
;
export
const
Primary
:
story
=
{
export
const
Input_
:
story
=
{
args
:
{
args
:
{
placeholder
:
'Enter the value...'
,
placeholder
:
'Enter the value...'
,
onChange
:
fn
(),
onChange
:
fn
(),
},
},
render
:
(
args
)
=>
{
render
:
(
args
)
=>
{
return
<>
return
<
React
.
Fragment
>
<
p
>
Without Error
</
p
>
<
p
>
Without Error
</
p
>
<
Input
{
...
args
}
/>
<
Input
{
...
args
}
/>
<
p
>
With Error
</
p
>
<
p
>
With Error
</
p
>
<
Input
{
...
args
}
ErrorMessage=
"Enter the Fields"
/>
<
Input
{
...
args
}
ErrorMessage=
"Enter the Fields"
/>
</>
</
React
.
Fragment
>
}
}
}
}
components/base/input/Input.tsx
View file @
98c2977c
...
@@ -6,9 +6,8 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
...
@@ -6,9 +6,8 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
const
Input
:
React
.
FC
<
InputProps
>
=
({
ErrorMessage
,
...
props
})
=>
{
const
Input
:
React
.
FC
<
InputProps
>
=
({
ErrorMessage
,
...
props
})
=>
{
return
(
return
(
<>
<
div
className=
{
styles
.
Container
}
>
<
input
{
...
props
}
className=
{
`${ErrorMessage
<
input
{
...
props
}
className=
{
`${styles.input} ${ErrorMessage
&& styles.inputError}`
}
/>
&& styles.inputError}`
}
/>
{
{
ErrorMessage
&&
ErrorMessage
&&
...
@@ -16,7 +15,7 @@ const Input: React.FC<InputProps> = ({ ErrorMessage, ...props }) => {
...
@@ -16,7 +15,7 @@ const Input: React.FC<InputProps> = ({ ErrorMessage, ...props }) => {
{
ErrorMessage
}
{
ErrorMessage
}
</
div
>
</
div
>
}
}
</>
</
div
>
)
)
}
}
...
...
components/base/input/input.module.css
View file @
98c2977c
.input
{
.
Container
input
{
padding
:
15px
20px
;
padding
:
15px
20px
;
border-radius
:
5px
;
border-radius
:
5px
;
border
:
2px
solid
#d2d2d2
;
border
:
2px
solid
#d2d2d2
;
...
@@ -8,47 +8,24 @@
...
@@ -8,47 +8,24 @@
width
:
100%
;
width
:
100%
;
}
}
.input
::placeholder
{
.
Container
input
::placeholder
{
font-size
:
15px
;
font-size
:
15px
;
}
}
.input
:focus
{
.
Container
input
:focus
{
outline
:
none
;
outline
:
none
;
border
:
2px
solid
rgb
(
189
,
189
,
189
);
border
:
2px
solid
rgb
(
189
,
189
,
189
);
}
}
.strike
{
text-decoration
:
line-through
;
}
.error
{
.error
{
color
:
red
;
color
:
red
;
font-family
:
'Segoe UI'
,
Tahoma
,
Geneva
,
Verdana
,
sans-serif
;
font-family
:
'Segoe UI'
,
Tahoma
,
Geneva
,
Verdana
,
sans-serif
;
padding
:
10
px
;
margin-top
:
2
px
;
font-size
:
13px
;
font-size
:
13px
;
}
}
.inputError
{
.
Container
.
inputError
{
border
:
1px
solid
red
;
border
:
1px
solid
red
;
}
.invisible
{
padding-inline
:
0px
;
border
:
none
;
font-size
:
16px
;
color
:
gray
;
background-color
:
transparent
;
box-shadow
:
none
;
padding-block
:
10px
;
}
.invisible
::placeholder
{
font-size
:
18px
;
}
.invisible
:focus
{
outline
:
none
;
border
:
none
;
}
}
\ No newline at end of file
components/layout/List/List.tsx
View file @
98c2977c
import
Item
from
"@/components/Top-Level/Item/Item"
;
import
Item
from
"@/components/Top-Level/Item/Item"
;
import
styles
from
"./list.module.css"
;
import
styles
from
"./list.module.css"
;
interface
ListItemProps
{
import
{
ItemMethods
,
TodoListItems
}
from
"@/Types/todoTypes"
;
data
:
{
interface
ListItemProps
extends
ItemMethods
{
id
:
number
;
data
:
TodoListItems
[];
task
:
string
;
isCompleted
:
boolean
;
}[];
onClose
:
(
id
:
number
)
=>
void
;
updateTask
:
(
id
:
number
,
task
:
string
,
isCompleted
:
boolean
)
=>
void
;
}
}
const
ListItem
:
React
.
FC
<
ListItemProps
>
=
({
data
,
updateTask
,
on
Clos
e
})
=>
{
const
ListItem
:
React
.
FC
<
ListItemProps
>
=
({
data
,
updateTask
,
on
Delet
e
})
=>
{
return
(
return
(
<
div
className=
{
styles
.
list
}
>
<
div
className=
{
styles
.
list
}
>
{
{
...
@@ -19,7 +14,7 @@ const ListItem: React.FC<ListItemProps> = ({ data, updateTask, onClose }) => {
...
@@ -19,7 +14,7 @@ const ListItem: React.FC<ListItemProps> = ({ data, updateTask, onClose }) => {
key=
{
item
.
id
}
key=
{
item
.
id
}
{
...
item
}
{
...
item
}
updateTask=
{
updateTask
}
updateTask=
{
updateTask
}
on
Close=
{
onClos
e
}
on
Delete=
{
onDelet
e
}
/>
/>
)
)
})
})
...
...
components/layout/List/list.stories.tsx
View file @
98c2977c
...
@@ -17,22 +17,17 @@ type Story = StoryObj<typeof meta>;
...
@@ -17,22 +17,17 @@ type Story = StoryObj<typeof meta>;
export
const
List_
:
Story
=
{
export
const
List_
:
Story
=
{
args
:
{
args
:
{
data
:
List_data
,
data
:
List_data
,
onChange
:
fn
(),
onDelete
:
fn
(),
onClose
:
fn
(),
updateTask
:
fn
()
onComplete
:
fn
()
}
}
};
};
export
const
Todos
:
Story
=
{
export
const
Todos
:
Story
=
{
args
:
{
args
:
{
data
:
List_data
,
data
:
List_data
,
onChange
:
fn
(),
onDelete
:
fn
(),
onClose
:
fn
(),
updateTask
:
fn
()
onComplete
:
fn
()
},
},
// parameters: {
// layout: 'centered',
// },
render
:
(
args
)
=>
(
render
:
(
args
)
=>
(
<
div
style=
{
{
<
div
style=
{
{
display
:
'flex'
,
display
:
'flex'
,
...
@@ -49,7 +44,7 @@ export const Todos: Story = {
...
@@ -49,7 +44,7 @@ export const Todos: Story = {
}
}
>
}
}
>
<
Heading
count=
{
args
.
data
.
length
}
/>
<
Heading
count=
{
args
.
data
.
length
}
/>
<
List
{
...
args
}
/>
<
List
{
...
args
}
/>
<
FormComponent
handleSubmi
t=
{
fn
()
}
/>
<
FormComponent
onPos
t=
{
fn
()
}
/>
</
div
>
</
div
>
</
div
>
</
div
>
)
)
...
...
components/types.d.ts
View file @
98c2977c
...
@@ -11,11 +11,3 @@ export interface ISocialLink {
...
@@ -11,11 +11,3 @@ export interface ISocialLink {
url
:
string
;
url
:
string
;
label
?:
string
;
label
?:
string
;
}
}
export
interface
TodoListItems
{
id
:
number
;
task
:
string
;
isCompleted
:
boolean
;
}
\ No newline at end of file
db.json
View file @
98c2977c
{
{
"tasks"
:
[
"tasks"
:
[
{
{
"id"
:
1
,
"task"
:
"new todo"
,
"task"
:
"clg"
,
"isCompleted"
:
false
},
{
"id"
:
2
,
"task"
:
"new"
,
"isCompleted"
:
true
},
{
"task"
:
"jake"
,
"isCompleted"
:
true
,
"isCompleted"
:
true
,
"id"
:
3
"id"
:
1
},
},
{
{
"task"
:
"
items
"
,
"task"
:
"
new element
"
,
"isCompleted"
:
false
,
"isCompleted"
:
false
,
"id"
:
5
"id"
:
2
},
},
{
{
"task"
:
"
another items
"
,
"task"
:
"
Nothing
"
,
"isCompleted"
:
false
,
"isCompleted"
:
false
,
"id"
:
6
"id"
:
3
}
}
]
]
}
}
\ No newline at end of file
lib/
Operation
.ts
→
lib/
TodoOperations
.ts
View file @
98c2977c
File moved
lib/getall.ts
View file @
98c2977c
...
@@ -2,7 +2,6 @@ import { Axios } from "./Instance";
...
@@ -2,7 +2,6 @@ import { Axios } from "./Instance";
export
default
async
function
getall
()
{
export
default
async
function
getall
()
{
try
{
try
{
const
res
=
await
Axios
.
get
(
''
);
const
res
=
await
Axios
.
get
(
''
);
return
await
res
.
data
return
await
res
.
data
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
pages/Todo.tsx
View file @
98c2977c
"use client"
"use client"
import
style
from
"./todoapp.module.css"
import
React
from
"react"
;
import
{
useState
,
useEffect
}
from
"react"
;
import
{
useState
,
useEffect
}
from
"react"
;
import
style
from
"./todoapp.module.css"
import
Heading
from
"@/components/base/Heading/Heading"
;
import
Heading
from
"@/components/base/Heading/Heading"
;
import
List
from
"@/components/layout/List/List"
;
import
List
from
"@/components/layout/List/List"
;
import
FormComponent
from
"@/components/Top-Level/Form/FormComponent"
;
import
FormComponent
from
"@/components/Top-Level/Form/FormComponent"
;
import
{
TodoListItems
}
from
"@/components/types"
;
import
{
TodoListItems
}
from
"@/components/types"
;
import
AddTask
,
{
UpdateTask
,
DeleteTask
}
from
"@/lib/
Operation
"
;
import
AddTask
,
{
UpdateTask
,
DeleteTask
}
from
"@/lib/
TodoOperations
"
;
import
getall
from
"@/lib/getall"
;
import
getall
from
"@/lib/getall"
;
interface
StateTodo
{
interface
StateTodo
{
data
?:
TodoListItems
[],
data
?:
TodoListItems
[],
...
@@ -52,45 +53,34 @@ const Todo = () => {
...
@@ -52,45 +53,34 @@ const Todo = () => {
setrefresh
(
!
refresh
)
setrefresh
(
!
refresh
)
}
}
}
}
const
handle
Add
=
async
(
task
:
string
)
=>
{
const
handle
Post
=
async
(
task
:
string
)
=>
{
const
result
=
await
AddTask
(
task
)
const
result
=
await
AddTask
(
task
)
if
(
result
)
{
if
(
result
)
{
setrefresh
(
!
refresh
)
setrefresh
(
!
refresh
)
}
}
}
}
if
(
TodoList
.
isLoading
)
{
return
(<
Wrapper
>
<
div
className=
{
style
.
loading
}
/>
</
Wrapper
>)
}
if
(
TodoList
.
isError
)
{
return
(
<
Wrapper
>
<
h2
className=
{
style
.
notFound
}
>
Something went wrong
</
h2
>
</
Wrapper
>
)
}
return
(
<
Wrapper
>
{
TodoList
.
data
&&
(
<>
<
Heading
count=
{
TodoList
.
data
.
length
}
/>
{
TodoList
.
data
.
length
!==
0
&&
<
List
data=
{
TodoList
.
data
}
onClose=
{
handleDelete
}
updateTask=
{
UpdateTask
}
/>
}
<
FormComponent
handleSubmit=
{
handleAdd
}
/>
</>
)
}
return
(
<
div
className=
{
style
.
container
}
>
<
div
className=
{
style
.
todoWrapper
}
>
{
TodoList
.
isLoading
&&
<
div
className=
{
style
.
loading
}
/>
}
{
TodoList
.
isError
&&
<
h2
className=
{
style
.
notFound
}
>
Something went wrong
</
h2
>
}
{
!
TodoList
.
isError
&&
!
TodoList
.
isLoading
&&
TodoList
.
data
&&
(
<
React
.
Fragment
>
<
Heading
count=
{
TodoList
.
data
.
length
}
/>
{
TodoList
.
data
.
length
!==
0
&&
<
List
data=
{
TodoList
.
data
}
onDelete=
{
handleDelete
}
updateTask=
{
UpdateTask
}
/>
}
<
FormComponent
onPost=
{
handlePost
}
/>
</
React
.
Fragment
>
)
}
</
div
>
</
div
>
</
Wrapper
>
);
);
}
}
...
@@ -100,17 +90,3 @@ export default Todo;
...
@@ -100,17 +90,3 @@ export default Todo;
type
WrapperProps
=
{
children
:
React
.
ReactNode
;
}
const
Wrapper
:
React
.
FC
<
WrapperProps
>
=
({
children
})
=>
{
return
(
<
div
className=
{
style
.
container
}
>
<
div
className=
{
style
.
todoWrapper
}
>
{
children
}
</
div
>
</
div
>
)
}
\ No newline at end of file
utils/data.ts
View file @
98c2977c
export
const
List_data
=
[
export
const
List_data
=
[
{
{
id
:
" 1"
,
id
:
1
,
task
:
"Buy the Groceries"
,
task
:
"Buy the Groceries"
,
isCompleted
:
true
isCompleted
:
true
},
},
{
{
id
:
" 2"
,
id
:
2
,
task
:
"Buy the food"
,
task
:
"Buy the food"
,
isCompleted
:
false
isCompleted
:
false
},
},
{
{
id
:
"3"
,
id
:
3
,
task
:
"pay the rent"
,
task
:
"pay the rent"
,
isCompleted
:
false
isCompleted
:
false
},
},
{
{
id
:
" 4"
,
id
:
4
,
task
:
"savings the money"
,
task
:
"savings the money"
,
isCompleted
:
true
isCompleted
:
true
}
}
...
...
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