"use client";
import { useActionState, useState } from "react";
import { Fieldset, FormField, Select } from "@unlocalhosted/metalui";
import { createTokenAction } from "@/app/actions/settings";
import { PlusIcon } from "@/components/icons";
import { RepoChecklist, type RepoOption } from "@/components/repo-checklist";
import { ChoiceCards, CopyIconButton, TextField } from "@/components/settings-fields";
import { PlateBody, PlateFooter } from "@/components/settings-plate";
import { Alert, Button } from "@/components/ui";
const expiries = [
{ value: "7", label: "7 days" },
{ value: "30", label: "30 days" },
{ value: "90", label: "90 days" },
{ value: "365", label: "1 year" },
{ value: "never", label: "No expiration" },
];
export function NewTokenForm({ repos, origin, username }: { repos: RepoOption[]; origin: string; username: string }) {
const [state, action, pending] = useActionState(createTokenAction, undefined);
const [scope, setScope] = useState<"all" | "selected">("all");
const [permission, setPermission] = useState<"read" | "write">("write");
const example = repos[0]?.fullName ?? `${username}/repo`;
if (state?.token) {
return (
<>
Use it with git When git asks for a password, paste the token. Or put it in the remote URL:{state.token}
git clone {origin.replace("://", `://${username}:${state.token}@`)}/{example}.git