add channelentry comp

This commit is contained in:
Niel 2019-04-17 23:39:50 +02:00
parent 304077cce9
commit 64a84708d0
3 changed files with 32 additions and 6 deletions

View file

@ -0,0 +1,21 @@
import React, { Component } from 'react';
class ChannelEntry extends Component<ChannelEntryProps> {
render() {
const { name, subchannels } = this.props.channel;
return (
<>
<div>{name}</div>
{subchannels !== undefined && (
<ul>
{subchannels.map(e => {
return <li key={e.id}>{e.name}</li>;
})}
</ul>
)}
</>
);
}
}
export default ChannelEntry;

View file

@ -1,5 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import ChannelService from '../../services/ChannelService'; import ChannelService from '../../services/ChannelService';
import ChannelEntry from './ChannelEntry';
import './ChannelList.scss'; import './ChannelList.scss';
@ -24,12 +25,13 @@ export default class Channellist extends Component<any, any> {
} else { } else {
return ( return (
<ul className='channelList'> <ul className='channelList'>
{channels.map((e: Channel) => ( {channels.map((e: Channel) => {
return (
<li key={e.id}> <li key={e.id}>
<span>#{e.id} </span> <ChannelEntry channel={e} />
{e.name}
</li> </li>
))} );
})}
</ul> </ul>
); );
} }

3
src/interfaces.d.ts vendored
View file

@ -6,6 +6,9 @@ interface Channel {
subchannels: Channel[]; subchannels: Channel[];
} }
interface ChannelEntryProps {
channel: Channel;
}
interface ChannelViewProps { interface ChannelViewProps {
channel: Channel; channel: Channel;
} }