+
+
+
+
+
+
+ {tab === 'manual' ? (
+
+ ) : (
+
+ )}
+
+
+ {rowError && (
+
+
+ {rowError}
+
+ )}
+
+ {tab === 'manual' && (
+
+ {manual.length === 0 ? (
+ No manual collections yet.
+ ) : (
+ manual.map((collection, index) => (
+
+
+
+
+
setSelected(collection)} size="sm" title="Manage items" variant="ghost">
+
+
+
{
+ setDialogError(null);
+ setRenameTarget(collection);
+ }}
+ size="sm"
+ title="Rename"
+ variant="ghost"
+ >
+
+
+
setDeleteTarget({ item: collection, kind: 'manual' })}
+ size="sm"
+ title="Delete"
+ variant="ghost"
+ >
+
+
+
+ ))
+ )}
+
+ )}
+
+ {tab === 'smart' && (
+
+ {smart.length === 0 ? (
+ No smart collections yet.
+ ) : (
+ smart.map((collection, index) => (
+
+
+
+
{collection.name}
+
{collection.query}
+
+
{
+ setDialogError(null);
+ setSmartTarget({ collection, open: true });
+ }}
+ size="sm"
+ title="Edit"
+ variant="ghost"
+ >
+
+
+
setDeleteTarget({ item: collection, kind: 'smart' })}
+ size="sm"
+ title="Delete"
+ variant="ghost"
+ >
+
+
+
+ ))
+ )}
+
+ )}
+
+
+
+ {/* create manual */}
+
setCreateOpen(false)}
+ onSubmit={(name) => void runDialog(() => createCollection({ name }).then(() => undefined), () => setCreateOpen(false))}
+ open={createOpen}
+ title="New collection"
+ />
+
+ {/* rename manual */}
+ setRenameTarget(null)}
+ onSubmit={(name) =>
+ renameTarget &&
+ void runDialog(
+ () =>
+ updateCollection(renameTarget.id, {
+ name,
+ useCustomPlaybackOrder: renameTarget.useCustomPlaybackOrder
+ }).then(() => undefined),
+ () => setRenameTarget(null)
+ )
+ }
+ open={renameTarget !== null}
+ title="Rename collection"
+ />
+
+ {/* create / edit smart */}
+ setSmartTarget({ collection: null, open: false })}
+ onSubmit={(values) => {
+ const editing = smartTarget.collection;
+ void runDialog(
+ () =>
+ (editing
+ ? updateSmartCollection(editing.id, values)
+ : createSmartCollection(values)
+ ).then(() => undefined),
+ () => setSmartTarget({ collection: null, open: false })
+ );
+ }}
+ open={smartTarget.open}
+ />
+
+
+ {`Delete "${deleteTarget.item.name ?? 'this collection'}"? This cannot be undone.`}
+ {dialogError && (
+
+ {dialogError}
+
+ )}
+ >
+ ) : (
+ ''
+ )
+ }
+ onCancel={() => {
+ setDeleteTarget(null);
+ setDialogError(null);
+ }}
+ onConfirm={confirmDelete}
+ open={deleteTarget !== null}
+ title={deleteTarget?.kind === 'smart' ? 'Delete smart collection' : 'Delete collection'}
+ tone="danger"
+ />
+
+ );
+}
+
+function ClassicNote() {
+ return (
+