diff --git a/packages/shared-models/src/lib/projectPin.ts b/packages/shared-models/src/lib/projectPin.ts index 9459de5a..f974af2d 100644 --- a/packages/shared-models/src/lib/projectPin.ts +++ b/packages/shared-models/src/lib/projectPin.ts @@ -6,9 +6,7 @@ const _getPinnedProjectList = async ( uid: string ): Promise => { const user = await mdUserFindFirst({ - where: { - id: uid - } + id: uid }) if (!user) return [] diff --git a/packages/shared-models/src/lib/taskAutomation.ts b/packages/shared-models/src/lib/taskAutomation.ts index 61aaca44..ae58b4cc 100644 --- a/packages/shared-models/src/lib/taskAutomation.ts +++ b/packages/shared-models/src/lib/taskAutomation.ts @@ -13,8 +13,27 @@ export const mdAutomationGet = async (projectId: string) => { } export const mdAutomationPost = async (data: Omit) => { + const { + organizationId, + projectId, + when, + then, + createdAt, + createdBy, + updatedAt, + updatedBy + } = data return taskAutomation.create({ - data + data: { + organizationId, + projectId, + when: when || {}, + then: then || {}, + createdAt, + createdBy, + updatedAt, + updatedBy + } }) } diff --git a/packages/shared-models/src/lib/user.ts b/packages/shared-models/src/lib/user.ts index 9f3e794c..b2479414 100644 --- a/packages/shared-models/src/lib/user.ts +++ b/packages/shared-models/src/lib/user.ts @@ -8,8 +8,10 @@ export const mdUserFindEmail = async (email: string) => { }) } -export const mdUserFindFirst = async cond => { - return userModel.findFirst(cond) +export const mdUserFindFirst = async (cond: { id: string }) => { + return userModel.findFirst({ + where: cond + }) } export const mdUserAdd = async (data: Omit) => { @@ -18,7 +20,10 @@ export const mdUserAdd = async (data: Omit) => { }) } -export const mdUserUpdate = async (id: string, data: Partial>) => { +export const mdUserUpdate = async ( + id: string, + data: Partial> +) => { return userModel.update({ where: { id }, data @@ -30,6 +35,8 @@ export const mdUserUpdateSetting = async (id: string, data: UserSetting) => { where: { id } }) + if (!user) return null + const settings = user.settings as UserSetting return userModel.update({ where: { id },