|
|
@ -6,12 +6,15 @@ import { httpPost } from '../../lib/http'; |
|
|
|
import { GitHubIcon } from '../ReactIcons/GitHubIcon.tsx'; |
|
|
|
import { GitHubIcon } from '../ReactIcons/GitHubIcon.tsx'; |
|
|
|
import { SubmissionRequirement } from './SubmissionRequirement.tsx'; |
|
|
|
import { SubmissionRequirement } from './SubmissionRequirement.tsx'; |
|
|
|
import { useCopyText } from '../../hooks/use-copy-text.ts'; |
|
|
|
import { useCopyText } from '../../hooks/use-copy-text.ts'; |
|
|
|
|
|
|
|
import { getTopGitHubLanguages } from '../../lib/github.ts'; |
|
|
|
|
|
|
|
|
|
|
|
type SubmitProjectResponse = { |
|
|
|
type SubmitProjectResponse = { |
|
|
|
repositoryUrl: string; |
|
|
|
repositoryUrl: string; |
|
|
|
submittedAt: Date; |
|
|
|
submittedAt: Date; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type GitHubApiLanguagesResponse = Record<string, number>; |
|
|
|
|
|
|
|
|
|
|
|
type VerificationChecksType = { |
|
|
|
type VerificationChecksType = { |
|
|
|
repositoryExists: 'pending' | 'success' | 'error'; |
|
|
|
repositoryExists: 'pending' | 'success' | 'error'; |
|
|
|
readmeExists: 'pending' | 'success' | 'error'; |
|
|
|
readmeExists: 'pending' | 'success' | 'error'; |
|
|
@ -170,13 +173,17 @@ export function SubmitProjectModal(props: SubmitProjectModalProps) { |
|
|
|
projectUrlExists: 'success', |
|
|
|
projectUrlExists: 'success', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const languagesUrl = `${mainApiUrl}/languages`; |
|
|
|
const languagesResponse = await fetch(`${mainApiUrl}/languages`); |
|
|
|
const languagesResponse = await fetch(languagesUrl); |
|
|
|
|
|
|
|
let languages: string[] = []; |
|
|
|
let languages: string[] = []; |
|
|
|
if (languagesResponse.ok) { |
|
|
|
if (languagesResponse.ok) { |
|
|
|
const languagesData = await languagesResponse.json(); |
|
|
|
const languagesData = |
|
|
|
|
|
|
|
(await languagesResponse.json()) as GitHubApiLanguagesResponse; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages = getTopGitHubLanguages(languagesData); |
|
|
|
|
|
|
|
if (languages?.length === 0) { |
|
|
|
languages = Object.keys(languagesData || {})?.slice(0, 4); |
|
|
|
languages = Object.keys(languagesData || {})?.slice(0, 4); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const submitProjectUrl = `${import.meta.env.PUBLIC_API_URL}/v1-submit-project/${projectId}`; |
|
|
|
const submitProjectUrl = `${import.meta.env.PUBLIC_API_URL}/v1-submit-project/${projectId}`; |
|
|
|
const { response: submitResponse, error } = |
|
|
|
const { response: submitResponse, error } = |
|
|
|