forked from cerc-io/snowballtools-base
🔧 chore: reskin with shared components
This commit is contained in:
parent
0b64ccc364
commit
6e653774be
@ -1,15 +1,23 @@
|
|||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import { useForm, Controller, SubmitHandler } from 'react-hook-form';
|
import { useForm, SubmitHandler } from 'react-hook-form';
|
||||||
import { useNavigate, useOutletContext, useParams } from 'react-router-dom';
|
import { useNavigate, useOutletContext, useParams } from 'react-router-dom';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
|
|
||||||
import { Button, Option, Typography } from '@material-tailwind/react';
|
|
||||||
|
|
||||||
import { useOctokit } from '../../../../../context/OctokitContext';
|
import { useOctokit } from '../../../../../context/OctokitContext';
|
||||||
import { useGQLClient } from '../../../../../context/GQLClientContext';
|
import { useGQLClient } from '../../../../../context/GQLClientContext';
|
||||||
import AsyncSelect from '../../../../../components/shared/AsyncSelect';
|
|
||||||
import { Template } from '../../../../../types';
|
import { Template } from '../../../../../types';
|
||||||
|
import { Heading } from 'components/shared/Heading';
|
||||||
|
import { Input } from 'components/shared/Input';
|
||||||
|
import { Radio } from 'components/shared/Radio';
|
||||||
|
import { Select } from 'components/shared/Select';
|
||||||
|
import {
|
||||||
|
ArrowRightCircleFilledIcon,
|
||||||
|
GitIcon,
|
||||||
|
GitTeaIcon,
|
||||||
|
} from 'components/shared/CustomIcon';
|
||||||
|
import { Checkbox } from 'components/shared/Checkbox';
|
||||||
|
import { Button } from 'components/shared/Button';
|
||||||
|
|
||||||
type SubmitRepoValues = {
|
type SubmitRepoValues = {
|
||||||
framework: string;
|
framework: string;
|
||||||
@ -30,6 +38,19 @@ const CreateRepo = () => {
|
|||||||
const [gitAccounts, setGitAccounts] = useState<string[]>([]);
|
const [gitAccounts, setGitAccounts] = useState<string[]>([]);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
const FRAMEWORK_OPTIONS = [
|
||||||
|
{
|
||||||
|
value: 'react-native',
|
||||||
|
label: 'React Native',
|
||||||
|
leftIcon: <GitIcon />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'expo',
|
||||||
|
label: 'Expo',
|
||||||
|
leftIcon: <GitTeaIcon />,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const submitRepoHandler: SubmitHandler<SubmitRepoValues> = useCallback(
|
const submitRepoHandler: SubmitHandler<SubmitRepoValues> = useCallback(
|
||||||
async (data) => {
|
async (data) => {
|
||||||
assert(data.account);
|
assert(data.account);
|
||||||
@ -93,7 +114,7 @@ const CreateRepo = () => {
|
|||||||
fetchUserAndOrgs();
|
fetchUserAndOrgs();
|
||||||
}, [octokit]);
|
}, [octokit]);
|
||||||
|
|
||||||
const { register, handleSubmit, control, reset } = useForm<SubmitRepoValues>({
|
const { handleSubmit, reset } = useForm<SubmitRepoValues>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
framework: 'React',
|
framework: 'React',
|
||||||
repoName: '',
|
repoName: '',
|
||||||
@ -110,87 +131,50 @@ const CreateRepo = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit(submitRepoHandler)}>
|
<form onSubmit={handleSubmit(submitRepoHandler)}>
|
||||||
<div className="mb-2">
|
<div className="flex flex-col gap-4 lg:gap-7 w-full">
|
||||||
<Typography variant="h6" placeholder={''}>
|
<div>
|
||||||
Create a repository
|
<Heading className="text-lg font-medium">Create a repository</Heading>
|
||||||
</Typography>
|
<Heading className="text-sm text-elements-low-em">
|
||||||
<Typography color="gray" placeholder={''}>
|
|
||||||
The project will be cloned into this repository
|
The project will be cloned into this repository
|
||||||
</Typography>
|
</Heading>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-2">
|
<div className="flex flex-col justify-start gap-3">
|
||||||
<h5>Framework</h5>
|
<Heading className="text-sm">Framework</Heading>
|
||||||
<div className="flex items-center gap-2">
|
<Radio
|
||||||
<label className="inline-flex items-center w-1/2 border rounded-lg p-2">
|
variant="card"
|
||||||
<input
|
options={FRAMEWORK_OPTIONS}
|
||||||
type="radio"
|
orientation="horizontal"
|
||||||
{...register('framework')}
|
|
||||||
value="React"
|
|
||||||
className="h-5 w-5 text-indigo-600 rounded"
|
|
||||||
/>
|
/>
|
||||||
<span className="ml-2">^React</span>
|
</div>
|
||||||
</label>
|
<div className="flex flex-col justify-start gap-3">
|
||||||
<label className="inline-flex items-center w-1/2 border rounded-lg p-2">
|
<Heading className="text-sm">Git account</Heading>
|
||||||
<input
|
<Select
|
||||||
type="radio"
|
options={
|
||||||
{...register('framework')}
|
gitAccounts.map((account) => ({
|
||||||
className="h-5 w-5 text-indigo-600 rounded"
|
value: account,
|
||||||
value="Next"
|
label: account,
|
||||||
|
})) ?? []
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<span className="ml-2">^Next</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex flex-col justify-start gap-3">
|
||||||
|
<Heading className="text-sm">Name the repo</Heading>
|
||||||
|
<Input />
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-2">
|
|
||||||
<h5>Git account</h5>
|
|
||||||
<div>
|
<div>
|
||||||
<Controller
|
<Checkbox label="Make this repo private" value={'private-repo'} />
|
||||||
name="account"
|
|
||||||
control={control}
|
|
||||||
render={({ field }) => (
|
|
||||||
<AsyncSelect {...field}>
|
|
||||||
{gitAccounts.map((account, key) => (
|
|
||||||
<Option key={key} value={account}>
|
|
||||||
^ {account}
|
|
||||||
</Option>
|
|
||||||
))}
|
|
||||||
</AsyncSelect>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div className="mb-2">
|
|
||||||
<h5>Name the repo</h5>
|
|
||||||
<div>
|
<div>
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="border border-gray-300 rounded p-2 w-full focus:border-blue-300 focus:outline-none focus:shadow-outline-blue"
|
|
||||||
placeholder=""
|
|
||||||
{...register('repoName')}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mb-2">
|
|
||||||
<label className="inline-flex items-center">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
className="h-5 w-5 text-indigo-600 rounded"
|
|
||||||
{...register('isPrivate')}
|
|
||||||
/>
|
|
||||||
<span className="ml-2">Make this repo private</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div className="mb-2">
|
|
||||||
<Button
|
<Button
|
||||||
className="bg-blue-500 rounded-xl p-2"
|
|
||||||
type="submit"
|
type="submit"
|
||||||
|
size="lg"
|
||||||
disabled={!Boolean(template.repoFullName) || isLoading}
|
disabled={!Boolean(template.repoFullName) || isLoading}
|
||||||
loading={isLoading}
|
rightIcon={<ArrowRightCircleFilledIcon />}
|
||||||
placeholder={''}
|
|
||||||
>
|
>
|
||||||
Deploy ^
|
Deploy
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user