Handle jellyfin playlist creation
This commit is contained in:
parent
8b04f70106
commit
b037329377
2 changed files with 27 additions and 21 deletions
|
@ -436,6 +436,7 @@ const createPlaylist = async (args: CreatePlaylistArgs): Promise<CreatePlaylistR
|
||||||
const body = {
|
const body = {
|
||||||
MediaType: 'Audio',
|
MediaType: 'Audio',
|
||||||
Name: query.name,
|
Name: query.name,
|
||||||
|
Overview: query.comment || '',
|
||||||
UserId: server?.userId,
|
UserId: server?.userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { Group, Stack } from '@mantine/core';
|
import { Group, Stack } from '@mantine/core';
|
||||||
import { useForm } from '@mantine/form';
|
import { useForm } from '@mantine/form';
|
||||||
import { CreatePlaylistQuery } from '/@/renderer/api/types';
|
import { CreatePlaylistQuery, ServerType } from '/@/renderer/api/types';
|
||||||
import { Button, Switch, TextInput, toast } from '/@/renderer/components';
|
import { Button, Switch, TextInput, toast } from '/@/renderer/components';
|
||||||
import { useCreatePlaylist } from '/@/renderer/features/playlists/mutations/create-playlist-mutation';
|
import { useCreatePlaylist } from '/@/renderer/features/playlists/mutations/create-playlist-mutation';
|
||||||
|
import { useCurrentServer } from '/@/renderer/store';
|
||||||
|
|
||||||
interface CreatePlaylistFormProps {
|
interface CreatePlaylistFormProps {
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
|
@ -10,6 +11,7 @@ interface CreatePlaylistFormProps {
|
||||||
|
|
||||||
export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
|
export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
|
||||||
const mutation = useCreatePlaylist();
|
const mutation = useCreatePlaylist();
|
||||||
|
const server = useCurrentServer();
|
||||||
|
|
||||||
const form = useForm<CreatePlaylistQuery>({
|
const form = useForm<CreatePlaylistQuery>({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
|
@ -35,6 +37,7 @@ export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isPublicDisplayed = server?.type === ServerType.NAVIDROME;
|
||||||
const isSubmitDisabled = !form.values.name || mutation.isLoading;
|
const isSubmitDisabled = !form.values.name || mutation.isLoading;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -50,27 +53,29 @@ export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
|
||||||
label="Description"
|
label="Description"
|
||||||
{...form.getInputProps('comment')}
|
{...form.getInputProps('comment')}
|
||||||
/>
|
/>
|
||||||
<Switch
|
{isPublicDisplayed && (
|
||||||
label="Is Public?"
|
<Switch
|
||||||
{...form.getInputProps('public')}
|
label="Is Public?"
|
||||||
/>
|
{...form.getInputProps('public')}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Group position="right">
|
||||||
|
<Button
|
||||||
|
variant="subtle"
|
||||||
|
onClick={onCancel}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
disabled={isSubmitDisabled}
|
||||||
|
loading={mutation.isLoading}
|
||||||
|
type="submit"
|
||||||
|
variant="filled"
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Group position="right">
|
|
||||||
<Button
|
|
||||||
variant="subtle"
|
|
||||||
onClick={onCancel}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
disabled={isSubmitDisabled}
|
|
||||||
loading={mutation.isLoading}
|
|
||||||
type="submit"
|
|
||||||
variant="filled"
|
|
||||||
>
|
|
||||||
Save
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue