Notes
![]() ![]() Notes - notes.io |
import API from '../api/disclosuresApi';
import handleError from '../utils/handleError';
import appState from './appState';
class StorefrontDisclosures {
searchTypeByEnv = null;
searchTypeByProject = null;
searchTypeInput = null;
selectedRows = {};
tableData = [];
searchTypeOptionsEnv = [];
searchTypeOptionsProjects = [];
isFetching = false;
isRemoveConfirmModalOpen = false;
isCreateConfirmModalOpen = false;
constructor() {
this.appState = appState;
makeAutoObservable(this, {
searchTypeByEnv: observable,
selectedRows: observable,
searchTypeByProject: observable,
searchTypeOptionsEnv: observable,
searchTypeInput: observable,
searchTypeOptionsProjects: observable,
initialize: action,
deleteRows: action,
createEditStorefront: action
});
}
reset() {
runInAction(() => {
this.searchTypeByEnv = null;
this.searchTypeByProject = null;
this.searchTypeInput = null;
this.selectedRows = {};
this.tableData = [];
this.searchTypeOptionsEnv = [];
this.searchTypeOptionsProjects = [];
});
}
updateValue = ({key, value}) => {
this[key] = value;
};
initialize = async () => {
runInAction(() => {
this.isFetching = true;
this.searchTypeByEnv = null;
this.searchTypeByProject = null;
this.searchTypeInput = null;
this.tableData = [];
this.searchTypeOptionsEnv = [];
this.searchTypeOptionsProjects = [];
});
try {
const response = (await API.fetchStorefrontDisclosures()).data || [];
const storefrontEnv = (await API.fetchEnvironmentsStorefront()).data || [];
const srorefrontProjects = (await API.fetchProjectsStorefront()).data || [];
const setProjectValues = srorefrontProjects.map(val => ({value: val.projectId, label: val.projectCode}));
const storefrontEnvValues = storefrontEnv.map(val => ({value: val, label: val}));
const storeFrontList = response.map(res => {
return {
...res,
environment: res.environment,
projectCode: res.projectDetails.map(value => value.projectCode).join(', '),
storefront: res.storefront
};
});
runInAction(() => {
this.tableData = storeFrontList || [];
this.searchTypeOptionsEnv = storefrontEnvValues;
this.searchTypeOptionsProjects = setProjectValues;
this.isFetching = false;
});
} catch (err) {
handleError(err, `Unable to fetch storefront disclosures, please try again.`);
this.isFetching = false;
}
};
async createEditStorefront(params, isCreate) {
try {
if (isCreate) {
(await API.createStorefrontDisclosures(params)).data;
this.appState.handleNotification({
message: `Storefront disclosures successfully added`,
levelType: 'success'
});
} else {
(await API.editStorefrontDisclosures(params)).data;
this.appState.handleNotification({
message: `Storefront disclosures updated sucessfully`,
levelType: 'success'
});
}
const response = (await API.fetchStorefrontDisclosures()).data || [];
const storeFrontList = response.map(res => {
return {
...res,
environment: res.environment,
projectCode: res.projectDetails.map(value => value.projectCode).join(', '),
storefront: res.storefront
};
});
runInAction(() => {
this.tableData = storeFrontList || [];
this.searchTypeByEnv = null;
this.searchTypeInput = null;
this.searchTypeByProject = [];
});
} catch (err) {
handleError(err, `Failed to fetch storefront disclosures for entered input.`);
this.isFetching = false;
}
}
async deleteRows(environment, storefront) {
try {
(await API.deleteStorefrontDisclosures({environment, storefront})).data;
const response = (await API.fetchStorefrontDisclosures()).data || [];
const storeFrontList = response.map(res => {
return {
...res,
environment: res.environment,
projectCode: res.projectDetails.map(value => value.projectCode).join(', '),
storefront: res.storefront
};
});
this.appState.handleNotification({
message: `Storefront disclosures deleted sucessfully`,
levelType: 'success'
});
runInAction(() => {
this.tableData = storeFrontList || [];
});
} catch (err) {
handleError(err, `Failed to delete storefront disclosures`);
this.isFetching = false;
}
}
}
export default new StorefrontDisclosures();
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team