|
|
@ -1,10 +1,8 @@ |
|
|
|
import { CheckIcon, CircleDashed, CopyIcon, X } from 'lucide-react'; |
|
|
|
import { CheckIcon, CopyIcon, X } from 'lucide-react'; |
|
|
|
import { Modal } from '../Modal'; |
|
|
|
import { Modal } from '../Modal'; |
|
|
|
import { useState, type FormEvent, type ReactNode } from 'react'; |
|
|
|
import { type FormEvent, useState } from 'react'; |
|
|
|
import { useToast } from '../../hooks/use-toast'; |
|
|
|
|
|
|
|
import { httpPost } from '../../lib/http'; |
|
|
|
import { httpPost } from '../../lib/http'; |
|
|
|
import { GitHubIcon } from '../ReactIcons/GitHubIcon.tsx'; |
|
|
|
import { GitHubIcon } from '../ReactIcons/GitHubIcon.tsx'; |
|
|
|
import { cn } from '../../lib/classname.ts'; |
|
|
|
|
|
|
|
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'; |
|
|
|
|
|
|
|
|
|
|
@ -165,6 +163,12 @@ export function SubmitProjectModal(props: SubmitProjectModalProps) { |
|
|
|
throw new Error('Add the project page URL to the readme file'); |
|
|
|
throw new Error('Add the project page URL to the readme file'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setVerificationChecks({ |
|
|
|
|
|
|
|
repositoryExists: 'success', |
|
|
|
|
|
|
|
readmeExists: 'success', |
|
|
|
|
|
|
|
projectUrlExists: 'success', |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
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 } = |
|
|
|
await httpPost<SubmitProjectResponse>(submitProjectUrl, { |
|
|
|
await httpPost<SubmitProjectResponse>(submitProjectUrl, { |
|
|
@ -172,10 +176,12 @@ export function SubmitProjectModal(props: SubmitProjectModalProps) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (error || !submitResponse) { |
|
|
|
if (error || !submitResponse) { |
|
|
|
throw new Error(error?.message || 'Failed to submit project'); |
|
|
|
throw new Error( |
|
|
|
|
|
|
|
error?.message || 'Error submitting project. Please try again!', |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setSuccessMessage('Repository verified successfully'); |
|
|
|
setSuccessMessage('Solution submitted successfully!'); |
|
|
|
setIsLoading(false); |
|
|
|
setIsLoading(false); |
|
|
|
|
|
|
|
|
|
|
|
onSubmit(submitResponse); |
|
|
|
onSubmit(submitResponse); |
|
|
@ -196,13 +202,22 @@ export function SubmitProjectModal(props: SubmitProjectModalProps) { |
|
|
|
</p> |
|
|
|
</p> |
|
|
|
|
|
|
|
|
|
|
|
<div className="my-4 flex flex-col gap-1"> |
|
|
|
<div className="my-4 flex flex-col gap-1"> |
|
|
|
<SubmissionRequirement status={verificationChecks.repositoryExists}> |
|
|
|
<SubmissionRequirement |
|
|
|
|
|
|
|
isLoading={isLoading} |
|
|
|
|
|
|
|
status={verificationChecks.repositoryExists} |
|
|
|
|
|
|
|
> |
|
|
|
URL must point to a public GitHub repository |
|
|
|
URL must point to a public GitHub repository |
|
|
|
</SubmissionRequirement> |
|
|
|
</SubmissionRequirement> |
|
|
|
<SubmissionRequirement status={verificationChecks.readmeExists}> |
|
|
|
<SubmissionRequirement |
|
|
|
|
|
|
|
isLoading={isLoading} |
|
|
|
|
|
|
|
status={verificationChecks.readmeExists} |
|
|
|
|
|
|
|
> |
|
|
|
Repository must contain a README file |
|
|
|
Repository must contain a README file |
|
|
|
</SubmissionRequirement> |
|
|
|
</SubmissionRequirement> |
|
|
|
<SubmissionRequirement status={verificationChecks.projectUrlExists}> |
|
|
|
<SubmissionRequirement |
|
|
|
|
|
|
|
isLoading={isLoading} |
|
|
|
|
|
|
|
status={verificationChecks.projectUrlExists} |
|
|
|
|
|
|
|
> |
|
|
|
README file must contain the{' '} |
|
|
|
README file must contain the{' '} |
|
|
|
<button |
|
|
|
<button |
|
|
|
className={ |
|
|
|
className={ |
|
|
@ -243,6 +258,13 @@ export function SubmitProjectModal(props: SubmitProjectModalProps) { |
|
|
|
onChange={(e) => setRepoUrl(e.target.value)} |
|
|
|
onChange={(e) => setRepoUrl(e.target.value)} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<button |
|
|
|
|
|
|
|
type="submit" |
|
|
|
|
|
|
|
className="mt-2 w-full rounded-lg bg-black p-2 font-medium text-white disabled:opacity-50" |
|
|
|
|
|
|
|
disabled={isLoading} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{isLoading ? 'Verifying...' : 'Verify and Submit'} |
|
|
|
|
|
|
|
</button> |
|
|
|
{error && ( |
|
|
|
{error && ( |
|
|
|
<p className="mt-2 text-sm font-medium text-red-500">{error}</p> |
|
|
|
<p className="mt-2 text-sm font-medium text-red-500">{error}</p> |
|
|
|
)} |
|
|
|
)} |
|
|
@ -252,14 +274,6 @@ export function SubmitProjectModal(props: SubmitProjectModalProps) { |
|
|
|
{successMessage} |
|
|
|
{successMessage} |
|
|
|
</p> |
|
|
|
</p> |
|
|
|
)} |
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
<button |
|
|
|
|
|
|
|
type="submit" |
|
|
|
|
|
|
|
className="mt-2 w-full rounded-lg bg-black p-2 font-medium text-white disabled:opacity-50" |
|
|
|
|
|
|
|
disabled={isLoading} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{isLoading ? 'Verifying...' : 'Verify Submission'} |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
</form> |
|
|
|
</form> |
|
|
|
|
|
|
|
|
|
|
|
<button |
|
|
|
<button |
|
|
|