[WEB-3482] refactor: platform components and mobx stores (#6713)

* improvement: platform componenents and mobx stores

* minor improvements
This commit is contained in:
Prateek Shourya 2025-03-06 15:47:46 +05:30 committed by GitHub
parent 4958be7898
commit 6d216f2607
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 375 additions and 102 deletions

View file

@ -5,3 +5,37 @@ import { twMerge } from "tailwind-merge";
export const getSupportEmail = (defaultEmail: string = ""): string => defaultEmail;
export const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs));
/**
* Extracts IDs from an array of objects with ID property
*/
export const extractIds = <T extends { id: string }>(items: T[]): string[] => items.map((item) => item.id);
/**
* Checks if an ID exists and is valid within the provided list
*/
export const isValidId = (id: string | null | undefined, validIds: string[]): boolean => !!id && validIds.includes(id);
/**
* Filters an array to only include valid IDs
*/
export const filterValidIds = (ids: string[], validIds: string[]): string[] =>
ids.filter((id) => validIds.includes(id));
/**
* Filters an array to include only valid IDs, returning both valid and invalid IDs
*/
export const partitionValidIds = (ids: string[], validIds: string[]): { valid: string[]; invalid: string[] } => {
const valid: string[] = [];
const invalid: string[] = [];
ids.forEach((id) => {
if (validIds.includes(id)) {
valid.push(id);
} else {
invalid.push(id);
}
});
return { valid, invalid };
};

View file

@ -11,3 +11,4 @@ export * from "./state";
export * from "./string";
export * from "./theme";
export * from "./workspace";
export * from "./work-item";

View file

@ -0,0 +1 @@
export * from "./modal";

View file

@ -0,0 +1,33 @@
// plane imports
import { DEFAULT_WORK_ITEM_FORM_VALUES } from "@plane/constants";
import { IPartialProject, ISearchIssueResponse, IState, TIssue } from "@plane/types";
export const getUpdateFormDataForReset = (projectId: string | null | undefined, formData: Partial<TIssue>) => ({
...DEFAULT_WORK_ITEM_FORM_VALUES,
project_id: projectId,
name: formData.name,
description_html: formData.description_html,
priority: formData.priority,
start_date: formData.start_date,
target_date: formData.target_date,
});
export const convertWorkItemDataToSearchResponse = (
workspaceSlug: string,
workItem: TIssue,
project: IPartialProject | undefined,
state: IState | undefined
): ISearchIssueResponse => ({
id: workItem.id,
name: workItem.name,
project_id: workItem.project_id ?? "",
project__identifier: project?.identifier ?? "",
project__name: project?.name ?? "",
sequence_id: workItem.sequence_id,
type_id: workItem.type_id ?? "",
state__color: state?.color ?? "",
start_date: workItem.start_date,
state__group: state?.group ?? "backlog",
state__name: state?.name ?? "",
workspace__slug: workspaceSlug,
});