2024-09-06 16:21:14 +05:30
|
|
|
"use client";
|
2025-10-14 16:45:07 +05:30
|
|
|
import type { FC } from "react";
|
2024-08-12 18:24:42 +05:30
|
|
|
import { Controller, useFormContext } from "react-hook-form";
|
2025-08-15 13:10:26 +05:30
|
|
|
// plane imports
|
2025-02-06 20:41:31 +05:30
|
|
|
import { NETWORK_CHOICES, ETabIndices } from "@plane/constants";
|
2025-01-03 14:16:26 +05:30
|
|
|
import { useTranslation } from "@plane/i18n";
|
2025-10-14 16:45:07 +05:30
|
|
|
import type { IProject } from "@plane/types";
|
2024-08-12 18:24:42 +05:30
|
|
|
import { CustomSelect } from "@plane/ui";
|
2025-06-16 17:18:41 +05:30
|
|
|
import { getTabIndex } from "@plane/utils";
|
2025-08-15 13:10:26 +05:30
|
|
|
// components
|
|
|
|
|
import { MemberDropdown } from "@/components/dropdowns/member/dropdown";
|
|
|
|
|
import { ProjectNetworkIcon } from "@/components/project/project-network-icon";
|
2024-08-12 18:24:42 +05:30
|
|
|
|
2024-09-06 16:21:14 +05:30
|
|
|
type Props = {
|
|
|
|
|
isMobile?: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ProjectAttributes: FC<Props> = (props) => {
|
|
|
|
|
const { isMobile = false } = props;
|
2025-01-03 14:16:26 +05:30
|
|
|
const { t } = useTranslation();
|
2024-08-12 18:24:42 +05:30
|
|
|
const { control } = useFormContext<IProject>();
|
2024-09-06 16:21:14 +05:30
|
|
|
const { getIndex } = getTabIndex(ETabIndices.PROJECT_CREATE, isMobile);
|
2024-08-12 18:24:42 +05:30
|
|
|
return (
|
|
|
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
|
|
|
<Controller
|
|
|
|
|
name="network"
|
|
|
|
|
control={control}
|
|
|
|
|
render={({ field: { onChange, value } }) => {
|
|
|
|
|
const currentNetwork = NETWORK_CHOICES.find((n) => n.key === value);
|
|
|
|
|
|
|
|
|
|
return (
|
2024-09-06 16:21:14 +05:30
|
|
|
<div className="flex-shrink-0 h-7" tabIndex={getIndex("network")}>
|
2024-08-12 18:24:42 +05:30
|
|
|
<CustomSelect
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={onChange}
|
|
|
|
|
label={
|
|
|
|
|
<div className="flex items-center gap-1 h-full">
|
|
|
|
|
{currentNetwork ? (
|
|
|
|
|
<>
|
2025-02-06 20:41:31 +05:30
|
|
|
<ProjectNetworkIcon iconKey={currentNetwork.iconKey} />
|
|
|
|
|
{t(currentNetwork.i18n_label)}
|
2024-08-12 18:24:42 +05:30
|
|
|
</>
|
|
|
|
|
) : (
|
2025-01-03 14:16:26 +05:30
|
|
|
<span className="text-custom-text-400">{t("select_network")}</span>
|
2024-08-12 18:24:42 +05:30
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
placement="bottom-start"
|
|
|
|
|
className="h-full"
|
|
|
|
|
buttonClassName="h-full"
|
|
|
|
|
noChevron
|
2024-09-06 16:21:14 +05:30
|
|
|
tabIndex={getIndex("network")}
|
2024-08-12 18:24:42 +05:30
|
|
|
>
|
|
|
|
|
{NETWORK_CHOICES.map((network) => (
|
|
|
|
|
<CustomSelect.Option key={network.key} value={network.key}>
|
|
|
|
|
<div className="flex items-start gap-2">
|
2025-02-06 20:41:31 +05:30
|
|
|
<ProjectNetworkIcon iconKey={network.iconKey} className="h-3.5 w-3.5" />
|
2024-08-12 18:24:42 +05:30
|
|
|
<div className="-mt-1">
|
2025-02-06 20:41:31 +05:30
|
|
|
<p>{t(network.i18n_label)}</p>
|
|
|
|
|
<p className="text-xs text-custom-text-400">{t(network.description)}</p>
|
2024-08-12 18:24:42 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</CustomSelect.Option>
|
|
|
|
|
))}
|
|
|
|
|
</CustomSelect>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Controller
|
|
|
|
|
name="project_lead"
|
|
|
|
|
control={control}
|
|
|
|
|
render={({ field: { value, onChange } }) => {
|
|
|
|
|
if (value === undefined || value === null || typeof value === "string")
|
|
|
|
|
return (
|
2024-09-06 16:21:14 +05:30
|
|
|
<div className="flex-shrink-0 h-7" tabIndex={getIndex("lead")}>
|
2024-08-12 18:24:42 +05:30
|
|
|
<MemberDropdown
|
2025-02-04 16:02:07 +05:30
|
|
|
value={value ?? null}
|
2024-08-12 18:24:42 +05:30
|
|
|
onChange={(lead) => onChange(lead === value ? null : lead)}
|
2025-01-03 14:16:26 +05:30
|
|
|
placeholder={t("lead")}
|
2024-08-12 18:24:42 +05:30
|
|
|
multiple={false}
|
|
|
|
|
buttonVariant="border-with-text"
|
|
|
|
|
tabIndex={5}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
else return <></>;
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ProjectAttributes;
|