Co-authored-by: Anubhav Singh <anubhav@mail.techindika.com>
This commit is contained in:
parent
44df17aecc
commit
194a49367c
1 changed files with 2 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { Checkbox } from "@usememos/mui";
|
import { Checkbox } from "@usememos/mui";
|
||||||
import { useContext, useState } from "react";
|
import { useContext } from "react";
|
||||||
import { markdownServiceClient } from "@/grpcweb";
|
import { markdownServiceClient } from "@/grpcweb";
|
||||||
import { useMemoStore } from "@/store/v1";
|
import { useMemoStore } from "@/store/v1";
|
||||||
import { Node, TaskListItemNode } from "@/types/proto/api/v1/markdown_service";
|
import { Node, TaskListItemNode } from "@/types/proto/api/v1/markdown_service";
|
||||||
|
|
@ -19,7 +19,6 @@ interface Props {
|
||||||
const TaskListItem: React.FC<Props> = ({ node, complete, children }: Props) => {
|
const TaskListItem: React.FC<Props> = ({ node, complete, children }: Props) => {
|
||||||
const context = useContext(RendererContext);
|
const context = useContext(RendererContext);
|
||||||
const memoStore = useMemoStore();
|
const memoStore = useMemoStore();
|
||||||
const [checked, setChecked] = useState(complete);
|
|
||||||
|
|
||||||
const handleCheckboxChange = async (on: boolean) => {
|
const handleCheckboxChange = async (on: boolean) => {
|
||||||
if (context.readonly || !context.memoName) {
|
if (context.readonly || !context.memoName) {
|
||||||
|
|
@ -35,13 +34,12 @@ const TaskListItem: React.FC<Props> = ({ node, complete, children }: Props) => {
|
||||||
},
|
},
|
||||||
["content"],
|
["content"],
|
||||||
);
|
);
|
||||||
setChecked(on);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className={cn("w-full grid grid-cols-[24px_1fr]")}>
|
<li className={cn("w-full grid grid-cols-[24px_1fr]")}>
|
||||||
<span className="w-6 h-6 flex justify-start items-center">
|
<span className="w-6 h-6 flex justify-start items-center">
|
||||||
<Checkbox size="sm" checked={checked} disabled={context.readonly} onChange={(e) => handleCheckboxChange(e.target.checked)} />
|
<Checkbox size="sm" checked={complete} disabled={context.readonly} onChange={(e) => handleCheckboxChange(e.target.checked)} />
|
||||||
</span>
|
</span>
|
||||||
<p className={cn(complete && "line-through opacity-80")}>
|
<p className={cn(complete && "line-through opacity-80")}>
|
||||||
{children.map((child, index) => (
|
{children.map((child, index) => (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue