Skip to content

Commit

Permalink
update store
Browse files Browse the repository at this point in the history
  • Loading branch information
toanredweb committed Dec 8, 2023
1 parent 565280d commit 2918a12
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import {
AesirxProjectApiService,
AesirxFacebookDataApiService,
AesirxPlanningApiService,
AesirxGroupApiService,
Storage,
} from 'aesirx-lib';

import { ContentConnectedChannelsModel } from '../ContentModel/ContentConnectedChannelsModel';

import ProjectUtils from '../../ProjectsPage/ProjectUtils/ProjectUtils';
import GroupUtils from '../../GroupListPage/GroupListUtils/GroupUtils';

export default class ContentStore {
globalStore = null;
Expand Down Expand Up @@ -192,6 +194,36 @@ export default class ContentStore {
});
}
}
async getGroupItemByGroupId(groupId, callbackOnSuccess, callbackOnError) {
if (!groupId) return false;

try {
const results = true;

if (results) {
const groupAPIService = new AesirxGroupApiService();
const respondedDataFromLibrary = await groupAPIService.getgroupItem(groupId, false);

const groupDataModels = GroupUtils.transformgroupResponseIntoModel([
respondedDataFromLibrary,
]);

if (groupDataModels) {
runInAction(() => {
callbackOnSuccess(groupDataModels);
});
} else {
callbackOnError({
message: 'Something went wrong from Server response',
});
}
}
} catch (error) {
runInAction(() => {
callbackOnError(error);
});
}
}

async getUserAccountDataFromFacebookData(callbackOnSuccess, callbackOnError) {
try {
Expand Down Expand Up @@ -309,6 +341,8 @@ export default class ContentStore {
isForcePersonaMasterData: true,
isForProjectMaster: true,
isForceProjectMasterData: true,
isForGroupMaster: true,
isForceGroupMasterData: true,
});
return result;
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ import { withTranslation } from 'react-i18next';
const GroupList = observer(
class GroupList extends ComponentViewList {
key = GROUP_FIELD_KEY.ID;
view = 'categories';
view = 'group';
handleEdit = (e, row) => {
this.formModalViewModal.getGroup(row.id);
};
_handleList = () => {
this.listViewModel.isList = !this.listViewModel.isList;
};

_handleSort = async (data) => {
this.handleSort(data);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class GroupListViewModel {
}
};

getPagination = (paginationStep, isList, limit = 5) => {
getPagination = (paginationStep, limit = 5) => {
this.pageSize = limit;
this.tableStatus = PAGE_STATUS.LOADING;
if (this.dataFilter !== null) {
Expand Down Expand Up @@ -124,7 +124,7 @@ class GroupListViewModel {
};

callbackOnSuccessHandler = (groupModelData) => {
console.log('groupModelData', groupModelData);

if (groupModelData) {
this.tableStatus = PAGE_STATUS.READY;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class ProjectsListViewModel {
};

callbackOnSuccessHandler = (projectModelData) => {
console.log('projectModelData', projectModelData);
if (projectModelData) {
this.tableStatus = PAGE_STATUS.READY;

Expand Down
32 changes: 32 additions & 0 deletions packages/aesirx-dma-app/src/store/Store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
AesirxCampaignApiService,
AesirxPersonaApiService,
AesirxBillingPlanApiService,
AesirxGroupApiService,
AUTHORIZATION_KEY,
Storage,
} from 'aesirx-lib';
Expand All @@ -18,6 +19,7 @@ class GlobalStore {
personaMasterData = null;
connectedChannelsMasterData = null;
memberFeaturesMasterData = null;
groupMasterData = null;
memberId = Storage.getItem(AUTHORIZATION_KEY.MEMBER_ID) ?? 0;
memberFullName = Storage.getItem(AUTHORIZATION_KEY.MEMBER_FULL_NAME) ?? '';

Expand All @@ -35,6 +37,13 @@ class GlobalStore {
return this.projectMasterData;
}

async getGroupMasterData() {
const groupApiService = new AesirxGroupApiService();
const respondedData = await groupApiService.getGroupMasterData();
this.groupMasterData = respondedData;
return this.groupMasterData;
}

async getConnectedChannelsMasterData() {
const PersonaApiService = new AesirxPersonaApiService();
const respondedData = await PersonaApiService.getConnectedChannelByOrganisationId();
Expand Down Expand Up @@ -64,6 +73,7 @@ class GlobalStore {
personaMasterData: null,
connectedChannelsMasterData: null,
memberFeaturesMasterData: null,
groupMasterData: null,
};

// Project Master Data
Expand All @@ -88,6 +98,28 @@ class GlobalStore {
result.projectMasterData = projectMasterData;
}
}
// Group Master Data
const isForGroupMasterData = args.isForGroupMaster ? args.isForGroupMaster : false;
const isForceGroupMasterData = args.isForceGroupMasterData
? args.isForceGroupMasterData
: false;

if (isForGroupMasterData === true) {
let groupMasterData = null;

if (isForceGroupMasterData) {
groupMasterData = await this.getGroupMasterData();
} else {
groupMasterData = this.groupMasterData
? this.groupMasterData
: await this.getGroupMasterData();
}

// const GroupMasterData = await this.getGroupMasterData();
if (groupMasterData) {
result.groupMasterData = groupMasterData;
}
}

// Campaign Master Data
const isForCampaignMasterData = args.isForCampaignMasterData
Expand Down

0 comments on commit 2918a12

Please sign in to comment.