Skip to content

Commit

Permalink
Merge pull request #120 from frontend-park-mail-ru/NM-119
Browse files Browse the repository at this point in the history
NM-119: defer csat window
  • Loading branch information
daronenko authored Dec 20, 2024
2 parents 6e23708 + 59ee040 commit c7d31b1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
33 changes: 25 additions & 8 deletions src/entities/csat/model/store.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
import { Storage } from '../../../shared/lib/storage.js';

class CSATStore {
constructor() {
constructor(firstShow = 5, showInterval = 30) {
this.storage = {
csat: Storage.load('csat') || {},
};
this.callCount = this.storage.csat?.callCount || 0;

this.firstShow = firstShow;
this.showInterval = showInterval;
}

submitted = () => {
submitted = () => {
return this.storage.csat?.submitted;
};

submit = () => {
this.storage.csat = {
submitted: true,
};
Storage.save('csat', this.storage.csat);
};
submit = () => {
this.storage.csat = {
submitted: true,
callCount: this.callCount,
};
Storage.save('csat', this.storage.csat);
};

shouldShow = () => {
this.callCount += 1;

this.storage.csat.callCount = this.callCount;
Storage.save('csat', this.storage.csat);

if (this.callCount === this.firstShow || (this.callCount - this.firstShow) % this.showInterval === 0) {
return true;
}
return false;
};
}

export const csatStore = new CSATStore();
2 changes: 1 addition & 1 deletion src/pages/feed/ui/Feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class FeedPage {

this.parent.innerHTML = "";

if (!csatStore.submitted()) {
if (csatStore.shouldShow()) {
const iframe = new CSATWindow();
await iframe.render();
}
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/csatWindow/ui/csatWindow.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ input {
//font-family: 'Sansation', sans-serif;

&__container {
width: 80%;
width: 75%;
height: 80%;
max-width: 400px;
max-height: 200px;
margin: auto;
margin: 10;
padding: 20px;
border: 1px solid colors.$white;
border-radius: 10px;
Expand Down

0 comments on commit c7d31b1

Please sign in to comment.