import { Button, Group } from '@mantine/core';
import { openModal, closeAllModals } from '@mantine/modals';
import {
RiSearch2Line,
RiSettings2Fill,
RiSettings2Line,
RiEdit2Line,
RiLockLine,
RiMenuFill,
} from 'react-icons/ri';
import { DropdownMenu, Text } from '/@/renderer/components';
import { ServerList } from '/@/renderer/features/servers';
import { EditServerForm } from '/@/renderer/features/servers/components/edit-server-form';
import { Settings } from '/@/renderer/features/settings';
import { useCurrentServer, useServerList, useAuthStoreActions } from '/@/renderer/store';
import { ServerListItem, ServerType } from '/@/renderer/types';
export const AppMenu = () => {
const currentServer = useCurrentServer();
const serverList = useServerList();
const { setCurrentServer } = useAuthStoreActions();
const handleSetCurrentServer = (server: ServerListItem) => {
setCurrentServer(server);
};
const handleCredentialsModal = (server: ServerListItem) => {
openModal({
children: server && (
),
size: 'sm',
title: `Update session for "${server.name}"`,
});
};
const handleManageServersModal = () => {
openModal({
children: ,
title: 'Manage Servers',
});
};
const handleSettingsModal = () => {
openModal({
children: ,
size: 'xl',
title: (
Settings
),
});
};
return (
Select a server
{serverList.map((s) => {
const isNavidromeExpired = s.type === ServerType.NAVIDROME && !s.ndCredential;
const isJellyfinExpired = false;
const isSessionExpired = isNavidromeExpired || isJellyfinExpired;
return (
)
}
onClick={() => {
if (!isSessionExpired) return handleSetCurrentServer(s);
return handleCredentialsModal(s);
}}
>
{s.name}
);
})}
}
>
Search
}
onClick={handleSettingsModal}
>
Settings
}
onClick={handleManageServersModal}
>
Manage servers
);
};