({
orgs,
project_id,
project_name,
org_name,
isEdit,
handleModalClose,
lockedOrgId,
}: {
orgs: IOrg[];
project_id?: string;
project_name?: string;
org_name?: string;
isEdit: boolean;
handleModalClose: () => void;
lockedOrgId?: string;
})
| 29 | import { UpsellModal } from './upsell-modal'; |
| 30 | |
| 31 | export const ProjectDetails = ({ |
| 32 | orgs, |
| 33 | project_id, |
| 34 | project_name, |
| 35 | org_name, |
| 36 | isEdit, |
| 37 | handleModalClose, |
| 38 | lockedOrgId, |
| 39 | }: { |
| 40 | orgs: IOrg[]; |
| 41 | project_id?: string; |
| 42 | project_name?: string; |
| 43 | org_name?: string; |
| 44 | isEdit: boolean; |
| 45 | handleModalClose: () => void; |
| 46 | lockedOrgId?: string; |
| 47 | }) => { |
| 48 | const queryClient = useQueryClient(); |
| 49 | const initialOrgId = lockedOrgId |
| 50 | ? lockedOrgId |
| 51 | : isEdit |
| 52 | ? (orgs.find((o) => o.name === org_name)?.id ?? (orgs.length > 0 ? orgs[0].id : '')) |
| 53 | : orgs.length > 0 |
| 54 | ? orgs[0].id |
| 55 | : ''; |
| 56 | const [projectName, setProjectName] = useState(isEdit ? project_name : 'New Project'); |
| 57 | const [selectedOrgId, setSelectedOrgId] = useState<string>(initialOrgId); |
| 58 | |
| 59 | type RenameMutationResponse = IProject; |
| 60 | type RenameMutationResult = UseMutationResult< |
| 61 | RenameMutationResponse, |
| 62 | Error, |
| 63 | RenameProjectPayload, |
| 64 | unknown |
| 65 | >; |
| 66 | |
| 67 | type CreateMutationResult = UseMutationResult<IProject, Error, CreateProjectPayload, unknown>; |
| 68 | |
| 69 | const createProjectMutation: CreateMutationResult = useMutation({ |
| 70 | mutationFn: createProjectAPI, |
| 71 | onSuccess: (createdProject) => { |
| 72 | queryClient.invalidateQueries({ queryKey: projectsQueryKey }); |
| 73 | toast({ title: 'Project Created', description: `Created ${createdProject.name}` }); |
| 74 | handleModalClose(); |
| 75 | if (typeof window !== 'undefined') { |
| 76 | navigator.clipboard |
| 77 | .writeText(createdProject.api_key) |
| 78 | .then(() => |
| 79 | toast({ |
| 80 | title: 'API Key Copied', |
| 81 | description: `Copied API key for ${createdProject.name}`, |
| 82 | }), |
| 83 | ) |
| 84 | .catch(() => |
| 85 | toast({ title: '❌ Manually copy API Key:', description: createdProject.api_key }), |
| 86 | ); |
| 87 | } |
| 88 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…