add channelentry comp
This commit is contained in:
parent
304077cce9
commit
64a84708d0
3 changed files with 32 additions and 6 deletions
21
src/components/Channel/ChannelEntry.tsx
Normal file
21
src/components/Channel/ChannelEntry.tsx
Normal 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;
|
|
@ -1,5 +1,6 @@
|
|||
import React, { Component } from 'react';
|
||||
import ChannelService from '../../services/ChannelService';
|
||||
import ChannelEntry from './ChannelEntry';
|
||||
|
||||
import './ChannelList.scss';
|
||||
|
||||
|
@ -24,12 +25,13 @@ export default class Channellist extends Component<any, any> {
|
|||
} else {
|
||||
return (
|
||||
<ul className='channelList'>
|
||||
{channels.map((e: Channel) => (
|
||||
<li key={e.id}>
|
||||
<span>#{e.id} </span>
|
||||
{e.name}
|
||||
</li>
|
||||
))}
|
||||
{channels.map((e: Channel) => {
|
||||
return (
|
||||
<li key={e.id}>
|
||||
<ChannelEntry channel={e} />
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
|
3
src/interfaces.d.ts
vendored
3
src/interfaces.d.ts
vendored
|
@ -6,6 +6,9 @@ interface Channel {
|
|||
subchannels: Channel[];
|
||||
}
|
||||
|
||||
interface ChannelEntryProps {
|
||||
channel: Channel;
|
||||
}
|
||||
interface ChannelViewProps {
|
||||
channel: Channel;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue