This commit is contained in:
KM Koushik
2025-09-10 22:36:39 +10:00
parent 0817b0c7a5
commit 1ae6257c11
4 changed files with 30 additions and 23 deletions
@@ -33,8 +33,7 @@ import {
SelectItem,
SelectTrigger,
SelectValue,
} from "@unsend/ui/src/select";
} from "@usesend/ui/src/select";
const apiKeySchema = z.object({
name: z.string({ required_error: "Name is required" }).min(1, {
@@ -49,7 +48,7 @@ export default function AddApiKey() {
const createApiKeyMutation = api.apiKey.createToken.useMutation();
const [isCopied, setIsCopied] = useState(false);
const [showApiKey, setShowApiKey] = useState(false);
const domainsQuery = api.domain.domains.useQuery();
const utils = api.useUtils();
@@ -67,7 +66,8 @@ export default function AddApiKey() {
{
name: values.name,
permission: "FULL",
domainId: values.domainId === "all" ? undefined : Number(values.domainId),
domainId:
values.domainId === "all" ? undefined : Number(values.domainId),
},
{
onSuccess: (data) => {
@@ -75,7 +75,7 @@ export default function AddApiKey() {
setApiKey(data);
apiKeyForm.reset();
},
},
}
);
}
@@ -199,7 +199,10 @@ export default function AddApiKey() {
render={({ field }) => (
<FormItem>
<FormLabel>Domain access</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<Select
onValueChange={field.onChange}
defaultValue={field.value}
>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="Select domain access" />
@@ -207,11 +210,16 @@ export default function AddApiKey() {
</FormControl>
<SelectContent>
<SelectItem value="all">All Domains</SelectItem>
{domainsQuery.data?.map((domain: { id: number; name: string }) => (
<SelectItem key={domain.id} value={domain.id.toString()}>
{domain.name}
</SelectItem>
))}
{domainsQuery.data?.map(
(domain: { id: number; name: string }) => (
<SelectItem
key={domain.id}
value={domain.id.toString()}
>
{domain.name}
</SelectItem>
)
)}
</SelectContent>
</Select>
<FormDescription>