Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #343 from erxes/meeting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wlkr123 authored Sep 27, 2023
2 parents 8fd1932 + 83395e6 commit feb7098
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@ const pinnedUserMutations = {
// /**
// * Creates a new pinnedUser
// */
async meetingPinnedUserAdd(
_root,
{ pinnedUserIds },
{ models, user }: IContext
) {
return await models.PinnedUsers.createPinnedUser(pinnedUserIds, user);
},

// /**
// * Edits a pinnedUser
// */
async meetingPinnedUserEdit(
async meetingPinnedUserUpdate(
_root,
{ pinnedUserIds },
{ models, user }: IContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ const params = `
pinnedUserIds: [String]
`;
export const mutations = `
meetingPinnedUserAdd(${params}): PinnedUsers
meetingPinnedUserEdit(${params}): PinnedUsers
meetingPinnedUserUpdate(${params}): PinnedUsers
`;

export const queries = `
Expand Down
24 changes: 10 additions & 14 deletions packages/plugin-meetings-api/src/models/pinnedUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import {
import { checkLogin } from '@erxes/api-utils/src';

export interface IPinnedUserModel extends Model<IPinnedUserDocument> {
createPinnedUser(
pinnedUserIds: String[],
user: IUser
): Promise<IPinnedUserDocument>;
updatePinnedUser(
pinnedUserIds: String[],
user: IUser
Expand All @@ -20,21 +16,21 @@ export interface IPinnedUserModel extends Model<IPinnedUserDocument> {

export const loadPinnedUserClass = (model: IModels) => {
class PinnedUser {
// create
public static async createPinnedUser(pinnedUserIds, user) {
// update
public static async updatePinnedUser(pinnedUserIds, user) {
const pinnedUsers = await model.PinnedUsers.findOne({ userId: user._id });

if (pinnedUsers) {
return await model.PinnedUsers.updateOne(
{ userId: user._id },
{ $set: { pinnedUserIds } }
).then(err => console.error(err));
}
return await model.PinnedUsers.create({
pinnedUserIds,
userId: user._id
});
}

// update
public static async updatePinnedUser(pinnedUserIds, user) {
return await model.PinnedUsers.updateOne(
{ userId: user._id },
{ $set: { pinnedUserIds } }
).then(err => console.error(err));
}
}

pinnedUserSchema.loadClass(PinnedUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ export const ChooseOwnerFormContainer = (props: Props) => {
}: IButtonMutateProps) => {
return (
<ButtonMutate
mutation={
object && object !== {}
? mutations.editPinnedUser
: mutations.addPinnedUser
}
mutation={mutations.updatePinnedUser}
variables={values}
callback={callback}
isSubmitted={isSubmitted}
Expand Down
17 changes: 4 additions & 13 deletions packages/plugin-meetings-ui/src/graphql/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,9 @@ const editTopic = `
}
`;

const editPinnedUser = `
mutation meetingPinnedUserEdit($pinnedUserIds: [String]) {
meetingPinnedUserEdit(pinnedUserIds: $pinnedUserIds) {
userId
pinnedUserIds
}
}
`;
const addPinnedUser = `
mutation meetingPinnedUserAdd($pinnedUserIds: [String]) {
meetingPinnedUserAdd(pinnedUserIds: $pinnedUserIds) {
const updatePinnedUser = `
mutation meetingPinnedUserUpdate($pinnedUserIds: [String]) {
meetingPinnedUserUpdate(pinnedUserIds: $pinnedUserIds) {
userId
pinnedUserIds
}
Expand All @@ -81,6 +73,5 @@ export default {
remove,
editMeeting,
editMeetingStatus,
editPinnedUser,
addPinnedUser
updatePinnedUser
};

0 comments on commit feb7098

Please sign in to comment.