new feature: add task
This commit is contained in:
parent
070b437bab
commit
bfb4ae627f
7 changed files with 74 additions and 35 deletions
|
|
@ -5,6 +5,7 @@ import ReactMarkdown from "react-markdown";
|
|||
function DailyItem(props: any) {
|
||||
return (
|
||||
<div className="todo-item" id={props.id}>
|
||||
{console.log(props)}
|
||||
<input type="checkbox" className="checkbox" id={props.id} onChange={props.onChange} checked={props.completed} />
|
||||
<div className="todo-content">
|
||||
<p><Emoji text={props.daily_text}></Emoji></p>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
import * as React from "react";
|
||||
import DailyItem from "./DailyItem"
|
||||
import { Tab, Tabs, TabList, TabPanel } from "react-tabs";
|
||||
import { useTranslation, Trans, Translation } from 'react-i18next'
|
||||
import { useTranslation, Trans, Translation } from 'react-i18next';
|
||||
import { useForm, SubmitHandler } from "react-hook-form";
|
||||
import { addDaily } from "src/view/habiticaAPI";
|
||||
|
||||
type Inputs = {
|
||||
title: string
|
||||
};
|
||||
import AddTask from "../AddTask";
|
||||
|
||||
export default function Index(props: any){
|
||||
if(props.dailys == undefined) {
|
||||
|
|
@ -22,10 +18,6 @@ export default function Index(props: any){
|
|||
if(daily.completed)
|
||||
return <DailyItem key={daily.id} id={daily.id} daily_text={daily.text} daily_notes={daily.notes} onChange={props.onChange} completed={daily.completed}/>
|
||||
})
|
||||
const { register, handleSubmit, watch, formState: { errors } } = useForm<Inputs>();
|
||||
const onSubmit: SubmitHandler<Inputs> = data => {
|
||||
addDaily(this.props.plugin.settings.userID,this.props.plugin.settings.apiToken,data.title)
|
||||
}
|
||||
|
||||
const display = <div id="classDisplay">
|
||||
<Tabs>
|
||||
|
|
@ -33,10 +25,7 @@ export default function Index(props: any){
|
|||
<Tab><Trans>Active</Trans></Tab>
|
||||
<Tab><Trans>Completed</Trans></Tab>
|
||||
</TabList>
|
||||
<form className="add-task-input" onSubmit={handleSubmit(onSubmit)}>
|
||||
<input type="text" defaultValue="" {...register("title")}></input>
|
||||
<button className="submit-button" type="submit"><Trans>submit</Trans></button>
|
||||
</form>
|
||||
<AddTask type="daily"></AddTask>
|
||||
<TabPanel>
|
||||
<ul>{incompleteDailies}</ul>
|
||||
</TabPanel>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue