From 070b437bab95e3440444df252474f15b210fa143 Mon Sep 17 00:00:00 2001 From: kkzzhizhou <806508401@qq.com> Date: Mon, 22 Nov 2021 23:05:12 +0800 Subject: [PATCH] add task function --- src/view/Components/Statsview/index.tsx | 6 ++--- .../Components/Taskview/Addview/index.tsx | 27 ------------------- .../Components/Taskview/Dailiesview/index.tsx | 20 ++++++++++---- src/view/Components/Taskview/index.tsx | 1 - src/view/habiticaAPI.ts | 16 +++++++++++ styles.css | 14 +++++++++- 6 files changed, 47 insertions(+), 37 deletions(-) delete mode 100644 src/view/Components/Taskview/Addview/index.tsx diff --git a/src/view/Components/Statsview/index.tsx b/src/view/Components/Statsview/index.tsx index 8335466..738ab51 100644 --- a/src/view/Components/Statsview/index.tsx +++ b/src/view/Components/Statsview/index.tsx @@ -7,9 +7,9 @@ export default function Index(props: any) {
{/*
{props.user_data.profile.name}
*/} {console.log(props)} -
{t('HP')}: {(props.user_data.stats.hp).toPrecision(3)}
-
{t('LEVEL')}: {props.user_data.stats.lvl}
-
{t('GOLD')}: {(props.user_data.stats.gp).toPrecision(3)}
+
favorite{t('HP')}: {(props.user_data.stats.hp).toPrecision(2)}
+
star{t('LEVEL')}: {props.user_data.stats.lvl}
+
credit_card{t('GOLD')}: {(props.user_data.stats.gp).toPrecision(2)}
); } \ No newline at end of file diff --git a/src/view/Components/Taskview/Addview/index.tsx b/src/view/Components/Taskview/Addview/index.tsx deleted file mode 100644 index ec59339..0000000 --- a/src/view/Components/Taskview/Addview/index.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import * as React from "react"; -import { useForm } from "react-hook-form"; -import { Trans,useTranslation } from 'react-i18next' - -export default function Index(props: any) { - - const display =
-
- - - -
-
- - return (display); -} \ No newline at end of file diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index 08d8c5d..0a885e9 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -2,6 +2,12 @@ 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 { useForm, SubmitHandler } from "react-hook-form"; +import { addDaily } from "src/view/habiticaAPI"; + +type Inputs = { + title: string +}; export default function Index(props: any){ if(props.dailys == undefined) { @@ -16,17 +22,21 @@ export default function Index(props: any){ if(daily.completed) return }) + const { register, handleSubmit, watch, formState: { errors } } = useForm(); + const onSubmit: SubmitHandler = data => { + addDaily(this.props.plugin.settings.userID,this.props.plugin.settings.apiToken,data.title) + } + const display =
Active Completed -
- - - -
+
+ + +
    {incompleteDailies}
diff --git a/src/view/Components/Taskview/index.tsx b/src/view/Components/Taskview/index.tsx index 480b2f6..45146cc 100644 --- a/src/view/Components/Taskview/index.tsx +++ b/src/view/Components/Taskview/index.tsx @@ -3,7 +3,6 @@ import Dailiesview from "./Dailiesview" import Habitsview from "./Habitsview" import Todoview from "./Todoview" import Rewardview from "./Rewardview" -import Addview from "./Addview" import { Tab, Tabs, TabList, TabPanel } from "react-tabs"; import { useTranslation, Trans, Translation } from 'react-i18next' diff --git a/src/view/habiticaAPI.ts b/src/view/habiticaAPI.ts index 478211b..bc12f73 100644 --- a/src/view/habiticaAPI.ts +++ b/src/view/habiticaAPI.ts @@ -54,3 +54,19 @@ export async function costReward(username: string, credentials: string, taskID: }) return(response) } + + +export async function addDaily(username: string, credentials: string, title: string) { + const url = "https://habitica.com/api/v4/tasks/user".concat(title) + const response = fetch(url, { + method: 'POST', + headers: { + "Content-Type": "application/json", + "x-client": "278e719e-5f9c-43b1-9dba-8b73343dc062-HabiticaSync", + "x-api-user": username, + "x-api-key": credentials, + }, + body: JSON.stringify({type: "daliy", text: title}) + }) + return(response) +} \ No newline at end of file diff --git a/styles.css b/styles.css index e99e114..7c097ab 100644 --- a/styles.css +++ b/styles.css @@ -16,6 +16,14 @@ justify-content: space-between; } +.modify-todo { + align-self: center; +} + +.delete-todo { + align-self: center; +} + .todo-item { display: grid; grid-template-columns: 1fr 30fr 1fr 1fr; @@ -31,6 +39,7 @@ p { margin: 0; + padding: 5px; } .reward-item { @@ -105,6 +114,7 @@ input[type=checkbox] { padding: 5px 15px; font-size: 15px; border: 1px solid #aaa; + white-space: nowrap; } input[type=checkbox]:focus { @@ -216,7 +226,9 @@ ul li:not(.task-list-item)::before { body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed > div.horizontal-main-container > div > div.workspace-split.mod-horizontal.mod-right-split > div.workspace-tabs > div.workspace-leaf > div > div.view-content > div > div.cron > button { margin: auto; margin-bottom: 5px; - white-space: nowrap + white-space: nowrap; + padding: 5px 5px; + margin-right: 0; } .cron { display: inline-grid;