8877b1695a
* add internet radio support * Add dynamic sidebar icon to Radios * Fix typos * Make URL suffix consistent * Fix typo * address feedback * Don't need to preload when playing Internet Radios * Reorder migration, or else it won't be applied * Make Radio list view responsive Also added filter by name, removed RadioActions and RadioContextMenu, and added a default radio icon, in case of favicon is not available. * Simplify StreamField usage * fix button, hide progress on mobile * use js styles over index.css Co-authored-by: Deluan <deluan@navidrome.org>
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
import React, { useCallback } from 'react'
|
|
import {
|
|
Create,
|
|
required,
|
|
SimpleForm,
|
|
TextInput,
|
|
useMutation,
|
|
useNotify,
|
|
useRedirect,
|
|
useTranslate,
|
|
} from 'react-admin'
|
|
import { Title } from '../common'
|
|
|
|
const RadioCreate = (props) => {
|
|
const translate = useTranslate()
|
|
const [mutate] = useMutation()
|
|
const notify = useNotify()
|
|
const redirect = useRedirect()
|
|
|
|
const resourceName = translate('resources.radio.name', { smart_count: 1 })
|
|
const title = translate('ra.page.create', {
|
|
name: `${resourceName}`,
|
|
})
|
|
|
|
const save = useCallback(
|
|
async (values) => {
|
|
try {
|
|
await mutate(
|
|
{
|
|
type: 'create',
|
|
resource: 'radio',
|
|
payload: { data: values },
|
|
},
|
|
{ returnPromise: true }
|
|
)
|
|
notify('resources.radio.notifications.created', 'info', {
|
|
smart_count: 1,
|
|
})
|
|
redirect('/radio')
|
|
} catch (error) {
|
|
if (error.body.errors) {
|
|
return error.body.errors
|
|
}
|
|
}
|
|
},
|
|
[mutate, notify, redirect]
|
|
)
|
|
|
|
return (
|
|
<Create title={<Title subTitle={title} />} {...props}>
|
|
<SimpleForm save={save} variant={'outlined'}>
|
|
<TextInput source="name" validate={[required()]} />
|
|
<TextInput type="url" source="streamUrl" validate={[required()]} />
|
|
<TextInput type="url" source="homepageUrl" />
|
|
</SimpleForm>
|
|
</Create>
|
|
)
|
|
}
|
|
|
|
export default RadioCreate
|