Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
itizawa committed Dec 17, 2023
1 parent a037a03 commit b84f533
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/[slug]/[date]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default async function Page({ params }: Props) {
<NippoBreadcrumbs objective={objective} date={dateString} />
<p className="mt-[32px] text-xl font-bold mb-[8px] text-gray-700">{dateString}</p>
{currentUser?._id === objective.createdUserId ? (
<NippoEditor objectiveId={objective._id} nippo={nippo} />
<NippoEditor objectiveId={objective._id} nippo={nippo} date={params.date} />
) : (
<NippoPreview nippo={nippo} />
)}
Expand Down
9 changes: 4 additions & 5 deletions src/app/_components/domains/Nippo/NippoEditor/NippoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@ import Placeholder from '@tiptap/extension-placeholder';
import StarterKit from '@tiptap/starter-kit';
import ListItem from '@tiptap/extension-list-item';
import Heading from '@tiptap/extension-heading';
import { format } from 'date-fns';
import { postNippo } from '~/app/_actions/nippoActions';
import { Nippo } from '~/domains/Nippo';
import { getCurrentDate } from '~/libs/getCurrentDate';
import { useDebounce } from '~/libs/useDebounce';

type Props = {
objectiveId: string;
nippo?: Nippo;
date: string;
};

export const NippoEditor: FC<Props> = ({ objectiveId, nippo }) => {
export const NippoEditor: FC<Props> = ({ objectiveId, nippo, date }) => {
const [inputText, setInputText] = useState<string>();
const debouncedInputText = useDebounce({ value: inputText, delay: 200 });

const handleEditorChange = useCallback(
async (body: string) => {
await postNippo({ objectiveId, date: nippo?.date || format(getCurrentDate(), 'yyyy-MM-dd'), body });
await postNippo({ objectiveId, date, body });
},
[nippo?.date, objectiveId],
[date, objectiveId],
);

useEffect(() => {
Expand Down

0 comments on commit b84f533

Please sign in to comment.