Files
InvokeAI/invokeai/frontend/web/src/services/api/hooks/useBoardName.ts
Mary Hipp d6add93901 lint
2024-10-11 17:23:34 -04:00

20 lines
571 B
TypeScript

import type { BoardId } from 'features/gallery/store/types';
import { t } from 'i18next';
import { useListAllBoardsQuery } from 'services/api/endpoints/boards';
export const useBoardName = (board_id: BoardId) => {
const { boardName } = useListAllBoardsQuery(
{ include_archived: true },
{
selectFromResult: ({ data }) => {
const selectedBoard = data?.find((b) => b.board_id === board_id);
const boardName = selectedBoard?.board_name || t('boards.uncategorized');
return { boardName };
},
}
);
return boardName;
};