refactor: split ExpandItem from Mainpage

mgy
Dawn_Ocean 2024-04-08 15:55:01 +08:00
parent 4d6eca0434
commit 097f6832e3
4 changed files with 35 additions and 29 deletions

View File

@ -0,0 +1,3 @@
export default {
component: true,
};

View File

@ -0,0 +1,31 @@
import { View } from '@tarojs/components';
import { Component, ReactNode } from 'react';
import { AtAccordion } from 'taro-ui';
export class ExpandItem extends Component {
state = {
open: false,
};
props = {
title: '',
content: <View></View>,
};
handleClick(value: boolean) {
this.setState({ open: value });
}
render(): ReactNode {
return (
<View>
<AtAccordion
open={this.state.open}
onClick={this.handleClick.bind(this)}
title={this.props.title}
>
{this.props.content}
</AtAccordion>
</View>
);
}
}

View File

@ -3,7 +3,6 @@ import { Component, ReactNode } from 'react';
import Taro from '@tarojs/taro';
import {
AtCard,
AtAccordion,
AtInputNumber,
AtButton,
AtList,
@ -23,6 +22,7 @@ import { getMemberDutyInfo } from '@/service/memberDutyInfo';
import { getUncompletedTicketList } from '@/service/uncompletedTicket';
import { changeDutyCnt } from '@/service/changeDutyCount';
import { TicketListItem } from '@/components/TicketListItem/TicketListItem';
import { ExpandItem } from '@/components/ExpandItem/ExpandItem';
import './index.scss';
import TitleCard from './TitleCard';
import { DutyInfo, DutyData } from './DutyInfo';
@ -47,34 +47,6 @@ function mainPageCard(c: CardContent): JSX.Element {
);
}
class ExpandItem extends Component {
state = {
open: false,
};
props = {
title: '',
content: <View></View>,
};
handleClick(value: boolean) {
this.setState({ open: value });
}
render(): ReactNode {
return (
<View>
<AtAccordion
open={this.state.open}
onClick={this.handleClick.bind(this)}
title={this.props.title}
>
{this.props.content}
</AtAccordion>
</View>
);
}
}
interface MainPageState {
fixList: Array<TicketListItem>;
rs: RequestState;