'use client'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import type { Project, User, UserProject } from '@prisma/client'; import { UniversalForm } from '../UniversalForm/UniversalForm'; import { customData, editProject, githubSettings, githubTestIssue, ratelimitChange, } from '@/lib/forms/actions'; import { bodyGen, bodyGenNoIdent } from '@/lib/bodyGen'; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from '@/components/ui/breadcrumb'; import GithubRepoChooser from '../GithubRepoChooser/GithubRepoChooser'; import React from 'react'; import Link from 'next/link'; import InviteCodeViewer from '../InviteCodeViewer/InviteCodeViewer'; import ProjectTeamUsers from '../ProjectTeamUsers/ProjectTeamUsers'; import { useSession } from '@/lib/providers/SessionProvider'; export default function ProjectSettings(project: ProjectWithUsers) { const { user } = useSession(); const [ghRepo, setGhRepo] = React.useState(''); const [ghInstallationId, setGhInstallationId] = React.useState(''); const [hasSubmitted, setHasSubmitted] = React.useState(false); const apiUrl = `https://${window.location.hostname}/api/feedback/${project.id}`; React.useEffect(() => { setHasSubmitted(project.github !== ''); }, [project.github]); return (
Dashboard {project.name} Settings

Project Settings

Manage your project configuration and preferences

Project {user?.id === project.UserProject.find((u) => u.isOwner)?.userId && ( Github )} API
Project Details Basic information about your project Custom Data Custom fields to store additional data Your team Invite people to join the project! {/* Project Deletion Permanently delete your project

This action is irreversible. All feedback and settings will be lost.

*/}
{user?.id === project.UserProject.find((u) => u.isOwner)?.userId && ( Github Integration Connect your project to Github { setGhRepo(`https://github.com/${repo}`); setGhInstallationId(id); }} selected={project.github ? project.github.replace('https://github.com/', '') : ''} />

Not the results you were expecting? You may have not allowed your user in the{' '} installation settings .

setHasSubmitted(true)} />
Issue submission testing Make sure your setup works! {hasSubmitted ? ( ) : (

You need to connect your project to a GitHub repository before you can test issue submission.

)}
)} Making a Request Instructions on how to make an API request

Endpoint

{apiUrl}

Method

POST

Body

{bodyGen(project.customData)}

Example Request (cURL)

{stripIndents`curl -X POST \\ -d '${bodyGenNoIdent(project.customData)}' \\ ${apiUrl}`}
Rate limiting Manage your API rate limits.
); } function stripIndents(strings: TemplateStringsArray, ...values: any[]) { const fullString = strings.reduce((accumulator, str, i) => { const value = values[i] ? values[i] : ''; return accumulator + str + value; }, ''); const lines = fullString.split('\n'); // Find minimum indentation level (excluding empty lines) const minIndent = lines .filter((line) => line.trim().length > 0) .reduce((min, line) => { const indent = line.match(/^\s*/)![0].length; return indent < min ? indent : min; }, Infinity); // Apply minimum indent + 2 spaces to each line return lines .map((line) => line.trim()) .map((line) => (line ? ' '.repeat(minIndent + 2) + line : line)) .join('\n') .trim(); } interface ProjectWithUsers extends Project { UserProject: (UserProject & { user: User; })[]; }