2018-06-11新增Modal寫API

index.jpg

點(diǎn)擊+號打開Modal、

import React from "react"
import { connect } from "utils"
import { Button, ButtonGroup, Input, Select } from "components/controls"
import { Intent, Modal } from "components"

interface Props {
  title: string
  processing?: boolean
  error?: string
  onClose(): void
}

interface State {
  name: string
  error: string
}

type P = WithStyles & Props

const styles = {
  inputContainer: {
    boxSizing: "border-box",
    width: 487,
    padding: "10px 25px",
  },
  btnContainer: {
    padding: "20px 25px",
    display: "flex",
    justifyContent: "flex-end",
  },
}

class EditModal extends React.Component<P, State> {
  constructor(props: P) {
    super(props)
    this.handleChange = this.handleChange.bind(this)
    this.handleSave = this.handleSave.bind(this)
    this.state = {
      name: "",
      error: null,
    }
  }
  handleChange(name: string) {
    this.setState({ name })
  }
  async handleSave() {
    this.props.onClose()
  }
  render() {
    const { classes, onClose, title, error, processing } = this.props
    const { name } = this.state
    return (
      <Modal open onClose={onClose} title={title}>
        <div className={classes.inputContainer}>
          <Input
            placeholder="Section Name"
            value={name}
            validMsg={error}
            onChange={this.handleChange}
            label="Section Name"
          />
        </div>
        <div className={classes.inputContainer}>
          <Select
            value={name}
            onChange={this.handleChange}
            label="Available Days"
          >
          <option>Every day in the week</option>
          <option>Every Sunday</option>
          </Select>
        </div>
        <div className={classes.inputContainer}>
          <Select
            value={name}
            onChange={this.handleChange}
            label="Time Available From"
          >
          <option>Every day in the week</option>
          <option>Every Sunday</option>
          </Select>
        </div>
        <div className={classes.inputContainer}>
          <Select
            value={name}
            onChange={this.handleChange}
            label="Time Available To"
          >
          <option>Every day in the week</option>
          <option>Every Sunday</option>
          </Select>
        </div>
        <div className={classes.btnContainer}>
          <ButtonGroup>
            <Button onClick={onClose}>CANCEL</Button>
            <Button intent={Intent.PRIMARY} onClick={this.handleSave} processing={processing}>
              SAVE
            </Button>
          </ButtonGroup>
        </div>
      </Modal>
    )
  }
}

export default connect(EditModal, { styles })

api-client

yarn test  
yarn install

01 打開查看列表 GET
v2/stores/4934/favorite_tabs?page=1&per_page=9999


GET

02 新增一項(xiàng) POST
v2/stores/4934/favorite_tabs


POST

03 修改PUT
v2/stores/4934/favorite_tabs/75557

04 DELETE

021 查看subsection
v2/stores/4934/favorite_tabs/75557/favorite_sections?with_details=true


subsection

022新增subsection POST
v2/stores/4934/favorite_tabs/75557/favorite_sections

favorite_section:
{
id: 75565,
 name: "you1650", 
position: 2, 
favorite_tab_id: 75557, 
store_id: 4934,
updated_at: "2018-06-11T04:50:07-0400"
}

023編輯 PUT
v2/stores/4934/favorite_tabs/75557/favorite_sections/74714

024 DELETE

031 新增ITEM
v2/stores/4934/favorites
v2/stores/4934/favorite_tabs
v2/stores/4934/favorite_tabs/75557/favorite_sections

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容