Fix: Check if credentials present
Fix: Request credentials as well
This commit is contained in:
parent
1e306ef1b0
commit
ce8cca8a39
2 changed files with 12 additions and 7 deletions
|
@ -46,18 +46,19 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||
const result = await createEvent(currentUser.credentials[0], evt);
|
||||
|
||||
const hashUID = sha256(JSON.stringify(evt));
|
||||
const referencesToCreate = currentUser.credentials.length == 0 ? [] : [
|
||||
{
|
||||
type: currentUser.credentials[0].type,
|
||||
uid: result.id
|
||||
}
|
||||
];
|
||||
|
||||
await prisma.booking.create({
|
||||
data: {
|
||||
uid: hashUID,
|
||||
userId: currentUser.id,
|
||||
references: {
|
||||
create: [
|
||||
{
|
||||
type: currentUser.credentials[0].type,
|
||||
uid: result.id
|
||||
}
|
||||
]
|
||||
create: referencesToCreate
|
||||
},
|
||||
eventTypeId: eventType.id,
|
||||
|
||||
|
|
|
@ -11,7 +11,11 @@ export default async function handler(req, res) {
|
|||
},
|
||||
select: {
|
||||
id: true,
|
||||
user: true,
|
||||
user: {
|
||||
select: {
|
||||
credentials: true
|
||||
}
|
||||
},
|
||||
attendees: true,
|
||||
references: true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue