2023-10-18 07:02:02 +00:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
// components
|
2023-10-18 13:48:01 +00:00
|
|
|
import { StateSelect } from "components/states";
|
2023-10-18 07:02:02 +00:00
|
|
|
// hooks
|
|
|
|
import useSubIssue from "hooks/use-sub-issue";
|
|
|
|
// types
|
|
|
|
import { IIssue, IStateResponse } from "types";
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
issue: IIssue;
|
|
|
|
onChange: (data: Partial<IIssue>) => void;
|
|
|
|
states: IStateResponse | undefined;
|
|
|
|
expandedIssues: string[];
|
|
|
|
disabled: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const SpreadsheetStateColumn: React.FC<Props> = (props) => {
|
|
|
|
const { issue, onChange, states, expandedIssues, disabled } = props;
|
|
|
|
|
|
|
|
const isExpanded = expandedIssues.indexOf(issue.id) > -1;
|
|
|
|
|
|
|
|
const { subIssues, isLoading } = useSubIssue(issue.project_detail.id, issue.id, isExpanded);
|
|
|
|
|
|
|
|
return (
|
2023-10-18 13:48:01 +00:00
|
|
|
<>
|
|
|
|
<StateSelect
|
|
|
|
value={issue.state_detail}
|
2023-10-18 07:02:02 +00:00
|
|
|
onChange={(data) => onChange({ state: data.id, state_detail: data })}
|
2023-10-18 13:48:01 +00:00
|
|
|
stateGroups={states}
|
|
|
|
buttonClassName="!shadow-none !border-0"
|
|
|
|
hideDropdownArrow
|
2023-10-18 07:02:02 +00:00
|
|
|
disabled={disabled}
|
|
|
|
/>
|
|
|
|
|
|
|
|
{isExpanded &&
|
|
|
|
!isLoading &&
|
|
|
|
subIssues &&
|
|
|
|
subIssues.length > 0 &&
|
|
|
|
subIssues.map((subIssue) => (
|
|
|
|
<SpreadsheetStateColumn
|
|
|
|
key={subIssue.id}
|
|
|
|
issue={subIssue}
|
|
|
|
onChange={onChange}
|
|
|
|
states={states}
|
|
|
|
expandedIssues={expandedIssues}
|
|
|
|
disabled={disabled}
|
|
|
|
/>
|
|
|
|
))}
|
2023-10-18 13:48:01 +00:00
|
|
|
</>
|
2023-10-18 07:02:02 +00:00
|
|
|
);
|
|
|
|
};
|