1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-06-03 16:15:03 +02:00

put limit on file mode creations in free plan

This commit is contained in:
Kushagra Gour 2019-03-08 16:36:49 +05:30
parent cd486fc3ba
commit 02b9e56562
2 changed files with 18 additions and 2 deletions

View File

@ -1351,8 +1351,16 @@ export default class App extends Component {
this.setState({ isCreateNewModalOpen: false });
}
blankFileTemplateSelectHandler() {
this.createNewItem(true);
this.setState({ isCreateNewModalOpen: false });
itemService.getCountOfFileModeItems().then(count => {
if (count < 2) {
this.createNewItem(true);
this.setState({ isCreateNewModalOpen: false });
} else {
return alert(
'"Files mode" is currently in beta and is limited to only 2 creations per user. You have already made 2 creations in Files mode.\n\nNote: You can choose to delete old ones to create new.'
);
}
});
}
templateSelectHandler(template) {

View File

@ -253,5 +253,13 @@ export const itemService = {
log(`Item ${itemId} unset for user`, arg);
})
.catch(error => log(error));
},
async getCountOfFileModeItems() {
const items = await this.getAllItems();
return items.reduce((count, item) => {
if (item.files) return ++count;
return count;
}, 0);
}
};