Skip to content

Commit

Permalink
move functions to helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
thewbuk committed Oct 12, 2024
1 parent 1235d62 commit 7b0266f
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/toolkit/src/view/catalog/components/lib/helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Catalog,
Nullable,
OrganizationSubscription,
OrganizationSubscriptionPlan,
Expand Down Expand Up @@ -325,3 +326,49 @@ export const validateFile = (

return { isValid: true, error: null };
};

export const getCatalogNameByUid = (
catalogUid: string | undefined,
catalogs: Catalog[]
): string => {
const catalog = catalogs.find((c) => c.catalogUid === catalogUid);
return catalog ? catalog.name : "Select";
};

export const getCatalogUidByName = (
catalogName: string,
catalogs: Catalog[] | undefined
): string | undefined => {
const catalog = catalogs?.find((catalog) => catalog.name === catalogName);
return catalog?.catalogUid;
};

export const getFileTypeByExtension = (extension: string) => {
switch (extension) {
case "txt":
return "FILE_TYPE_TEXT";
case "md":
case "markdown":
return "FILE_TYPE_MARKDOWN";
case "csv":
return "FILE_TYPE_CSV";
case "pdf":
return "FILE_TYPE_PDF";
case "docx":
return "FILE_TYPE_DOCX";
case "doc":
return "FILE_TYPE_DOC";
case "pptx":
return "FILE_TYPE_PPTX";
case "ppt":
return "FILE_TYPE_PPT";
case "html":
return "FILE_TYPE_HTML";
case "xls":
return "FILE_TYPE_XLS";
case "xlsx":
return "FILE_TYPE_XLSX";
default:
return "FILE_TYPE_UNSPECIFIED";
}
};

0 comments on commit 7b0266f

Please sign in to comment.