1 import { useFolders } from '@proton/mail';
2 import { useMailSettings } from '@proton/mail/mailSettings/hooks';
3 import { toMap } from '@proton/shared/lib/helpers/object';
4 import type { Folder } from '@proton/shared/lib/interfaces/Folder';
6 const useFolderColor = (folder: Folder) => {
7 const [folders] = useFolders();
8 const [mailSettings] = useMailSettings();
10 if (!mailSettings?.EnableFolderColor) {
14 if (!mailSettings?.InheritParentFolderColor) {
18 const folderMap = toMap(folders);
20 const getParentFolderColor = ({ ParentID, Color }: Folder): string | undefined => {
21 // ParentID is undefined for root folder
26 const folder = folderMap[ParentID];
29 return getParentFolderColor(folder);
35 return getParentFolderColor(folder);
38 export default useFolderColor;