parent
d7af28d802
commit
9e5fa87a6a
3 changed files with 140 additions and 4 deletions
@ -0,0 +1,34 @@ |
||||
import React from 'react'; |
||||
import MaterialTable from 'material-table'; |
||||
|
||||
export interface Entry { |
||||
name: String |
||||
} |
||||
|
||||
export interface IProps { |
||||
artists: Entry[] |
||||
} |
||||
|
||||
export default function ArtistTable(props: IProps) { |
||||
const tableTitle = "Artists"; |
||||
const tableColumns = [ |
||||
{ title: "Name", field: 'name' }, |
||||
]; |
||||
const tableData = props.artists; |
||||
|
||||
const options = { |
||||
filtering: true, |
||||
paging: true, |
||||
pageSize: 100, |
||||
pageSizeOptions: [ 5, 10, 20, 50, 100 ] |
||||
}; |
||||
|
||||
return ( |
||||
<MaterialTable |
||||
title={tableTitle} |
||||
columns={tableColumns} |
||||
data={tableData} |
||||
options={options} |
||||
/> |
||||
); |
||||
} |
@ -0,0 +1,46 @@ |
||||
import React from 'react'; |
||||
import { Dialog, Grid, Typography, TextField, Button } from '@material-ui/core'; |
||||
|
||||
var cloneDeep = require('lodash/cloneDeep'); |
||||
|
||||
export interface ArtistProperties { |
||||
name: String, |
||||
} |
||||
|
||||
export interface IProps { |
||||
dialogOpen: boolean, |
||||
onClose?: () => void, |
||||
onChangeArtistProperties?: (props: ArtistProperties) => void, |
||||
artistProperties: ArtistProperties, |
||||
onSubmit?: () => void, |
||||
} |
||||
|
||||
export default function EditArtistDialog(props: IProps) { |
||||
const onNameChange = (name: String) => { |
||||
if (props.onChangeArtistProperties) { |
||||
const p = cloneDeep(props.artistProperties); |
||||
p.name = name; |
||||
props.onChangeArtistProperties(p); |
||||
} |
||||
}; |
||||
|
||||
return <Dialog |
||||
open={props.dialogOpen} |
||||
onClose={props.onClose} |
||||
> |
||||
<Typography variant='h6' gutterBottom> |
||||
Artist Details |
||||
</Typography> |
||||
<Grid container spacing={3}> |
||||
<Grid item xs={12}> |
||||
<TextField |
||||
label="Name" |
||||
value={props.artistProperties.name} |
||||
onChange={(i: any) => onNameChange(i.target.value)} |
||||
fullWidth |
||||
/> |
||||
</Grid> |
||||
</Grid> |
||||
<Button variant="contained" onClick={props.onSubmit}>Submit</Button> |
||||
</Dialog> |
||||
} |
Loading…
Reference in new issue