fix edit button

This commit is contained in:
kkzzhizhou 2021-11-25 22:30:58 +08:00
parent 0416a4de8c
commit 876fe85f08
5 changed files with 43 additions and 23 deletions

View file

@ -167,6 +167,11 @@ class App extends React.Component<any, any> {
} }
} }
async sendEditTask(id: string, type: string) {
console.log(id, type)
return (<div className="loading">Loading....</div>)
}
handleChangeTodos(event: any) { handleChangeTodos(event: any) {
if (event.target.id == "add-todo") { if (event.target.id == "add-todo") {
const title = event.target.name const title = event.target.name
@ -200,11 +205,12 @@ class App extends React.Component<any, any> {
this.state.tasks.dailys.forEach((element: any) => { this.state.tasks.dailys.forEach((element: any) => {
if (element.id == event.target.id) { if (element.id == event.target.id) {
if (element.id == event.target.id) { if (element.id == event.target.id) {
if (!element.completed && event.target.innerText != 'clear') { if ( event.target.innerText == 'create' ) {
this.sendScore(event.target.id, "up", "Checked!") this.sendEditTask(event.target.id, "daily")
} } else if (event.target.innerText == 'clear') {
else if (event.target.innerText == 'clear') {
this.sendDeleteTask(event.target.id, "Deleted!") this.sendDeleteTask(event.target.id, "Deleted!")
} else if ( !element.completed) {
this.sendScore(event.target.id, "up", "Checked!")
} else { } else {
this.sendScore(event.target.id, "down", "Un-Checked!") this.sendScore(event.target.id, "down", "Un-Checked!")
} }
@ -242,6 +248,7 @@ class App extends React.Component<any, any> {
} }
handleChangeRewards(event: any) { handleChangeRewards(event: any) {
console.log(event)
if (event.target.id == "add-reward") { if (event.target.id == "add-reward") {
const title = event.target.name const title = event.target.name
this.sendAddTask("reward", title, "Add!") this.sendAddTask("reward", title, "Add!")
@ -251,8 +258,9 @@ class App extends React.Component<any, any> {
if (element.id == target_id) { if (element.id == target_id) {
if (event.target.innerText == 'clear') { if (event.target.innerText == 'clear') {
this.sendDeleteTask(event.target.id, "Deleted!") this.sendDeleteTask(event.target.id, "Deleted!")
} } else if (event.target.innerText == 'create') {
else { this.sendEditTask(event.target.id, "Edit!")
} else {
this.sendReward(target_id, "down", "Cost!") this.sendReward(target_id, "down", "Cost!")
} }
} }

View file

@ -1,5 +1,5 @@
import * as React from 'react'; import * as React from 'react';
import { useTranslation, Trans, Translation } from 'react-i18next' import { useTranslation } from 'react-i18next'
export default function Index(props: any) { export default function Index(props: any) {
let { t ,i18n} = useTranslation() let { t ,i18n} = useTranslation()
@ -7,9 +7,9 @@ export default function Index(props: any) {
<div className="stats"> <div className="stats">
{/* <div id="profile-name">{props.user_data.profile.name}</div> */} {/* <div id="profile-name">{props.user_data.profile.name}</div> */}
{/* {console.log(props)} */} {/* {console.log(props)} */}
<div className = "substats" id="hp"><i className="material-icons">favorite</i>{t('HP')}: {(props.user_data.stats.hp).toPrecision(2)}</div> <div className = "substats" id="hp"><i className="material-icons">favorite</i>{t('HP')}: {(props.user_data.stats.hp).toPrecision(3)}</div>
<div className = "substats" id="lvl"><i className="material-icons">star</i>{t('LEVEL')}: {props.user_data.stats.lvl}</div> <div className = "substats" id="lvl"><i className="material-icons">star</i>{t('LEVEL')}: {props.user_data.stats.lvl}</div>
<div className = "substats" id="gold"><i className="material-icons">credit_card</i>{t('GOLD')}: {(props.user_data.stats.gp).toPrecision(2)}</div> <div className = "substats" id="gold"><i className="material-icons">credit_card</i>{t('GOLD')}: {(props.user_data.stats.gp).toPrecision(3)}</div>
</div> </div>
); );
} }

View file

@ -0,0 +1,25 @@
import Emoji from "react-emoji-render";
import * as React from "react";
import ReactMarkdown from "react-markdown";
function EditDailyItem(props: any) {
return (
<div className="edit-todo-item" id={props.id}>
<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>
<ReactMarkdown children={props.daily_notes} />
</div>
<button className="task-operation" >
<span className="material-icons md-24" id={props.id} onClick={props.onChange}>create</span>
</button>
<button className="task-operation">
<span className="material-icons md-24" id={props.id} onClick={props.onChange}>clear</span>
</button>
</div>
)
}
export default EditDailyItem

View file

@ -1,5 +1,6 @@
import * as React from "react"; import * as React from "react";
import DailyItem from "./DailyItem" import DailyItem from "./DailyItem"
import EditDailyItem from "./EditDailyItem"
import { Tab, Tabs, TabList, TabPanel } from "react-tabs"; import { Tab, Tabs, TabList, TabPanel } from "react-tabs";
import { Trans } from 'react-i18next'; import { Trans } from 'react-i18next';
@ -24,7 +25,6 @@ export default function Index(props: any) {
return <DailyItem key={daily.id} id={daily.id} daily_text={daily.text} daily_notes={daily.notes} onChange={props.onChange} completed={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 display = <div id="classDisplay"> const display = <div id="classDisplay">
<Tabs> <Tabs>
<TabList> <TabList>

View file

@ -1,13 +0,0 @@
import { Emoji } from 'react-emoji-render';
import * as React from "react";
function TodoItem(props: any) {
return (
<div className="todo-item" id={props.id}>
<input type="checkbox" className="checkbox" id={props.id} onChange={props.onChange} checked={props.completed}/>
<Emoji text = {props.todo_text}></Emoji><Emoji text = {props.todo_text}></Emoji>
</div>
)
}
export default TodoItem