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 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) => {
|
||||||
<li key={e.id}>
|
return (
|
||||||
<span>#{e.id} </span>
|
<li key={e.id}>
|
||||||
{e.name}
|
<ChannelEntry channel={e} />
|
||||||
</li>
|
</li>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
3
src/interfaces.d.ts
vendored
3
src/interfaces.d.ts
vendored
|
@ -6,6 +6,9 @@ interface Channel {
|
||||||
subchannels: Channel[];
|
subchannels: Channel[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ChannelEntryProps {
|
||||||
|
channel: Channel;
|
||||||
|
}
|
||||||
interface ChannelViewProps {
|
interface ChannelViewProps {
|
||||||
channel: Channel;
|
channel: Channel;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue