fix some build errors due to type changes

This commit is contained in:
rahulramesha 2024-03-08 18:21:28 +05:30
parent 026bc9318f
commit 63b850f92f
36 changed files with 180 additions and 166 deletions

View File

@ -24,7 +24,7 @@ export type TBaseIssue = {
project_id: string | null; project_id: string | null;
parent_id: string | null; parent_id: string | null;
cycle_id: string | null; cycle_id: string | null;
module_ids: string[]; module_ids: string[] | null;
created_at: string; created_at: string;
updated_at: string; updated_at: string;

View File

@ -7,7 +7,7 @@ type TIssuePriorities = "urgent" | "high" | "medium" | "low" | "none";
interface IPriorityIcon { interface IPriorityIcon {
className?: string; className?: string;
containerClassName?: string; containerClassName?: string;
priority: TIssuePriorities; priority: TIssuePriorities | undefined | null;
size?: number; size?: number;
withContainer?: boolean; withContainer?: boolean;
} }
@ -31,7 +31,7 @@ export const PriorityIcon: React.FC<IPriorityIcon> = (props) => {
low: SignalLow, low: SignalLow,
none: Ban, none: Ban,
}; };
const Icon = icons[priority]; const Icon = icons[priority ?? "none"];
if (!Icon) return null; if (!Icon) return null;
@ -41,7 +41,7 @@ export const PriorityIcon: React.FC<IPriorityIcon> = (props) => {
<div <div
className={cn( className={cn(
"grid place-items-center border rounded p-0.5 flex-shrink-0", "grid place-items-center border rounded p-0.5 flex-shrink-0",
priorityClasses[priority], priorityClasses[priority ?? "none"],
containerClassName containerClassName
)} )}
> >

View File

@ -25,7 +25,7 @@ export const AssignedUpcomingIssueListItem: React.FC<IssueListItemProps> = obser
// derived values // derived values
const issueDetails = getIssueById(issueId) as TWidgetIssue | undefined; const issueDetails = getIssueById(issueId) as TWidgetIssue | undefined;
if (!issueDetails) return null; if (!issueDetails || !issueDetails.project_id) return null;
const projectDetails = getProjectById(issueDetails.project_id); const projectDetails = getProjectById(issueDetails.project_id);
@ -75,7 +75,7 @@ export const AssignedOverdueIssueListItem: React.FC<IssueListItemProps> = observ
// derived values // derived values
const issueDetails = getIssueById(issueId) as TWidgetIssue | undefined; const issueDetails = getIssueById(issueId) as TWidgetIssue | undefined;
if (!issueDetails) return null; if (!issueDetails || !issueDetails.project_id) return null;
const projectDetails = getProjectById(issueDetails.project_id); const projectDetails = getProjectById(issueDetails.project_id);
const blockedByIssues = issueDetails.issue_relation?.filter((issue) => issue.relation_type === "blocked_by") ?? []; const blockedByIssues = issueDetails.issue_relation?.filter((issue) => issue.relation_type === "blocked_by") ?? [];
@ -122,7 +122,7 @@ export const AssignedCompletedIssueListItem: React.FC<IssueListItemProps> = obse
// derived values // derived values
const issueDetails = getIssueById(issueId); const issueDetails = getIssueById(issueId);
if (!issueDetails) return null; if (!issueDetails || !issueDetails.project_id) return null;
const projectDetails = getProjectById(issueDetails.project_id); const projectDetails = getProjectById(issueDetails.project_id);
@ -154,7 +154,7 @@ export const CreatedUpcomingIssueListItem: React.FC<IssueListItemProps> = observ
// derived values // derived values
const issue = getIssueById(issueId); const issue = getIssueById(issueId);
if (!issue) return null; if (!issue || !issue.project_id) return null;
const projectDetails = getProjectById(issue.project_id); const projectDetails = getProjectById(issue.project_id);
@ -208,7 +208,7 @@ export const CreatedOverdueIssueListItem: React.FC<IssueListItemProps> = observe
// derived values // derived values
const issue = getIssueById(issueId); const issue = getIssueById(issueId);
if (!issue) return null; if (!issue || !issue.project_id) return null;
const projectDetails = getProjectById(issue.project_id); const projectDetails = getProjectById(issue.project_id);
@ -260,7 +260,7 @@ export const CreatedCompletedIssueListItem: React.FC<IssueListItemProps> = obser
// derived values // derived values
const issue = getIssueById(issueId); const issue = getIssueById(issueId);
if (!issue) return null; if (!issue || !issue.project_id) return null;
const projectDetails = getProjectById(issue.project_id); const projectDetails = getProjectById(issue.project_id);

View File

@ -35,7 +35,7 @@ export const WidgetIssuesList: React.FC<WidgetIssuesListProps> = (props) => {
const { setPeekIssue } = useIssueDetail(); const { setPeekIssue } = useIssueDetail();
const handleIssuePeekOverview = (issue: TIssue) => const handleIssuePeekOverview = (issue: TIssue) =>
setPeekIssue({ workspaceSlug, projectId: issue.project_id, issueId: issue.id }); issue.project_id && setPeekIssue({ workspaceSlug, projectId: issue.project_id, issueId: issue.id });
const filterParams = getRedirectionFilters(tab); const filterParams = getRedirectionFilters(tab);

View File

@ -24,7 +24,7 @@ type Props = TDropdownProps & {
dropdownArrowClassName?: string; dropdownArrowClassName?: string;
onChange: (val: string | null) => void; onChange: (val: string | null) => void;
onClose?: () => void; onClose?: () => void;
projectId: string; projectId: string | undefined;
value: string | null; value: string | null;
}; };
@ -142,7 +142,7 @@ export const CycleDropdown: React.FC<Props> = observer((props) => {
</button> </button>
)} )}
</Combobox.Button> </Combobox.Button>
{isOpen && ( {isOpen && projectId && (
<CycleOptions isOpen={isOpen} projectId={projectId} placement={placement} referenceElement={referenceElement} /> <CycleOptions isOpen={isOpen} projectId={projectId} placement={placement} referenceElement={referenceElement} />
)} )}
</Combobox> </Combobox>

View File

@ -23,7 +23,7 @@ type Props = TDropdownProps & {
dropdownArrowClassName?: string; dropdownArrowClassName?: string;
onChange: (val: number | null) => void; onChange: (val: number | null) => void;
onClose?: () => void; onClose?: () => void;
projectId: string; projectId: string | undefined;
value: number | null; value: number | null;
}; };
@ -107,10 +107,10 @@ export const EstimateDropdown: React.FC<Props> = observer((props) => {
const filteredOptions = const filteredOptions =
query === "" ? options : options?.filter((o) => o.query.toLowerCase().includes(query.toLowerCase())); query === "" ? options : options?.filter((o) => o.query.toLowerCase().includes(query.toLowerCase()));
const selectedEstimate = value !== null ? getEstimatePointValue(value, projectId) : null; const selectedEstimate = value !== null && projectId ? getEstimatePointValue(value, projectId) : null;
const onOpen = () => { const onOpen = () => {
if (!activeEstimate && workspaceSlug) fetchProjectEstimates(workspaceSlug, projectId); if (!activeEstimate && workspaceSlug && projectId) fetchProjectEstimates(workspaceSlug, projectId);
}; };
const handleClose = () => { const handleClose = () => {

View File

@ -22,7 +22,7 @@ type Props = TDropdownProps & {
button?: ReactNode; button?: ReactNode;
dropdownArrow?: boolean; dropdownArrow?: boolean;
dropdownArrowClassName?: string; dropdownArrowClassName?: string;
projectId: string; projectId: string | undefined;
showCount?: boolean; showCount?: boolean;
onClose?: () => void; onClose?: () => void;
} & ( } & (
@ -272,7 +272,7 @@ export const ModuleDropdown: React.FC<Props> = observer((props) => {
</button> </button>
)} )}
</Combobox.Button> </Combobox.Button>
{isOpen && ( {isOpen && projectId && (
<ModuleOptions <ModuleOptions
isOpen={isOpen} isOpen={isOpen}
projectId={projectId} projectId={projectId}

View File

@ -24,7 +24,7 @@ type Props = TDropdownProps & {
highlightUrgent?: boolean; highlightUrgent?: boolean;
onChange: (val: TIssuePriorities) => void; onChange: (val: TIssuePriorities) => void;
onClose?: () => void; onClose?: () => void;
value: TIssuePriorities; value: TIssuePriorities | undefined | null;
}; };
type ButtonProps = { type ButtonProps = {
@ -35,7 +35,7 @@ type ButtonProps = {
hideText?: boolean; hideText?: boolean;
isActive?: boolean; isActive?: boolean;
highlightUrgent: boolean; highlightUrgent: boolean;
priority: TIssuePriorities; priority: TIssuePriorities | undefined;
showTooltip: boolean; showTooltip: boolean;
}; };
@ -66,7 +66,7 @@ const BorderButton = (props: ButtonProps) => {
<div <div
className={cn( className={cn(
"h-full flex items-center gap-1.5 border-[0.5px] rounded text-xs px-2 py-0.5", "h-full flex items-center gap-1.5 border-[0.5px] rounded text-xs px-2 py-0.5",
priorityClasses[priority], priorityClasses[priority || "none"],
{ {
// compact the icons if text is hidden // compact the icons if text is hidden
"px-0.5": hideText, "px-0.5": hideText,
@ -135,7 +135,7 @@ const BackgroundButton = (props: ButtonProps) => {
<div <div
className={cn( className={cn(
"h-full flex items-center gap-1.5 rounded text-xs px-2 py-0.5", "h-full flex items-center gap-1.5 rounded text-xs px-2 py-0.5",
priorityClasses[priority], priorityClasses[priority || "none"],
{ {
// compact the icons if text is hidden // compact the icons if text is hidden
"px-0.5": hideText, "px-0.5": hideText,
@ -205,7 +205,7 @@ const TransparentButton = (props: ButtonProps) => {
<div <div
className={cn( className={cn(
"h-full flex items-center gap-1.5 rounded text-xs px-2 py-0.5 hover:bg-custom-background-80", "h-full flex items-center gap-1.5 rounded text-xs px-2 py-0.5 hover:bg-custom-background-80",
priorityClasses[priority], priorityClasses[priority || "none"],
{ {
// compact the icons if text is hidden // compact the icons if text is hidden
"px-0.5": hideText, "px-0.5": hideText,
@ -342,8 +342,8 @@ export const PriorityDropdown: React.FC<Props> = (props) => {
const ButtonToRender = BORDER_BUTTON_VARIANTS.includes(buttonVariant) const ButtonToRender = BORDER_BUTTON_VARIANTS.includes(buttonVariant)
? BorderButton ? BorderButton
: BACKGROUND_BUTTON_VARIANTS.includes(buttonVariant) : BACKGROUND_BUTTON_VARIANTS.includes(buttonVariant)
? BackgroundButton ? BackgroundButton
: TransparentButton; : TransparentButton;
useEffect(() => { useEffect(() => {
if (isOpen && inputRef.current) { if (isOpen && inputRef.current) {
@ -393,7 +393,7 @@ export const PriorityDropdown: React.FC<Props> = (props) => {
onClick={handleOnClick} onClick={handleOnClick}
> >
<ButtonToRender <ButtonToRender
priority={value} priority={value ?? undefined}
className={cn(buttonClassName, { className={cn(buttonClassName, {
"text-white": resolvedTheme === "dark", "text-white": resolvedTheme === "dark",
})} })}

View File

@ -24,8 +24,8 @@ type Props = TDropdownProps & {
dropdownArrowClassName?: string; dropdownArrowClassName?: string;
onChange: (val: string) => void; onChange: (val: string) => void;
onClose?: () => void; onClose?: () => void;
projectId: string; projectId: string | undefined;
value: string; value: string | undefined | null;
}; };
export const StateDropdown: React.FC<Props> = observer((props) => { export const StateDropdown: React.FC<Props> = observer((props) => {
@ -92,7 +92,7 @@ export const StateDropdown: React.FC<Props> = observer((props) => {
const selectedState = getStateById(value); const selectedState = getStateById(value);
const onOpen = () => { const onOpen = () => {
if (!statesList && workspaceSlug) fetchProjectStates(workspaceSlug, projectId); if (!statesList && workspaceSlug && projectId) fetchProjectStates(workspaceSlug, projectId);
}; };
const handleClose = () => { const handleClose = () => {

View File

@ -73,7 +73,7 @@ export const DeleteInboxIssueModal: React.FC<Props> = observer(({ isOpen, onClos
<p className="text-sm text-custom-text-200"> <p className="text-sm text-custom-text-200">
Are you sure you want to delete issue{" "} Are you sure you want to delete issue{" "}
<span className="break-words font-medium text-custom-text-100"> <span className="break-words font-medium text-custom-text-100">
{getProjectById(data?.project_id)?.identifier}-{data?.sequence_id} {getProjectById(data?.project_id ?? "")?.identifier}-{data?.sequence_id}
</span> </span>
{""}? The issue will only be deleted from the inbox and this action cannot be undone. {""}? The issue will only be deleted from the inbox and this action cannot be undone.
</p> </p>

View File

@ -126,7 +126,7 @@ export const SelectDuplicateInboxIssueModal: React.FC<Props> = (props) => {
<ul className="text-sm text-custom-text-100"> <ul className="text-sm text-custom-text-100">
{filteredIssues.map((issue) => { {filteredIssues.map((issue) => {
const stateColor = const stateColor =
getProjectStates(issue?.project_id)?.find((state) => state?.id == issue?.state_id) getProjectStates(issue?.project_id ?? "")?.find((state) => state?.id == issue?.state_id)
?.color || ""; ?.color || "";
return ( return (

View File

@ -84,7 +84,7 @@ export const InboxIssueListItem: FC<TInboxIssueListItem> = observer((props) => {
<div className="flex flex-wrap items-center gap-2"> <div className="flex flex-wrap items-center gap-2">
<Tooltip tooltipHeading="Priority" tooltipContent={`${issue.priority ?? "None"}`}> <Tooltip tooltipHeading="Priority" tooltipContent={`${issue.priority ?? "None"}`}>
<PriorityIcon priority={issue.priority ?? null} className="h-3.5 w-3.5" /> <PriorityIcon priority={issue.priority} className="h-3.5 w-3.5" />
</Tooltip> </Tooltip>
<Tooltip tooltipHeading="Created on" tooltipContent={`${renderFormattedDate(issue.created_at ?? "")}`}> <Tooltip tooltipHeading="Created on" tooltipContent={`${renderFormattedDate(issue.created_at ?? "")}`}>
<div className="flex items-center gap-1 rounded border border-custom-border-200 px-2 py-[0.19rem] text-xs text-custom-text-200 shadow-sm"> <div className="flex items-center gap-1 rounded border border-custom-border-200 px-2 py-[0.19rem] text-xs text-custom-text-200 shadow-sm">

View File

@ -46,7 +46,7 @@ export const InboxIssueMainContent: React.FC<Props> = observer((props) => {
}, [isSubmitting, setShowAlert, setIsSubmitting]); }, [isSubmitting, setShowAlert, setIsSubmitting]);
const issue = issueId ? getIssueById(issueId) : undefined; const issue = issueId ? getIssueById(issueId) : undefined;
if (!issue) return <></>; if (!issue || !issue.project_id) return <></>;
const currentIssueState = projectStates?.find((s) => s.id === issue.state_id); const currentIssueState = projectStates?.find((s) => s.id === issue.state_id);

View File

@ -48,7 +48,7 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
}, [isSubmitting, setShowAlert, setIsSubmitting]); }, [isSubmitting, setShowAlert, setIsSubmitting]);
const issue = issueId ? getIssueById(issueId) : undefined; const issue = issueId ? getIssueById(issueId) : undefined;
if (!issue) return <></>; if (!issue || !issue.project_id) return <></>;
const currentIssueState = projectStates?.find((s) => s.id === issue.state_id); const currentIssueState = projectStates?.find((s) => s.id === issue.state_id);

View File

@ -26,7 +26,7 @@ export const IssueParentSiblings: FC<TIssueParentSiblings> = (props) => {
? `ISSUE_PARENT_CHILD_ISSUES_${peekIssue?.workspaceSlug}_${parentIssue.project_id}_${parentIssue.id}` ? `ISSUE_PARENT_CHILD_ISSUES_${peekIssue?.workspaceSlug}_${parentIssue.project_id}_${parentIssue.id}`
: null, : null,
peekIssue && parentIssue && parentIssue.project_id peekIssue && parentIssue && parentIssue.project_id
? () => fetchSubIssues(peekIssue?.workspaceSlug, parentIssue.project_id, parentIssue.id) ? () => fetchSubIssues(peekIssue?.workspaceSlug, parentIssue.project_id!, parentIssue.id)
: null : null
); );

View File

@ -30,6 +30,7 @@ export const IssueGanttBlock: React.FC<Props> = observer((props) => {
workspaceSlug && workspaceSlug &&
issueDetails && issueDetails &&
!issueDetails.tempId && !issueDetails.tempId &&
issueDetails.project_id &&
setPeekIssue({ workspaceSlug, projectId: issueDetails.project_id, issueId: issueDetails.id }); setPeekIssue({ workspaceSlug, projectId: issueDetails.project_id, issueId: issueDetails.id });
return ( return (
@ -82,6 +83,7 @@ export const IssueGanttSidebarBlock: React.FC<Props> = observer((props) => {
const handleIssuePeekOverview = () => const handleIssuePeekOverview = () =>
workspaceSlug && workspaceSlug &&
issueDetails && issueDetails &&
issueDetails.project_id &&
setPeekIssue({ workspaceSlug, projectId: issueDetails.project_id, issueId: issueDetails.id }); setPeekIssue({ workspaceSlug, projectId: issueDetails.project_id, issueId: issueDetails.id });
return ( return (

View File

@ -118,7 +118,7 @@ export const KanbanIssueBlock: React.FC<IssueBlockProps> = memo((props) => {
if (!issue) return null; if (!issue) return null;
const canEditIssueProperties = canEditProperties(issue.project_id); const canEditIssueProperties = canEditProperties(issue.project_id ?? undefined);
return ( return (
<Draggable <Draggable

View File

@ -39,7 +39,7 @@ export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlock
if (!issue) return null; if (!issue) return null;
const canEditIssueProperties = canEditProperties(issue.project_id); const canEditIssueProperties = canEditProperties(issue.project_id ?? undefined);
const projectIdentifier = getProjectIdentifierById(issue.project_id); const projectIdentifier = getProjectIdentifierById(issue.project_id);
return ( return (

View File

@ -30,7 +30,9 @@ import { WithDisplayPropertiesHOC } from "../properties/with-display-properties-
export interface IIssueProperties { export interface IIssueProperties {
issue: TIssue; issue: TIssue;
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined; updateIssue:
| ((projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => Promise<void>)
| undefined;
displayProperties: IIssueDisplayProperties | undefined; displayProperties: IIssueDisplayProperties | undefined;
isReadOnly: boolean; isReadOnly: boolean;
className: string; className: string;
@ -236,7 +238,7 @@ export const IssueProperties: React.FC<IIssueProperties> = observer((props) => {
}); });
}; };
if (!displayProperties) return null; if (!displayProperties || !issue.project_id) return null;
const defaultLabelOptions = issue?.label_ids?.map((id) => labelMap[id]) || []; const defaultLabelOptions = issue?.label_ids?.map((id) => labelMap[id]) || [];
@ -267,7 +269,7 @@ export const IssueProperties: React.FC<IIssueProperties> = observer((props) => {
<WithDisplayPropertiesHOC displayProperties={displayProperties} displayPropertyKey="priority"> <WithDisplayPropertiesHOC displayProperties={displayProperties} displayPropertyKey="priority">
<div className="h-5"> <div className="h-5">
<PriorityDropdown <PriorityDropdown
value={issue?.priority || null} value={issue?.priority}
onChange={handlePriority} onChange={handlePriority}
disabled={isReadOnly} disabled={isReadOnly}
buttonVariant="border-without-text" buttonVariant="border-without-text"

View File

@ -29,7 +29,7 @@ export const SpreadsheetAssigneeColumn: React.FC<Props> = observer((props: Props
} }
); );
}} }}
projectId={issue?.project_id} projectId={issue?.project_id ?? undefined}
disabled={disabled} disabled={disabled}
multiple multiple
placeholder="Assignees" placeholder="Assignees"

View File

@ -30,7 +30,7 @@ export const SpreadsheetCycleColumn: React.FC<Props> = observer((props) => {
const handleCycle = useCallback( const handleCycle = useCallback(
async (cycleId: string | null) => { async (cycleId: string | null) => {
if (!workspaceSlug || !issue || issue.cycle_id === cycleId) return; if (!workspaceSlug || !issue || !issue.project_id || issue.cycle_id === cycleId) return;
if (cycleId) await addIssueToCycle(workspaceSlug.toString(), issue.project_id, cycleId, [issue.id]); if (cycleId) await addIssueToCycle(workspaceSlug.toString(), issue.project_id, cycleId, [issue.id]);
else await removeIssueFromCycle(workspaceSlug.toString(), issue.project_id, issue.cycle_id ?? "", issue.id); else await removeIssueFromCycle(workspaceSlug.toString(), issue.project_id, issue.cycle_id ?? "", issue.id);
captureIssueEvent({ captureIssueEvent({
@ -50,7 +50,7 @@ export const SpreadsheetCycleColumn: React.FC<Props> = observer((props) => {
return ( return (
<div className="h-11 border-b-[0.5px] border-custom-border-200"> <div className="h-11 border-b-[0.5px] border-custom-border-200">
<CycleDropdown <CycleDropdown
projectId={issue.project_id} projectId={issue.project_id ?? undefined}
value={issue.cycle_id} value={issue.cycle_id}
onChange={handleCycle} onChange={handleCycle}
disabled={disabled} disabled={disabled}

View File

@ -39,9 +39,9 @@ export const SpreadsheetModuleColumn: React.FC<Props> = observer((props) => {
for (const moduleId of updatedModuleIds) for (const moduleId of updatedModuleIds)
if (issue.module_ids.includes(moduleId)) modulesToRemove.push(moduleId); if (issue.module_ids.includes(moduleId)) modulesToRemove.push(moduleId);
else modulesToAdd.push(moduleId); else modulesToAdd.push(moduleId);
if (modulesToAdd.length > 0) if (issue.project_id && modulesToAdd.length > 0)
addModulesToIssue(workspaceSlug.toString(), issue.project_id, issue.id, modulesToAdd); addModulesToIssue(workspaceSlug.toString(), issue.project_id, issue.id, modulesToAdd);
if (modulesToRemove.length > 0) if (issue.project_id && modulesToRemove.length > 0)
removeModulesFromIssue(workspaceSlug.toString(), issue.project_id, issue.id, modulesToRemove); removeModulesFromIssue(workspaceSlug.toString(), issue.project_id, issue.id, modulesToRemove);
captureIssueEvent({ captureIssueEvent({
@ -61,7 +61,7 @@ export const SpreadsheetModuleColumn: React.FC<Props> = observer((props) => {
return ( return (
<div className="h-11 border-b-[0.5px] border-custom-border-200"> <div className="h-11 border-b-[0.5px] border-custom-border-200">
<ModuleDropdown <ModuleDropdown
projectId={issue?.project_id} projectId={issue?.project_id ?? undefined}
value={issue?.module_ids ?? []} value={issue?.module_ids ?? []}
onChange={handleModule} onChange={handleModule}
disabled={disabled} disabled={disabled}

View File

@ -18,7 +18,7 @@ export const SpreadsheetStateColumn: React.FC<Props> = observer((props) => {
return ( return (
<div className="h-11 border-b-[0.5px] border-custom-border-200"> <div className="h-11 border-b-[0.5px] border-custom-border-200">
<StateDropdown <StateDropdown
projectId={issue.project_id} projectId={issue.project_id ?? undefined}
value={issue.state_id} value={issue.state_id}
onChange={(data) => onChange(issue, { state_id: data }, { changed_property: "state", change_details: data })} onChange={(data) => onChange(issue, { state_id: data }, { changed_property: "state", change_details: data })}
disabled={disabled} disabled={disabled}

View File

@ -416,7 +416,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
)} )}
</button> </button>
)} )}
{envConfig?.has_openai_configured && ( {envConfig?.has_openai_configured && projectId && (
<GptAssistantPopover <GptAssistantPopover
isOpen={gptAssistantModal} isOpen={gptAssistantModal}
projectId={projectId} projectId={projectId}
@ -486,7 +486,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
onChange(stateId); onChange(stateId);
handleFormChange(); handleFormChange();
}} }}
projectId={projectId} projectId={projectId ?? undefined}
buttonVariant="border-with-text" buttonVariant="border-with-text"
tabIndex={getTabIndex("state_id")} tabIndex={getTabIndex("state_id")}
/> />
@ -516,7 +516,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
render={({ field: { value, onChange } }) => ( render={({ field: { value, onChange } }) => (
<div className="h-7"> <div className="h-7">
<MemberDropdown <MemberDropdown
projectId={projectId} projectId={projectId ?? undefined}
value={value} value={value}
onChange={(assigneeIds) => { onChange={(assigneeIds) => {
onChange(assigneeIds); onChange(assigneeIds);
@ -543,7 +543,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
onChange(labelIds); onChange(labelIds);
handleFormChange(); handleFormChange();
}} }}
projectId={projectId} projectId={projectId ?? undefined}
tabIndex={getTabIndex("label_ids")} tabIndex={getTabIndex("label_ids")}
/> />
</div> </div>
@ -588,7 +588,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
render={({ field: { value, onChange } }) => ( render={({ field: { value, onChange } }) => (
<div className="h-7"> <div className="h-7">
<CycleDropdown <CycleDropdown
projectId={projectId} projectId={projectId ?? undefined}
onChange={(cycleId) => { onChange={(cycleId) => {
onChange(cycleId); onChange(cycleId);
handleFormChange(); handleFormChange();
@ -608,7 +608,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
render={({ field: { value, onChange } }) => ( render={({ field: { value, onChange } }) => (
<div className="h-7"> <div className="h-7">
<ModuleDropdown <ModuleDropdown
projectId={projectId} projectId={projectId ?? undefined}
value={value ?? []} value={value ?? []}
onChange={(moduleIds) => { onChange={(moduleIds) => {
onChange(moduleIds); onChange(moduleIds);
@ -623,7 +623,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
)} )}
/> />
)} )}
{areEstimatesEnabledForProject(projectId) && ( {projectId && areEstimatesEnabledForProject(projectId) && (
<Controller <Controller
control={control} control={control}
name="estimate_point" name="estimate_point"
@ -635,7 +635,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
onChange(estimatePoint); onChange(estimatePoint);
handleFormChange(); handleFormChange();
}} }}
projectId={projectId} projectId={projectId ?? undefined}
buttonVariant="border-with-text" buttonVariant="border-with-text"
tabIndex={getTabIndex("estimate_point")} tabIndex={getTabIndex("estimate_point")}
/> />
@ -702,7 +702,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
handleFormChange(); handleFormChange();
setSelectedParentIssue(issue); setSelectedParentIssue(issue);
}} }}
projectId={projectId} projectId={projectId ?? undefined}
/> />
)} )}
/> />

View File

@ -111,10 +111,10 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = observer((prop
}, [data, projectId, workspaceProjectIds, isOpen, activeProjectId]); }, [data, projectId, workspaceProjectIds, isOpen, activeProjectId]);
const addIssueToCycle = async (issue: TIssue, cycleId: string) => { const addIssueToCycle = async (issue: TIssue, cycleId: string) => {
if (!workspaceSlug || !activeProjectId) return; if (!workspaceSlug || !issue.project_id) return;
await cycleIssues.addIssueToCycle(workspaceSlug, issue.project_id, cycleId, [issue.id]); await cycleIssues.addIssueToCycle(workspaceSlug, issue.project_id, cycleId, [issue.id]);
fetchCycleDetails(workspaceSlug, activeProjectId, cycleId); fetchCycleDetails(workspaceSlug, issue.project_id, cycleId);
}; };
const addIssueToModule = async (issue: TIssue, moduleIds: string[]) => { const addIssueToModule = async (issue: TIssue, moduleIds: string[]) => {

View File

@ -18,7 +18,7 @@ type Props = {
handleClose: () => void; handleClose: () => void;
value?: any; value?: any;
onChange: (issue: ISearchIssueResponse) => void; onChange: (issue: ISearchIssueResponse) => void;
projectId: string; projectId: string | undefined;
issueId?: string; issueId?: string;
}; };

View File

@ -43,9 +43,9 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = observer(
}, [isSubmitting, setShowAlert, setIsSubmitting]); }, [isSubmitting, setShowAlert, setIsSubmitting]);
const issue = issueId ? getIssueById(issueId) : undefined; const issue = issueId ? getIssueById(issueId) : undefined;
if (!issue) return <></>; if (!issue || !issue.project_id) return <></>;
const projectDetails = getProjectById(issue?.project_id); const projectDetails = getProjectById(issue.project_id);
const issueDescription = const issueDescription =
issue.description_html !== undefined || issue.description_html !== null issue.description_html !== undefined || issue.description_html !== null

View File

@ -16,7 +16,7 @@ type Props = {
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>; setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
value: string[]; value: string[];
onChange: (value: string[]) => void; onChange: (value: string[]) => void;
projectId: string; projectId: string | undefined;
label?: JSX.Element; label?: JSX.Element;
disabled?: boolean; disabled?: boolean;
tabIndex?: number; tabIndex?: number;

View File

@ -176,7 +176,8 @@ export const IssueListItem: React.FC<ISubIssues> = observer((props) => {
<div <div
className="invisible flex h-[22px] w-[22px] flex-shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-sm transition-all hover:bg-custom-background-80 group-hover:visible" className="invisible flex h-[22px] w-[22px] flex-shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-sm transition-all hover:bg-custom-background-80 group-hover:visible"
onClick={() => { onClick={() => {
subIssueOperations.removeSubIssue(workspaceSlug, issue.project_id, parentIssueId, issue.id); issue.project_id &&
subIssueOperations.removeSubIssue(workspaceSlug, issue.project_id, parentIssueId, issue.id);
}} }}
> >
<X width={14} strokeWidth={2} /> <X width={14} strokeWidth={2} />
@ -187,17 +188,20 @@ export const IssueListItem: React.FC<ISubIssues> = observer((props) => {
</div> </div>
)} )}
{subIssueHelpers.issue_visibility.includes(issueId) && issue.sub_issues_count && issue.sub_issues_count > 0 && ( {subIssueHelpers.issue_visibility.includes(issueId) &&
<IssueList issue.sub_issues_count &&
workspaceSlug={workspaceSlug} issue.project_id &&
projectId={issue.project_id} issue.sub_issues_count > 0 && (
parentIssueId={issue.id} <IssueList
spacingLeft={spacingLeft + 22} workspaceSlug={workspaceSlug}
disabled={disabled} projectId={issue.project_id}
handleIssueCrudState={handleIssueCrudState} parentIssueId={issue.id}
subIssueOperations={subIssueOperations} spacingLeft={spacingLeft + 22}
/> disabled={disabled}
)} handleIssueCrudState={handleIssueCrudState}
subIssueOperations={subIssueOperations}
/>
)}
</div> </div>
); );
}); });

View File

@ -29,8 +29,9 @@ export const IssueProperty: React.FC<IIssueProperty> = (props) => {
<div className="h-5 flex-shrink-0"> <div className="h-5 flex-shrink-0">
<StateDropdown <StateDropdown
value={issue.state_id} value={issue.state_id}
projectId={issue.project_id} projectId={issue.project_id ?? undefined}
onChange={(val) => onChange={(val) =>
issue.project_id &&
subIssueOperations.updateSubIssue( subIssueOperations.updateSubIssue(
workspaceSlug, workspaceSlug,
issue.project_id, issue.project_id,
@ -51,6 +52,7 @@ export const IssueProperty: React.FC<IIssueProperty> = (props) => {
<PriorityDropdown <PriorityDropdown
value={issue.priority} value={issue.priority}
onChange={(val) => onChange={(val) =>
issue.project_id &&
subIssueOperations.updateSubIssue(workspaceSlug, issue.project_id, parentIssueId, issueId, { subIssueOperations.updateSubIssue(workspaceSlug, issue.project_id, parentIssueId, issueId, {
priority: val, priority: val,
}) })
@ -64,8 +66,9 @@ export const IssueProperty: React.FC<IIssueProperty> = (props) => {
<div className="h-5 flex-shrink-0"> <div className="h-5 flex-shrink-0">
<MemberDropdown <MemberDropdown
value={issue.assignee_ids} value={issue.assignee_ids}
projectId={issue.project_id} projectId={issue.project_id ?? undefined}
onChange={(val) => onChange={(val) =>
issue.project_id &&
subIssueOperations.updateSubIssue(workspaceSlug, issue.project_id, parentIssueId, issueId, { subIssueOperations.updateSubIssue(workspaceSlug, issue.project_id, parentIssueId, issueId, {
assignee_ids: val, assignee_ids: val,
}) })

View File

@ -19,12 +19,12 @@ interface IssueActions {
userViewId?: "assigned" | "created" | "subscribed" userViewId?: "assigned" | "created" | "subscribed"
) => Promise<TIssuesResponse | undefined>; ) => Promise<TIssuesResponse | undefined>;
fetchNextIssues: () => Promise<TIssuesResponse | undefined>; fetchNextIssues: () => Promise<TIssuesResponse | undefined>;
removeIssue: (projectId: string, issueId: string) => Promise<void>; removeIssue: (projectId: string | undefined | null, issueId: string) => Promise<void>;
createIssue?: (projectId: string, data: Partial<TIssue>) => Promise<TIssue | undefined>; createIssue?: (projectId: string | undefined | null, data: Partial<TIssue>) => Promise<TIssue | undefined>;
updateIssue?: (projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>; updateIssue?: (projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => Promise<void>;
removeIssueFromView?: (projectId: string, issueId: string) => Promise<void>; removeIssueFromView?: (projectId: string | undefined | null, issueId: string) => Promise<void>;
archiveIssue?: (projectId: string, issueId: string) => Promise<void>; archiveIssue?: (projectId: string | undefined | null, issueId: string) => Promise<void>;
restoreIssue?: (projectId: string, issueId: string) => Promise<void>; restoreIssue?: (projectId: string | undefined | null, issueId: string) => Promise<void>;
updateFilters: ( updateFilters: (
projectId: string, projectId: string,
filterType: EIssueFilterType, filterType: EIssueFilterType,
@ -83,29 +83,29 @@ const useProjectIssueActions = () => {
}, [issues.fetchIssues, workspaceSlug, projectId]); }, [issues.fetchIssues, workspaceSlug, projectId]);
const createIssue = useCallback( const createIssue = useCallback(
async (projectId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.createIssue(workspaceSlug, projectId, data); return await issues.createIssue(workspaceSlug, projectId, data);
}, },
[issues.createIssue, workspaceSlug] [issues.createIssue, workspaceSlug]
); );
const updateIssue = useCallback( const updateIssue = useCallback(
async (projectId: string, issueId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.updateIssue(workspaceSlug, projectId, issueId, data); return await issues.updateIssue(workspaceSlug, projectId, issueId, data);
}, },
[issues.updateIssue, workspaceSlug] [issues.updateIssue, workspaceSlug]
); );
const removeIssue = useCallback( const removeIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.removeIssue(workspaceSlug, projectId, issueId); return await issues.removeIssue(workspaceSlug, projectId, issueId);
}, },
[issues.removeIssue, workspaceSlug] [issues.removeIssue, workspaceSlug]
); );
const archiveIssue = useCallback( const archiveIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.archiveIssue(workspaceSlug, projectId, issueId); return await issues.archiveIssue(workspaceSlug, projectId, issueId);
}, },
[issues.archiveIssue, workspaceSlug] [issues.archiveIssue, workspaceSlug]
@ -157,36 +157,36 @@ const useCycleIssueActions = () => {
}, [issues.fetchIssues, workspaceSlug, projectId, cycleId]); }, [issues.fetchIssues, workspaceSlug, projectId, cycleId]);
const createIssue = useCallback( const createIssue = useCallback(
async (projectId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, data: Partial<TIssue>) => {
if (!cycleId || !workspaceSlug) return; if (!cycleId || !workspaceSlug || !projectId) return;
return await issues.createIssue(workspaceSlug, projectId, data, cycleId); return await issues.createIssue(workspaceSlug, projectId, data, cycleId);
}, },
[issues.createIssue, cycleId, workspaceSlug] [issues.createIssue, cycleId, workspaceSlug]
); );
const updateIssue = useCallback( const updateIssue = useCallback(
async (projectId: string, issueId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.updateIssue(workspaceSlug, projectId, issueId, data); return await issues.updateIssue(workspaceSlug, projectId, issueId, data);
}, },
[issues.updateIssue, workspaceSlug] [issues.updateIssue, workspaceSlug]
); );
const removeIssue = useCallback( const removeIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.removeIssue(workspaceSlug, projectId, issueId); return await issues.removeIssue(workspaceSlug, projectId, issueId);
}, },
[issues.removeIssue, workspaceSlug] [issues.removeIssue, workspaceSlug]
); );
const removeIssueFromView = useCallback( const removeIssueFromView = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!cycleId || !workspaceSlug) return; if (!cycleId || !workspaceSlug || !projectId) return;
return await issues.removeIssueFromCycle(workspaceSlug, projectId, cycleId, issueId); return await issues.removeIssueFromCycle(workspaceSlug, projectId, cycleId, issueId);
}, },
[issues.removeIssueFromCycle, cycleId, workspaceSlug] [issues.removeIssueFromCycle, cycleId, workspaceSlug]
); );
const archiveIssue = useCallback( const archiveIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.archiveIssue(workspaceSlug, projectId, issueId); return await issues.archiveIssue(workspaceSlug, projectId, issueId);
}, },
[issues.archiveIssue, workspaceSlug] [issues.archiveIssue, workspaceSlug]
@ -248,36 +248,36 @@ const useModuleIssueActions = () => {
}, [issues.fetchIssues, workspaceSlug, projectId, moduleId]); }, [issues.fetchIssues, workspaceSlug, projectId, moduleId]);
const createIssue = useCallback( const createIssue = useCallback(
async (projectId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, data: Partial<TIssue>) => {
if (!moduleId || !workspaceSlug) return; if (!moduleId || !workspaceSlug || !projectId) return;
return await issues.createIssue(workspaceSlug, projectId, data, moduleId); return await issues.createIssue(workspaceSlug, projectId, data, moduleId);
}, },
[issues.createIssue, moduleId, workspaceSlug] [issues.createIssue, moduleId, workspaceSlug]
); );
const updateIssue = useCallback( const updateIssue = useCallback(
async (projectId: string, issueId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.updateIssue(workspaceSlug, projectId, issueId, data); return await issues.updateIssue(workspaceSlug, projectId, issueId, data);
}, },
[issues.updateIssue, workspaceSlug] [issues.updateIssue, workspaceSlug]
); );
const removeIssue = useCallback( const removeIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.removeIssue(workspaceSlug, projectId, issueId); return await issues.removeIssue(workspaceSlug, projectId, issueId);
}, },
[issues.removeIssue, workspaceSlug] [issues.removeIssue, workspaceSlug]
); );
const removeIssueFromView = useCallback( const removeIssueFromView = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!moduleId || !workspaceSlug) return; if (!moduleId || !workspaceSlug || !projectId) return;
return await issues.removeIssueFromModule(workspaceSlug, projectId, moduleId, issueId); return await issues.removeIssueFromModule(workspaceSlug, projectId, moduleId, issueId);
}, },
[issues.removeIssueFromModule, moduleId, workspaceSlug] [issues.removeIssueFromModule, moduleId, workspaceSlug]
); );
const archiveIssue = useCallback( const archiveIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.archiveIssue(workspaceSlug, projectId, issueId); return await issues.archiveIssue(workspaceSlug, projectId, issueId);
}, },
[issues.archiveIssue, moduleId, workspaceSlug] [issues.archiveIssue, moduleId, workspaceSlug]
@ -330,29 +330,29 @@ const useProfileIssueActions = () => {
}, [issues.fetchIssues, workspaceSlug, userId]); }, [issues.fetchIssues, workspaceSlug, userId]);
const createIssue = useCallback( const createIssue = useCallback(
async (projectId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.createIssue(workspaceSlug, projectId, data); return await issues.createIssue(workspaceSlug, projectId, data);
}, },
[issues.createIssue, workspaceSlug] [issues.createIssue, workspaceSlug]
); );
const updateIssue = useCallback( const updateIssue = useCallback(
async (projectId: string, issueId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.updateIssue(workspaceSlug, projectId, issueId, data); return await issues.updateIssue(workspaceSlug, projectId, issueId, data);
}, },
[issues.updateIssue, workspaceSlug] [issues.updateIssue, workspaceSlug]
); );
const removeIssue = useCallback( const removeIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.removeIssue(workspaceSlug, projectId, issueId); return await issues.removeIssue(workspaceSlug, projectId, issueId);
}, },
[issues.removeIssue, workspaceSlug] [issues.removeIssue, workspaceSlug]
); );
const archiveIssue = useCallback( const archiveIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.archiveIssue(workspaceSlug, projectId, issueId); return await issues.archiveIssue(workspaceSlug, projectId, issueId);
}, },
[issues.archiveIssue, workspaceSlug] [issues.archiveIssue, workspaceSlug]
@ -404,29 +404,29 @@ const useProjectViewIssueActions = () => {
}, [issues.fetchIssues, workspaceSlug, projectId]); }, [issues.fetchIssues, workspaceSlug, projectId]);
const createIssue = useCallback( const createIssue = useCallback(
async (projectId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.createIssue(workspaceSlug, projectId, data); return await issues.createIssue(workspaceSlug, projectId, data);
}, },
[issues.createIssue, workspaceSlug] [issues.createIssue, workspaceSlug]
); );
const updateIssue = useCallback( const updateIssue = useCallback(
async (projectId: string, issueId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.updateIssue(workspaceSlug, projectId, issueId, data); return await issues.updateIssue(workspaceSlug, projectId, issueId, data);
}, },
[issues.updateIssue, workspaceSlug] [issues.updateIssue, workspaceSlug]
); );
const removeIssue = useCallback( const removeIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.removeIssue(workspaceSlug, projectId, issueId); return await issues.removeIssue(workspaceSlug, projectId, issueId);
}, },
[issues.removeIssue, workspaceSlug] [issues.removeIssue, workspaceSlug]
); );
const archiveIssue = useCallback( const archiveIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.archiveIssue(workspaceSlug, projectId, issueId); return await issues.archiveIssue(workspaceSlug, projectId, issueId);
}, },
[issues.archiveIssue, workspaceSlug] [issues.archiveIssue, workspaceSlug]
@ -478,22 +478,22 @@ const useDraftIssueActions = () => {
}, [issues.fetchIssues, workspaceSlug, projectId]); }, [issues.fetchIssues, workspaceSlug, projectId]);
const createIssue = useCallback( const createIssue = useCallback(
async (projectId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.createIssue(workspaceSlug, projectId, data); return await issues.createIssue(workspaceSlug, projectId, data);
}, },
[issues.createIssue, workspaceSlug] [issues.createIssue, workspaceSlug]
); );
const updateIssue = useCallback( const updateIssue = useCallback(
async (projectId: string, issueId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.updateIssue(workspaceSlug, projectId, issueId, data); return await issues.updateIssue(workspaceSlug, projectId, issueId, data);
}, },
[issues.updateIssue, workspaceSlug] [issues.updateIssue, workspaceSlug]
); );
const removeIssue = useCallback( const removeIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.removeIssue(workspaceSlug, projectId, issueId); return await issues.removeIssue(workspaceSlug, projectId, issueId);
}, },
[issues.removeIssue, workspaceSlug] [issues.removeIssue, workspaceSlug]
@ -544,15 +544,15 @@ const useArchivedIssueActions = () => {
}, [issues.fetchIssues, workspaceSlug, projectId]); }, [issues.fetchIssues, workspaceSlug, projectId]);
const removeIssue = useCallback( const removeIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.removeIssue(workspaceSlug, projectId, issueId); return await issues.removeIssue(workspaceSlug, projectId, issueId);
}, },
[issues.removeIssue] [issues.removeIssue]
); );
const restoreIssue = useCallback( const restoreIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.restoreIssue(workspaceSlug, projectId, issueId); return await issues.restoreIssue(workspaceSlug, projectId, issueId);
}, },
[issues.restoreIssue] [issues.restoreIssue]
@ -601,22 +601,22 @@ const useGlobalIssueActions = () => {
}, [issues.fetchIssues, workspaceSlug, globalViewId]); }, [issues.fetchIssues, workspaceSlug, globalViewId]);
const createIssue = useCallback( const createIssue = useCallback(
async (projectId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.createIssue(workspaceSlug, projectId, data); return await issues.createIssue(workspaceSlug, projectId, data);
}, },
[issues.createIssue, workspaceSlug] [issues.createIssue, workspaceSlug]
); );
const updateIssue = useCallback( const updateIssue = useCallback(
async (projectId: string, issueId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.updateIssue(workspaceSlug, projectId, issueId, data); return await issues.updateIssue(workspaceSlug, projectId, issueId, data);
}, },
[issues.updateIssue, workspaceSlug] [issues.updateIssue, workspaceSlug]
); );
const removeIssue = useCallback( const removeIssue = useCallback(
async (projectId: string, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug) return; if (!workspaceSlug || !projectId) return;
return await issues.removeIssue(workspaceSlug, projectId, issueId); return await issues.removeIssue(workspaceSlug, projectId, issueId);
}, },
[issues.removeIssue, workspaceSlug] [issues.removeIssue, workspaceSlug]

View File

@ -50,7 +50,7 @@ const ArchivedIssueDetailsPage: NextPageWithLayout = observer(() => {
// derived values // derived values
const issue = archivedIssueId ? getIssueById(archivedIssueId.toString()) : undefined; const issue = archivedIssueId ? getIssueById(archivedIssueId.toString()) : undefined;
const project = issue ? getProjectById(issue?.project_id) : undefined; const project = issue ? getProjectById(issue?.project_id ?? "") : undefined;
const pageTitle = project && issue ? `${project?.identifier}-${issue?.sequence_id} ${issue?.name}` : undefined; const pageTitle = project && issue ? `${project?.identifier}-${issue?.sequence_id} ${issue?.name}` : undefined;
// auth // auth
const canRestoreIssue = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; const canRestoreIssue = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
@ -68,11 +68,9 @@ const ArchivedIssueDetailsPage: NextPageWithLayout = observer(() => {
type: TOAST_TYPE.SUCCESS, type: TOAST_TYPE.SUCCESS,
title: "Success", title: "Success",
message: message:
issue && issue && project
`${getProjectById(issue.project_id) ? `${project.identifier}-${issue.sequence_id} is restored successfully under the project ${project.name}`
?.identifier}-${issue?.sequence_id} is restored successfully under the project ${getProjectById( : `issue is restored successfully`,
issue.project_id
)?.name}`,
}); });
router.push(`/${workspaceSlug}/projects/${projectId}/issues/${archivedIssueId}`); router.push(`/${workspaceSlug}/projects/${projectId}/issues/${archivedIssueId}`);
}) })

View File

@ -20,7 +20,7 @@ export interface IEstimateStore {
areEstimatesEnabledForProject: (projectId: string) => boolean; areEstimatesEnabledForProject: (projectId: string) => boolean;
getEstimatePointValue: (estimateKey: number | null, projectId: string | null) => string; getEstimatePointValue: (estimateKey: number | null, projectId: string | null) => string;
getProjectEstimateById: (estimateId: string) => IEstimate | null; getProjectEstimateById: (estimateId: string) => IEstimate | null;
getProjectActiveEstimateDetails: (projectId: string) => IEstimate | null; getProjectActiveEstimateDetails: (projectId: string | undefined | null) => IEstimate | null;
// fetch actions // fetch actions
fetchProjectEstimates: (workspaceSlug: string, projectId: string) => Promise<IEstimate[]>; fetchProjectEstimates: (workspaceSlug: string, projectId: string) => Promise<IEstimate[]>;
fetchWorkspaceEstimates: (workspaceSlug: string) => Promise<IEstimate[]>; fetchWorkspaceEstimates: (workspaceSlug: string) => Promise<IEstimate[]>;
@ -129,10 +129,15 @@ export class EstimateStore implements IEstimateStore {
* @description returns the estimate details for the given estimate id * @description returns the estimate details for the given estimate id
* @param projectId * @param projectId
*/ */
getProjectActiveEstimateDetails = computedFn((projectId: string) => { getProjectActiveEstimateDetails = computedFn((projectId: string | undefined | null) => {
const projectDetails = this.rootStore.projectRoot.project?.getProjectById(projectId); const projectDetails = this.rootStore.projectRoot.project?.getProjectById(projectId);
const worksapceSlug = this.rootStore.app.router.workspaceSlug || ""; const worksapceSlug = this.rootStore.app.router.workspaceSlug || "";
if (!projectDetails || !projectDetails?.estimate || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) if (
!projectId ||
!projectDetails ||
!projectDetails?.estimate ||
!(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])
)
return null; return null;
return this.estimateMap?.[projectDetails?.estimate || ""] || null; return this.estimateMap?.[projectDetails?.estimate || ""] || null;
}); });

View File

@ -20,7 +20,7 @@ export interface ILabelStore {
projectLabelsTree: IIssueLabelTree[] | undefined; projectLabelsTree: IIssueLabelTree[] | undefined;
workspaceLabels: IIssueLabel[] | undefined; workspaceLabels: IIssueLabel[] | undefined;
//computed actions //computed actions
getProjectLabels: (projectId: string | null) => IIssueLabel[] | undefined; getProjectLabels: (projectId: string | undefined | null) => IIssueLabel[] | undefined;
getLabelById: (labelId: string) => IIssueLabel | null; getLabelById: (labelId: string) => IIssueLabel | null;
// fetch actions // fetch actions
fetchWorkspaceLabels: (workspaceSlug: string) => Promise<IIssueLabel[]>; fetchWorkspaceLabels: (workspaceSlug: string) => Promise<IIssueLabel[]>;
@ -110,9 +110,9 @@ export class LabelStore implements ILabelStore {
return buildTree(this.projectLabels); return buildTree(this.projectLabels);
} }
getProjectLabels = computedFn((projectId: string | null) => { getProjectLabels = computedFn((projectId: string | undefined | null) => {
const worksapceSlug = this.rootStore.app.router.workspaceSlug || ""; const workspaceSlug = this.rootStore.app.router.workspaceSlug || "";
if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return; if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[workspaceSlug])) return;
return sortBy( return sortBy(
Object.values(this.labelMap).filter((label) => label.project_id === projectId), Object.values(this.labelMap).filter((label) => label.project_id === projectId),
"sort_order" "sort_order"

View File

@ -23,8 +23,8 @@ export interface IProjectStore {
currentProjectDetails: IProject | undefined; currentProjectDetails: IProject | undefined;
// actions // actions
setSearchQuery: (query: string) => void; setSearchQuery: (query: string) => void;
getProjectById: (projectId: string) => IProject | null; getProjectById: (projectId: string | undefined | null) => IProject | undefined;
getProjectIdentifierById: (projectId: string) => string; getProjectIdentifierById: (projectId: string | undefined | null) => string;
// fetch actions // fetch actions
fetchProjects: (workspaceSlug: string) => Promise<IProject[]>; fetchProjects: (workspaceSlug: string) => Promise<IProject[]>;
fetchProjectDetails: (workspaceSlug: string, projectId: string) => Promise<any>; fetchProjectDetails: (workspaceSlug: string, projectId: string) => Promise<any>;
@ -206,8 +206,8 @@ export class ProjectStore implements IProjectStore {
* @param projectId * @param projectId
* @returns IProject | null * @returns IProject | null
*/ */
getProjectById = computedFn((projectId: string) => { getProjectById = computedFn((projectId: string | undefined | null) => {
const projectInfo = this.projectMap[projectId] || null; const projectInfo = this.projectMap[projectId ?? ""] || undefined;
return projectInfo; return projectInfo;
}); });
@ -216,8 +216,8 @@ export class ProjectStore implements IProjectStore {
* @param projectId * @param projectId
* @returns string * @returns string
*/ */
getProjectIdentifierById = computedFn((projectId: string) => { getProjectIdentifierById = computedFn((projectId: string | undefined | null) => {
const projectInfo = this.projectMap?.[projectId]; const projectInfo = this.projectMap?.[projectId ?? ""];
return projectInfo?.identifier; return projectInfo?.identifier;
}); });

View File

@ -21,8 +21,8 @@ export interface IStateStore {
projectStates: IState[] | undefined; projectStates: IState[] | undefined;
groupedProjectStates: Record<string, IState[]> | undefined; groupedProjectStates: Record<string, IState[]> | undefined;
// computed actions // computed actions
getStateById: (stateId: string) => IState | undefined; getStateById: (stateId: string | null | undefined) => IState | undefined;
getProjectStates: (projectId: string) => IState[] | undefined; getProjectStates: (projectId: string | null | undefined) => IState[] | undefined;
// fetch actions // fetch actions
fetchProjectStates: (workspaceSlug: string, projectId: string) => Promise<IState[]>; fetchProjectStates: (workspaceSlug: string, projectId: string) => Promise<IState[]>;
fetchWorkspaceStates: (workspaceSlug: string) => Promise<IState[]>; fetchWorkspaceStates: (workspaceSlug: string) => Promise<IState[]>;
@ -105,8 +105,8 @@ export class StateStore implements IStateStore {
* @description returns state details using state id * @description returns state details using state id
* @param stateId * @param stateId
*/ */
getStateById = computedFn((stateId: string) => { getStateById = computedFn((stateId: string | null | undefined) => {
if (!this.stateMap) return; if (!this.stateMap || !stateId) return;
return this.stateMap[stateId] ?? undefined; return this.stateMap[stateId] ?? undefined;
}); });
@ -115,7 +115,7 @@ export class StateStore implements IStateStore {
* @param projectId * @param projectId
* @returns IState[] * @returns IState[]
*/ */
getProjectStates = computedFn((projectId: string) => { getProjectStates = computedFn((projectId: string | null | undefined) => {
const workspaceSlug = this.router.workspaceSlug || ""; const workspaceSlug = this.router.workspaceSlug || "";
if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[workspaceSlug])) return; if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[workspaceSlug])) return;
return sortStates(Object.values(this.stateMap).filter((state) => state.project_id === projectId)); return sortStates(Object.values(this.stateMap).filter((state) => state.project_id === projectId));