fix
This commit is contained in:
@@ -216,7 +216,7 @@ model ApiKey {
|
||||
lastUsed DateTime?
|
||||
teamId Int
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
domain Domain? @relation(fields: [domainId], references: [id], onDelete: Cascade)
|
||||
domain Domain? @relation(fields: [domainId], references: [id], onDelete: SetNull, onUpdate: Cascade)
|
||||
}
|
||||
|
||||
enum EmailStatus {
|
||||
|
@@ -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>
|
||||
|
@@ -60,17 +60,12 @@ function send(app: PublicAPIApp) {
|
||||
const team = c.var.team;
|
||||
const emailId = c.req.param("emailId");
|
||||
|
||||
const whereClause: { id: string; teamId: number; domainId?: number } = {
|
||||
id: emailId,
|
||||
teamId: team.id,
|
||||
};
|
||||
|
||||
if (team.apiKey.domainId !== null) {
|
||||
whereClause.domainId = team.apiKey.domainId;
|
||||
}
|
||||
|
||||
const email = await db.email.findUnique({
|
||||
where: whereClause,
|
||||
where: {
|
||||
id: emailId,
|
||||
teamId: team.id,
|
||||
domainId: team.apiKey.domainId ?? undefined,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
teamId: true,
|
||||
|
@@ -48,7 +48,11 @@ function updateEmailScheduledAt(app: PublicAPIApp) {
|
||||
const team = c.var.team;
|
||||
const emailId = c.req.param("emailId");
|
||||
|
||||
await checkIsValidEmailIdWithDomainRestriction(emailId, team.id, team.apiKey.domainId);
|
||||
await checkIsValidEmailIdWithDomainRestriction(
|
||||
emailId,
|
||||
team.id,
|
||||
team.apiKey.domainId ?? undefined
|
||||
);
|
||||
|
||||
await updateEmail(emailId, {
|
||||
scheduledAt: c.req.valid("json").scheduledAt,
|
||||
|
Reference in New Issue
Block a user