-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
145 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use server'; | ||
|
||
import { API_TASK } from '../_constants/apiUrls'; | ||
import { apiPost } from '~/libs/apiClient'; | ||
import { Task } from '~/domains/Task'; | ||
|
||
export const postTask = async ({ | ||
body, | ||
title, | ||
dueDate, | ||
objectiveId, | ||
}: { | ||
body: string; | ||
title: string; | ||
dueDate: Date; | ||
objectiveId: string; | ||
}) => { | ||
return await apiPost<{ task: Task }>(API_TASK(), { | ||
body: JSON.stringify({ | ||
body, | ||
title, | ||
dueDate, | ||
objectiveId, | ||
}), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 69 additions & 8 deletions
77
src/app/_components/domains/Task/CreateTaskModal/CreateTaskModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
'use client'; | ||
|
||
import { FC, useCallback } from 'react'; | ||
import { FC } from 'react'; | ||
import { Editor } from '~/app/_components/uiParts/Editor'; | ||
import { Task } from '~/domains/Task'; | ||
|
||
type Props = { | ||
task?: Task; | ||
onChangeText: (body: string) => Promise<void>; | ||
}; | ||
|
||
export const TaskEditor: FC<Props> = ({ task }) => { | ||
const handleEditorChange = useCallback(async (body: string) => { | ||
console.log(body); | ||
}, []); | ||
|
||
return <Editor body={task?.body} onChange={handleEditorChange} placeholder="タスクの内容を記入しましょう" />; | ||
export const TaskEditor: FC<Props> = ({ onChangeText }) => { | ||
return <Editor onChange={onChangeText} placeholder="タスクの内容を記入しましょう" />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use client'; | ||
|
||
import './styles.scss'; | ||
|
||
import { useEffect, useState, FC, useCallback } from 'react'; | ||
import { Editor } from './Editor'; | ||
import { useDebounce } from '~/libs/useDebounce'; | ||
|
||
type Props = { | ||
body?: string; | ||
placeholder: string; | ||
onChange: (body: string) => Promise<void>; | ||
}; | ||
|
||
export const DebounceEditor: FC<Props> = ({ body, placeholder, onChange }) => { | ||
const [inputText, setInputText] = useState<string>(); | ||
const debouncedInputText = useDebounce({ value: inputText, delay: 200 }); | ||
|
||
const handleEditorChange = useCallback( | ||
async (body: string) => { | ||
await onChange(body); | ||
}, | ||
[onChange], | ||
); | ||
|
||
useEffect(() => { | ||
debouncedInputText && handleEditorChange(debouncedInputText); | ||
}, [debouncedInputText, handleEditorChange]); | ||
|
||
return <Editor body={body} placeholder={placeholder} onChange={(body) => setInputText(body)} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters