Handle jellyfin playlist creation

This commit is contained in:
jeffvli 2023-01-01 14:02:03 -08:00
parent 8b04f70106
commit b037329377
2 changed files with 27 additions and 21 deletions

View file

@ -436,6 +436,7 @@ const createPlaylist = async (args: CreatePlaylistArgs): Promise<CreatePlaylistR
const body = {
MediaType: 'Audio',
Name: query.name,
Overview: query.comment || '',
UserId: server?.userId,
};

View file

@ -1,8 +1,9 @@
import { Group, Stack } from '@mantine/core';
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 { useCreatePlaylist } from '/@/renderer/features/playlists/mutations/create-playlist-mutation';
import { useCurrentServer } from '/@/renderer/store';
interface CreatePlaylistFormProps {
onCancel: () => void;
@ -10,6 +11,7 @@ interface CreatePlaylistFormProps {
export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
const mutation = useCreatePlaylist();
const server = useCurrentServer();
const form = useForm<CreatePlaylistQuery>({
initialValues: {
@ -35,6 +37,7 @@ export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
);
});
const isPublicDisplayed = server?.type === ServerType.NAVIDROME;
const isSubmitDisabled = !form.values.name || mutation.isLoading;
return (
@ -50,27 +53,29 @@ export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
label="Description"
{...form.getInputProps('comment')}
/>
<Switch
label="Is Public?"
{...form.getInputProps('public')}
/>
{isPublicDisplayed && (
<Switch
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>
<Group position="right">
<Button
variant="subtle"
onClick={onCancel}
>
Cancel
</Button>
<Button
disabled={isSubmitDisabled}
loading={mutation.isLoading}
type="submit"
variant="filled"
>
Save
</Button>
</Group>
</form>
);
};