{"id":378031,"date":"2024-06-04T21:00:09","date_gmt":"2024-06-04T21:00:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=378031"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-04T21:00:09","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=378031","title":{"rendered":"<span>\u041c\u043e\u0439 \u043e\u043f\u044b\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f frontend \u0438 backend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043c\u043e\u0435\u0433\u043e \u0441\u0442\u0430\u0440\u0442\u0430\u043f\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043a\u0430\u043a \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u0434\u0435\u044f \u0441\u0442\u0430\u0440\u0442\u0430\u043f\u0430, \u043a\u0430\u043a \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u0430\u043a \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f. \u0422\u0430\u043a\u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435  \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0434\u0438\u0437\u0430\u0439\u043d\u0430. \u041d\u0430\u043f\u043e\u043c\u043d\u044e \u0447\u0442\u043e \u044f \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f sass \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b ecwid, \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u0432 \u043e\u0434\u0438\u043d \u043a\u043b\u0438\u043a. \u042f \u0441\u043e\u0437\u0434\u0430\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b ecwid \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0437\u0430 \u043c\u0435\u0441\u044f\u0447\u043d\u0443\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 ($11). \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 Instagram \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b backend &amp; frontend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u044e \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u0435\u0440\u0447\u0430\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c \u0447\u0435\u0440\u0435\u0437 iframe. \u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u043e\u0432\u0430\u0440\u0430\u043c, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0440\u0447\u0430\u043d\u0442 \u043c\u043e\u0433 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u0432\u044b\u0435 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 Instagram.<\/p>\n<h2>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 frontend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0430\u043c\u043e\u043c\u0443, \u0442\u043e \u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u0441 frontend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u044b\u0441\u043e\u043a\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0447\u0442\u043e \u0432 \u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u043c\u043e\u0433 \u0447\u0442\u043e-\u0442\u043e \u0443\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u043c\u043e\u0442\u0440\u044e \u0443\u0434\u043e\u0431\u043d\u043e \u043b\u0438 \u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u044d\u043a\u0435\u043d\u0434\u0430. \u0427\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u043e \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u0432 \u043c\u0430\u043a\u0435\u0442\u0430\u0445 \u043d\u0435 user friendly \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u043c.<\/p>\n<h3>\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h3>\n<p>\u0414\u043b\u044f web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u044d\u043a: ReactJS +TypeScript + Mobx. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u044d\u043a \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u044e \u0435\u0433\u043e. \u0412\u044b\u0431\u0440\u0430\u043b React \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0443 \u043d\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043c\u044c\u044e\u043d\u0438\u0442\u0438 \u0438 \u044f \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u044e \u0435\u0433\u043e. \u0418 \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u044f\u0437\u044b\u043a\u0438 \u0438 \u044d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043f\u0430\u0441\u0430\u0435\u0442 \u043e\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u043f\u043e \u043c\u0435\u0440\u0435 \u0440\u043e\u0441\u0442\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f. \u0422\u0443\u0442 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e\u0442 \u0441\u0442\u044d\u043a \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0435 \u0441\u0435\u0431\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u043e\u0431\u044c\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 \u0441\u043b\u043e\u0438, \u044f \u0437\u0434\u0435\u0441\u044c \u0432\u0438\u0436\u0443 6 \u0441\u043b\u043e\u0451\u0432:<\/p>\n<ul>\n<li>\n<p>routing \u2013 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>models \u2013 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 mobx<\/p>\n<\/li>\n<li>\n<p>pages \u2013 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>ui-kit \u2013 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>components \u2013 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>lib \u2013 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<p><strong>Routing<\/strong><\/p>\n<p>\u041c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0438, \u043d\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c\u0443.<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044f \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Layout, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0412\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Outlet \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 react-router-dom \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"typescript\">import React from \"react\"; import { createBrowserRouter, RouterProvider } from \"react-router-dom\"; import Dashboard from \"@\/pages\/Dashboard\"; import CreateCampaign from \"@\/pages\/Campaign\/CreateCampaign\"; import EditCampaign from \"@\/pages\/Campaign\/EditCampaign\"; import Layout from \"@\/components\/Layout\";  const router = createBrowserRouter([ { path: \"\/\", element: &lt;Layout \/>, children: [ { path: \"\/\", element: &lt;Dashboard \/> }, { path: \"\/campaign\", element: null, children: [ { path: \"\/campaign\/create\", element: &lt;CreateCampaign \/> }, { path: \"\/campaign\/edit\/:id\", element: &lt;EditCampaign \/> }, ], }, ], }, ]);  export default function Router() { return &lt;RouterProvider router={router} \/>; }<\/code><\/pre>\n<p><strong>Storage<\/strong><\/p>\n<p>\u042f \u0441\u043e\u0437\u0434\u0430\u043b RootStore \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e factory create models. \u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"typescript\">import { createContext } from \"react\"; import Campaign from \".\/campaign\"; import Dashboard from \".\/dashboard\"; import Api from \"@\/api\";  export interface ModelInterface { [key: string]: any; }  interface ModelConstructor { new (context: RootStore): ModelInterface; }  function createModel&lt;T>( ctor: ModelConstructor, context: RootStore ): T { return new ctor(context) as T; }  export class RootStore { api: Api; campaign: Campaign; dashboard: Dashboard;  constructor(api: Api) { this.api = api;  this.campaign = createModel&lt;Campaign>(Campaign, this); this.dashboard = createModel&lt;Dashboard>(Dashboard, this); } } const api = new Api({ ecwidStore: { payload: \"c2bh2nmjkkoa2\" }, }); export const store = new RootStore(api); export type StoreType = RootStore | Record&lt;string, never>; export const StoreContext = createContext&lt;StoreType>({});<\/code><\/pre>\n<p><strong>API<\/strong><\/p>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 Axios \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0448\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 401.<\/p>\n<pre><code class=\"typescript\">import axios, {AxiosInstance} from \"axios\";  import {endpointsInitFactory} from \".\/endpoints\";  type InitialType = { ecwidStore: { payload: string } }  class Api { endpoints axios: AxiosInstance constructor(initial: InitialType) { this.axios = axios.create({ baseURL: process.env.REACT_APP_BASE_URL, headers: { \"Content-Type\": \"application\/json\", \"ecwid-payload\": initial.ecwidStore.payload, }, });  this.endpoints = endpointsInitFactory(this.axios) } }  export default Api; <\/code><\/pre>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0430\u043b\u0438\u0430\u0441\u043e\u0432<\/strong><\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b \u043f\u0440\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0435 \u043c\u043e\u0434\u0443\u043b\u0435\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c \u0432\u043c\u0435\u0441\u0442\u0435.<\/p>\n<p>\u0412 \u0432\u0430\u0448\u0435\u043c tsconfig.json \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043f\u0443\u0442\u044c:<\/p>\n<pre><code class=\"json\">{     \"compilerOptions\": {         \"paths\": {             \"@\/*\": [\".\/src\/*\"]         },     }, }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0430\u043a\u0435\u0442 <code>npm install <a class=\"mention\" href=\"\/users\/craco\">@craco<\/a>\/craco --save<\/code> \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0432\u0441\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 package.json<\/p>\n<pre><code class=\"json\">\"scripts\": {     \"start\": \"craco start\",     \"build\": \"craco build\",     \"test\": \"craco test\",     \"eject\": \"craco eject\"   },<\/code><\/pre>\n<h2>\u041e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b<\/h2>\n<p>\u041d\u0438\u0436\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 ReactJS \u043d\u0430 CodeSandbox.<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/665f31aa87bb36d4b3a0d179\" data-style=\"\" id=\"665f31aa87bb36d4b3a0d179\" width=\"\"><\/div>\n<h4>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 ui-kit<\/h4>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u044f \u043d\u0435 \u0441\u0442\u0430\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0438\u0437\u0430\u0439\u043d, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 Ecwid \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439 css framework <a href=\"https:\/\/developers.ecwid.com\/ecwid-css-framework\/\" rel=\"noopener noreferrer nofollow\">https:\/\/developers.ecwid.com\/ecwid-css-framework\/<\/a><\/p>\n<p>\u041e\u043d\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0432 html \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 css &amp; js \u0444\u0430\u0439\u043b\u044b. \u0418 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c html \u0432\u0451\u0440\u0442\u0441\u043a\u0443, \u043d\u043e \u044d\u0442\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e\u0434 React \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0443, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0430 ReactJS \u0441\u0442\u044d\u043a \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p><strong>Checkbox<\/strong><\/p>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 html \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430, \u0430 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c disabled \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u043b\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440?<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/46b\/23d\/74d\/46b23d74dc22dcbb6393fbef5d38d00d.png\" width=\"2000\" height=\"638\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/46b\/23d\/74d\/46b23d74dc22dcbb6393fbef5d38d00d.png\"\/><\/figure>\n<p>\u041d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0430 disabled \u0438 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e!<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 src \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e ui-kit, \u0442\u0443\u0442 \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 Ecwid CSS framework. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e base \u2013 \u0442\u0443\u0442 \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u041e\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0432\u0441\u0435 class \u043d\u0430 className \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0442\u0435\u0433\u0438 \u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 Props<\/p>\n<\/li>\n<\/ol>\n<div class=\"floating-image\">\n<figure class=\"float bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/efc\/e68\/8a3\/efce688a32550dcbf2c93fef59ff4513.png\" width=\"2000\" height=\"1887\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/efc\/e68\/8a3\/efce688a32550dcbf2c93fef59ff4513.png\"\/><\/figure>\n<\/div>\n<div class=\"floating-image\">\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4c3\/356\/adc\/4c3356adc0dc5b9e4fd3c2c1f9e0ca85.png\" alt=\"\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0441\u0442\u0438\u043b\u0438\" title=\"\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0441\u0442\u0438\u043b\u0438\" width=\"1983\" height=\"1594\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4c3\/356\/adc\/4c3356adc0dc5b9e4fd3c2c1f9e0ca85.png\"\/><\/p>\n<div><figcaption>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0441\u0442\u0438\u043b\u0438<\/figcaption><\/div>\n<\/figure>\n<\/div>\n<pre><code class=\"xml\">&lt;head>   &lt;link rel=\"stylesheet\" href=\"https:\/\/d35z3p2poghz10.cloudfront.net\/ecwid-sdk\/css\/1.3.19\/ecwid-app-ui.css\"\/> &lt;\/head>  &lt;body>      &lt;div>Some content&lt;\/div>    &lt;script type=\"text\/javascript\" src=\"https:\/\/d35z3p2poghz10.cloudfront.net\/ecwid-sdk\/css\/1.3.19\/ecwid-app-ui.min.js\">&lt;\/script> &lt;\/body><\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430.<\/p>\n<h2>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0434\u043b\u044f frontend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0412 \u043d\u0430\u0448\u0438\u0445 \u043c\u0430\u043a\u0435\u0442\u0430\u0445 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 4 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<ul>\n<li>\n<p>Dashboard \u2013 \u0442\u0443\u0442 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c Instagram \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u043a\u0443\u0434\u0430<\/p>\n<\/li>\n<li>\n<p>Create campaign \u2013 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 2 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 <\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u0431\u043e\u0440 \u0442\u0438\u043f\u0430 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0424\u043e\u0440\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Edit campaign \u2013 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<h3>Dashboard page<\/h3>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0443 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0451\u0440\u0441\u0442\u043a\u0435, \u0430 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f Instagram account \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c SDK \u0432 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u043d\u0435\u0446 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0412\u044b\u043d\u0435\u0441\u0435\u043c appId \u0432 env (REACT_APP_FACEBOOK_APP_ID) \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u044f\u0441\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0434\u043e\u0432\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 window \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u0435 FB<\/p>\n<pre><code class=\"xml\">&lt;script>     window.fbAsyncInit = function() {         FB.init({             appId      : '%REACT_APP_FACEBOOK_APP_ID%',             cookie     : true,             xfbml      : true,             version    : 'v9.0'         });          FB.AppEvents.logPageView();      };      (function(d, s, id){         var js, fjs = d.getElementsByTagName(s)[0];         if (d.getElementById(id)) {return;}         js = d.createElement(s); js.id = id;         js.src = \"https:\/\/connect.facebook.net\/en_US\/sdk.js\";         fjs.parentNode.insertBefore(js, fjs);     }(document, 'script', 'facebook-jssdk')); &lt;\/script><\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Dashboard.jsx, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 3 \u0447\u0430\u0441\u0442\u0435\u0439, \u0448\u0430\u043f\u043a\u0430 \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c Instagram, \u043d\u0438\u0436\u0435 \u0431\u043b\u043e\u043a \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430, \u0442.\u043a. \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438 \u0442\u043e\u043a\u0435\u043d\u0430, \u0438 \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0430\u0440\u043e\u043b\u044c \u043e\u0442 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430, \u0442\u043e \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c \u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d.<\/p>\n<p>\u0412<code>useEffect<\/code> \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0435 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u044b, \u043f\u043e\u0441\u043b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430\u043c \u0432\u0435\u0440\u043d\u0451\u0442 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u044b \u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u043e\u043b\u0435 <code>fbNeedToUpdate == true<\/code> , \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c <code>useEffect<\/code> \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0436\u0438\u0434\u0430\u0442\u044c\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f <code>fbNeedToUpdate<\/code> \u0432 store. \u0415\u0441\u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 SDK \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d \u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u043e\u0439\u0434\u0451\u0442 \u0432\u0441\u0451 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e.<\/p>\n<blockquote>\n<p>\u0412\u0430\u0436\u043d\u043e! \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 Instagram \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u044f\u0437\u044c \u0431\u0438\u0437\u043d\u0435\u0441 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b Instagram &amp; Facebook Page, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043a\u043e\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f <\/p>\n<\/blockquote>\n<pre><code class=\"javascript\">\/\/ getting Facebook Page status useEffect(() => {     getSavePages(); }, [])  \/\/ Updating facebook token useEffect(() => {     if (fbNeedToUpdate !== null &amp;&amp; fbNeedToUpdate) {         getFBLoginStatus();     } }, [fbNeedToUpdate]);  const getFBLoginStatus = () => {     window.FB.getLoginStatus((response) => {         console.log('Good to see you, ', response);         const {status, authResponse} = response;         setFbLoginStatus(status);         if (status === 'connected') {             const {accessToken, userID} = authResponse;             setFacebookData(accessToken, userID);             getPages();         }     }); };<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0435\u0439\u0441, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0438 \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043f\u043e\u0432\u0435\u0441\u0438\u043c \u0435\u0433\u043e \u043d\u0430 button \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 onClick. \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c  \u0442\u043e\u043a\u0435\u043d \u0438 uderID \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<pre><code class=\"javascript\">const loginInst = () => {     window.FB.login((response) => {         if (response.status === 'connected') {             const {accessToken, userID} = response.authResponse;             setFacebookData(accessToken, userID);             getPages();         }     }, {         scope: 'instagram_basic, instagram_content_publish, pages_show_list, pages_read_engagement',         auth_type: 'rerequest',         return_scopes: true,     }); }; <\/code><\/pre>\n<p>\u0418 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043c \u0441 \u0432\u0451\u0440\u0441\u0442\u043a\u043e\u0439.<\/p>\n<pre><code class=\"javascript\">return (     &lt;div className=\"my-3\">         &lt;ConnectSocialNetwork             loading={loading}             icon={&lt;img src={instagramLogo} alt=\"logo facebook\"\/>}             title={pages.length > 0 ? t('connected.title') : t('connect.title')}             text={pages.length > 0 ? t('connected.text') : t('connect.text')}             pages={pages}             rightContainer={(                 &lt;>                     &lt;Button                         label={pages.length > 0 ? t('connected.btn') : t('connect.btn')}                         onClick={onLogin}                         loading={loading}                     \/>                     &lt;Button                         label={t('helpConnectBtn')}                         color=\"link\"                         icon={&lt;InfoIcon\/>}                         size=\"small\"                         className=\"ml-1\"                         onClick={getHelp}                     \/>                 &lt;\/>             )}         \/>         {fbNeedToUpdate &amp;&amp; (             &lt;Alert                 modal                 type=\"error\"                 title={t('expired.title')}                 description={(                     &lt;Button label={t('expired.btn')} onClick={onLogin}\/>                 )}             \/>         )}     &lt;\/div> ); <\/code><\/pre>\n<h3>\u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c 2 \u044d\u0442\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0442\u043e \u043e\u043d\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u043e\u0434\u043d\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u044b, \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u0418 \u0432 \u0434\u0432\u0443\u0445 \u044d\u0442\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0445 \u043c\u044b \u0445\u043e\u0434\u0438\u043c \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0422\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 2 \u043f\u0443\u0442\u044f\u043c\u0438:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0433\u043b\u0443\u043f\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0451\u0440\u0441\u0442\u043a\u0443 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0449\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c Higher-Order Component, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<\/ol>\n<p>\u042f \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043e\u043d \u043f\u0440\u043e\u0449\u0435 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0438.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u0432\u0451\u0440\u0441\u0442\u043a\u043e\u0439 \u0438 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"javascript\">const CampaignForm = () => {   const {       campaignStore: {           getProduct,           \/\/ import all variables for our form       },       dashboardStore: {           getSavePages       }   } = useStore();  \/\/ getting store product   useEffect(() => {       getProduct();   }, []);    \/\/ getting instagram pages   useEffect(() => {       getSavePages();   }, []);    const Errors = () => {       if (typeof errors === 'string') {           return errors;       }        return (           &lt;ul>               {errors.map((error, i) => (                   &lt;li key={i}>{error}&lt;\/li>               ))}           &lt;\/ul>       );   }      return (   &lt;form>   &lt;Errors\/>   {\/*fields*\/}   &lt;\/form>   )    } <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438.<\/p>\n<ul>\n<li>\n<p>\u0432 \u0441\u0430\u043c\u043e\u043c \u0432\u0435\u0440\u0445\u0443 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c Navbar, \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u043c\u0435\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 onSubmit \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u043c\u0435\u0442\u043e\u0434 saveRandomCampaign \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0442\u043e\u0432\u0430\u0440<\/p>\n<ul>\n<li>\n<p>\u0438 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 \u043d\u0430 Dashboard page<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0412\u0430\u0436\u043d\u043e \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439 UI \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043a\u043b\u0438\u043a\u0430\u0435\u0442 \u043f\u043e \u043a\u043d\u043e\u043f\u043a\u0435 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u043b\u043e\u0430\u0434\u0435\u0440\u0430 \u0432\u043d\u0443\u0442\u0440\u0438, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0451\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e sendingForm<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"javascript\">import React from 'react'; import {observer} from \"mobx-react-lite\"; import {useHistory} from \"react-router-dom\"; import {useTranslation} from \"react-i18next\";   import Button from \"..\/..\/components\/Button\/Button\"; import Navbar from \"..\/..\/components\/Navbar\/Navbar\"; import CampaignForm from \".\/CampaignForm\"; import Label from \"..\/..\/components\/Label\/Label\"; import {useStore} from \"..\/..\/store\";   const CreateRandomCampaign = () => {     const history = useHistory();     const {t} = useTranslation('campaigns');     const {         campaignStore: {             saveRandomCampaign, sendingForm         }     } = useStore();      const onSubmit = () => {         saveRandomCampaign()             .then(() => history.push('\/'));     };      return (         &lt;div className=\"mt-2\">             &lt;Navbar                 title={&lt;>                     &lt;span className=\"mx-1\">                     {t('randomForm.createTitle')}                     &lt;\/span>                     &lt;Label label=\"Random\"\/>                 &lt;\/>}                 actions={                     &lt;>                         &lt;Button label={t('form.save')} loading={sendingForm} onClick={onSubmit}\/>                         &lt;span className=\"mr-2\"\/>                         &lt;Button label={t('form.cancel')} color=\"link\" onClick={() => history.push('\/')}\/>                     &lt;\/>                 }             \/>             &lt;CampaignForm\/>         &lt;\/div>     ); }; export default observer(CreateRandomCampaign);<\/code><\/pre>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0444\u043e\u0440\u043c\u044b \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438. \u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0435\u0436\u043d\u0435\u0439<\/p>\n<pre><code class=\"javascript\">import React, {useEffect} from 'react'; import {observer} from \"mobx-react-lite\"; import {useHistory, useParams} from \"react-router-dom\"; import {useTranslation} from \"react-i18next\"; import {toJS} from \"mobx\";  import Button from \"..\/..\/components\/Button\/Button\"; import Navbar from \"..\/..\/components\/Navbar\/Navbar\"; import CampaignForm from \".\/CampaignForm\"; import Label from \"..\/..\/components\/Label\/Label\"; import {useStore} from \"..\/..\/store\";   const UpdateRandomCampaign = () => {     const history = useHistory();     let {id} = useParams();      const {t} = useTranslation('campaigns');     const {         campaignStore: {             getCampaign, updateRandomCampaign, sendingForm         },         dashboardStore: {             activeCampaigns         }     } = useStore();      useEffect(() => {         getCampaign(id);     }, []);      const onSubmit = () => {         updateRandomCampaign(id)             .then(() => history.push('\/'));     };      return (         &lt;div className=\"mt-2\">             &lt;Navbar                 title={                     &lt;>                         &lt;span className=\"mx-1\">                             {t('randomForm.editTitle')}                         &lt;\/span>                         &lt;Label label=\"Random\"\/>                     &lt;\/>                 }                 actions={                     &lt;>                         &lt;Button label={t('form.update')} loading={sendingForm} onClick={onSubmit}\/>                         &lt;span className=\"mr-2\"\/>                         &lt;Button label={t('form.cancel')} color=\"link\" onClick={() => history.push('\/')}\/>                     &lt;\/>                 }             \/>             &lt;CampaignForm\/>         &lt;\/div>     ); }; export default observer(UpdateRandomCampaign);<\/code><\/pre>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9ef\/803\/b93\/9ef803b93a3b224daf87e68a7d6824ab.png\" alt=\"\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\" title=\"\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\" width=\"860\" height=\"764\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9ef\/803\/b93\/9ef803b93a3b224daf87e68a7d6824ab.png\"\/><\/p>\n<div><figcaption>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/figcaption><\/div>\n<\/figure>\n<h3>\u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043f\u043e\u0441\u0442\u0430<\/h3>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u0432\u0435\u0440\u0445\u0443 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0442\u043e\u0432\u0430\u0440<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u0432\u0430\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>\u0446\u0435\u043d\u0430<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u0444\u0438\u0447\u0430 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0435\u0441\u0435\u0442\u043e\u0432 \u0442\u0435\u043a\u0441\u0442\u0430, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u044b \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0438\u0448\u0435\u043c mobx \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430<\/p>\n<pre><code class=\"javascript\">import {action, makeAutoObservable, makeObservable, toJS} from \"mobx\";  import randomInteger from '..\/utils\/random';  class CampaignStore { \/\/ array of templates     templates = [\"\"];     activeTemplate = 0;          constructor({api}) {         this.api = api;          makeObservable(this, {             addTemplate: action,             removeTemplate: action,             setActiveTemplate: action,             changeTemplate: action,         });     }          \/\/ add new template when user click add button     addTemplate = () => {     \/\/ create a copy of templates         const templates = this.templates.slice();         templates.push('');         this.templates = templates;         \/\/ change active template in the form         this.setActiveTemplate(this.templates.length - 1);     };          \/\/ remove template by index when user click trash icon button     removeTemplate = (index) => {         if (this.templates.length > 1) {             const templates = this.templates.slice();             templates.splice(index, 1);             this.templates = templates;             this.setActiveTemplate((index - 1) % templates.length);         }     };          \/\/ set active template when user choose template     setActiveTemplate = (index) => {         this.activeTemplate = index;     };               \/\/ change content inside editor for choosable template     changeTemplate = (value) => {         let templates = this.templates.slice();         templates[this.activeTemplate] = value;         this.templates = templates;     }; }<\/code><\/pre>\n<p>\u041e\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430.<\/p>\n<pre><code class=\"javascript\">import React, {useCallback, useMemo, useRef, useState} from 'react'; import $ from 'jquery'; import PropTypes from 'prop-types';  import '.\/styles\/post-editor.scss'; import {ReactComponent as CloseIcon} from '.\/assets\/cancel.svg'; import {ReactComponent as ArrowIcon} from '.\/assets\/arrow.svg'; import Button from \"..\/Button\/Button\"; import selectTemplates from \"..\/..\/store\/template\/templates\"; import {useTranslation} from \"react-i18next\"; import Skeleton from \"react-loading-skeleton\";  const PostEditor = (     {         disabled, changeTemplate, templates,         addTemplate,         removeTemplate,         activeTemplate,         setActiveTemplate, loading     } ) => {     const textAreaRef = useRef();     const {t} = useTranslation('campaigns');          \/\/ when user want to add constant we should determinate insert position     const insertConstant = (constant) => {     \/\/ getting cursor index          const cursorPos = $(textAreaRef.current).prop('selectionStart');         const value = templates[activeTemplate];         const textBefore = value.substring(0, cursorPos);         const textAfter = value.substring(cursorPos, value.length);         changeTemplate(textBefore + constant + textAfter);     };  \/\/ showing the skeletons while content is loading     if (loading) {         return (             &lt;div className=\"fieldset\">                 &lt;div className=\"fieldset__title\">{t('form.contentLabel')}&lt;\/div>                 &lt;div className=\"d-flex flex-wrap align-items-center\">                     &lt;Skeleton width={32} height={32} className=\"mr-2 mb-1\"\/>                     &lt;Skeleton width={100} height={18}\/>                 &lt;\/div>                 &lt;Skeleton width=\"100%\" height={178}\/>             &lt;\/div>         );     }      return (         &lt;div className=\"fieldset\">             &lt;div className=\"d-flex flex-wrap\">           {\/* render carousel btns with remove btn *\/}                 {templates.map((template, index) => (                     &lt;div key={template + index}>                         &lt;Button                          label={index + 1}                          disabled={index === activeTemplate}                                  size=\"small\"                                 color=\"default\"                                 onClick={() => setActiveTemplate(index)}                         \/>                         &lt;div onClick={() => removeTemplate(index)}>                             &lt;CloseIcon width={8} height={8}\/>                         &lt;\/div>                     &lt;\/div>                 ))}                 {\/* render add template btn *\/}                 &lt;Button label={t('form.addContentTemplate')} icon size=\"small\" color=\"link\" onClick={addTemplate}\/>             &lt;\/div>             &lt;div className=\"postEditorWrap\">             {\/* selecting a pre-filled template *\/}             &lt;SelectBox                     onChange={onChange}                     label={t('form.selectTemplate')}                     options={selectTemplates}                 \/>                 {\/* selecting constants *\/}                 &lt;SelectBox                     onChange={insertConstant}                     label={t('form.insertConstant')}                     options={t('form.constants', {returnObjects: true})}                 \/>                                  &lt;textarea                  rows={8}                  className=\"postEditor\"                  ref={textAreaRef}                  onChange={(e) => onChange(e.target.value)}                 value={templates[activeTemplate]}                 \/>             &lt;\/div>         &lt;\/div>     ); }  export default PostEditor; <\/code><\/pre>\n<p>\u042f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c 2 \u0432\u0435\u0449\u0438:<\/p>\n<ul>\n<li>\n<p>\u0412\u0441\u0442\u0430\u0432\u043a\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u0438\u0437 SelectBox<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u043e\u0440 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0438\u0437 SelectBox<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u0441\u0442\u0430\u0432\u043a\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u0438\u0437 SelectBox<\/strong><\/p>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u042d\u0442\u0443 JSON \u044f \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u043a\u0430\u043a options in SelectBox. \u0414\u0430\u043b\u044c\u0448\u0435 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443, \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u044d\u0442\u0443 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u043e\u043b\u044f value.<\/p>\n<p>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u0444\u043e\u0440\u043c\u0443 \u043a\u0430\u043a string \u043c\u0430\u0441\u0441\u0438\u0432, \u0433\u0434\u0435 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c <code>$(textAreaRef.current).prop('selectionStart')<\/code><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0451\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0438\u0437 \u0441\u0442\u043e\u0440\u0430 \u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 2 \u0447\u0430\u0441\u0442\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043a\u0443\u0440\u0441\u043e\u0440\u0430 \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435. \u0417\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u0435\u043c <code>changeTemplate<\/code> \u0433\u0434\u0435 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043e\u0439 \u0438 \u043a\u043e\u043d\u0446\u043e\u043c \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<pre><code class=\"json\">\"constants\": [       {         \"value\": \"{PRODUCT_LINK}\",         \"label\": \"{PRODUCT_LINK} - A direct link to the product\"       },       {         \"value\": \"{PRODUCT_TITLE}\",         \"label\": \"{PRODUCT_TITLE} - The product title\"       },       {         \"value\": \"{STORE_NAME}\",         \"label\": \"{STORE_NAME} - The store name\"       },       {         \"value\": \"{PRICE}\",         \"label\": \"{PRICE} - The product price\"       },       {         \"value\": \"{DISCOUNT_AMOUNT}\",         \"label\": \"{DISCOUNT_AMOUNT} - The product discount amount\"       },       {         \"value\": \"{DISCOUNT_CODE}\",         \"label\": \"{DISCOUNT_CODE} - The product discount code\"       }     ]<\/code><\/pre>\n<p><strong>\u0412\u044b\u0431\u043e\u0440 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0438\u0437 SelectBox<\/strong><\/p>\n<p>\u0412 \u0441\u0435\u043b\u0435\u043a\u0442\u0431\u043e\u043a\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c options \u0441 \u043f\u0440\u0435\u0434\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438. \u0413\u0434\u0435 label \u2013 \u044d\u0442\u043e \u043a\u0440\u0430\u043a\u0442\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u0432 \u0441\u0435\u043b\u0435\u043a\u0442\u0435, \u0430 value \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u043c.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d, \u043c\u044b \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f value \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440.<\/p>\n<pre><code class=\"javascript\">const templates = [ \/\/    1     {         label: \"? {PRODUCT_TITLE} ?...\",          value: `? {PRODUCT_TITLE} ? starting at {PRICE}  Shop Now ?? {PRODUCT_LINK}`     },  \/\/    2     {         label: \"? {PRODUCT_TITLE} ?...\",          value: `? {PRODUCT_TITLE} ?   Shop {VENDOR_NAME} Today ? {PRODUCT_LINK}`     } ]<\/code><\/pre>\n<h2>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 backend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 backend \u044f \u0432\u044b\u0431\u0440\u0430\u043b NestJS \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0441 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 TypeScript, \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 PostgreSQL.<\/p>\n<p>\u0412\u0441\u0435\u0433\u0434\u0430 \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u0443\u0437\u043d\u0430\u044e \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u043e\u043b\u0435\u0439, \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438. \u041e\u0431 \u044d\u0442\u043e\u043c \u044f \u043f\u0438\u0441\u0430\u043b \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0435\u0440\u0438\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0441\u0432\u0435\u0436\u0438\u043c \u043f\u0430\u043c\u044f\u0442\u044c, \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0437 1 \u0441\u0442\u0430\u0442\u044c\u0438<\/p>\n<h3>\u041f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 ER\u00a0Diagram<\/h3>\n<p>\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u044b\u0439 \u044d\u0442\u0430\u043f \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 backend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0451 \u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u0441\u044f \u043d\u0430\u0448\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0440\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e \u043d\u0430\u043c \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438.<\/p>\n<p>\u042f \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u0411\u0414, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a <a href=\"http:\/\/sqlstyle.guide\" rel=\"noopener noreferrer nofollow\">sqlstyle.guide<\/a> \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b (<a href=\"https:\/\/www.sqlstyle.guide\/#tables\" rel=\"noopener noreferrer nofollow\">https:\/\/www.sqlstyle.guide\/#tables<\/a>):<\/p>\n<ul>\n<li>\n<p><strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435<\/strong>\u00a0\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0438\u043b\u0438, \u0447\u0442\u043e \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0444\u043e\u0440\u043c\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,\u00a0<code>staff<\/code>\u00a0\u0438\u00a0<code>employees<\/code>\u00a0(\u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u044f).<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435<\/strong>\u00a0\u043e\u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u044b \u0432\u0438\u0434\u0430\u00a0<code>tbl_<\/code>\u00a0\u0438 \u0432\u0435\u043d\u0433\u0435\u0440\u0441\u043a\u0443\u044e \u043d\u043e\u0442\u0430\u0446\u0438\u044e \u0432 \u0446\u0435\u043b\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435<\/strong>\u00a0\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043b\u044e\u0431\u043e\u0433\u043e \u0438\u0437 \u0435\u0451 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438\u00a0<strong>\u0438\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435<\/strong>\u00a0\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0434\u0432\u0443\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u00a0<code>cars_mechanics<\/code>\u00a0\u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442\u00a0<code>services<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 stores<\/strong><\/p>\n<p>\u042d\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0412\u0430\u0436\u043d\u043e \u043d\u0435 \u0443\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u043e\u043b\u0435.<\/p>\n<div class=\"floating-image\">\n<figure class=\"float bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b06\/7bd\/067\/b067bd067cc7f6666ee4b9742a6d392e.png\" alt=\"\u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 stores\" title=\"\u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 stores\" width=\"2000\" height=\"3138\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b06\/7bd\/067\/b067bd067cc7f6666ee4b9742a6d392e.png\"\/><\/p>\n<div><figcaption>\u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 stores<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u0432\u0430\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c: id \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430, \u043b\u043e\u043a\u0430\u043b\u044c \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430, \u0442\u043e\u043a\u0435\u043d\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0447\u0435\u0440\u0435\u0437 \u043d\u0438\u0445 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0440\u0447\u0430\u043d\u0442\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430, \u0432\u0430\u043b\u044e\u0442\u0430, \u0434\u0430\u0442\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u0431 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435 \u0443 \u043d\u0430\u0441 \u0432 \u0431\u0430\u0437\u0435.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443, \u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u0441\u0430\u043c Ecwid, \u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043e\u0431 \u0434\u0430\u0442\u0435 \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0438 \u0435\u0451 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f + \u0441\u0442\u0430\u0442\u0443\u0441.<\/p>\n<\/div>\n<p><strong>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 facebook_pages<\/strong><\/p>\n<p>\u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 facebook pages (\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 Instagram \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 Facebook Pages)<\/p>\n<p>\u041d\u0430\u043c \u0432\u0430\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c token \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u0437\u0430 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u043e\u043d \u0432\u044b\u0431\u0440\u0430\u043b \u0438 expires \u2013 \u0434\u0430\u0442\u0430 \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430 (\u0442\u043e\u043a\u0435\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u0438 \u0440\u0430\u043d\u044c\u0448\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0430\u0440\u043e\u043b\u044c \u043e\u0442 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430)<\/p>\n<p><strong>\u0422\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f campaign<\/strong><\/p>\n<div class=\"floating-image\">\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/96d\/672\/06f\/96d67206f077ecea09f335536e6b963e.png\" width=\"2000\" height=\"1382\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/96d\/672\/06f\/96d67206f077ecea09f335536e6b963e.png\"\/><\/figure>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u2013 \u044d\u0442\u043e campaigns<\/strong> \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0438\u043c\u044f \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438, \u0442\u0438\u043f \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438 (\u0440\u0430\u043d\u0434\u043e\u043c\u043d\u0430\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0438\u043b\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u043e\u0432\u0438\u043d\u043e\u043a), \u0441\u0432\u044f\u0437\u044c \u043d\u0430 \u043a\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e, \u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0438 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0441\u0432\u044f\u0437\u044c \u043a\u0430\u043a\u043e\u043c\u0443 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0443 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u044f.<\/p>\n<\/div>\n<div class=\"floating-image\">\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/681\/397\/876\/68139787644b22a01a4820f2b5afa38c.png\" width=\"2000\" height=\"1152\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/681\/397\/876\/68139787644b22a01a4820f2b5afa38c.png\"\/><\/figure>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 templates \u2013 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043d\u0430\u0431\u043e\u0440\u044b \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0430, \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442, \u0438 \u0441\u0432\u044f\u0437\u044c \u0441 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0435\u0439.<\/p>\n<\/div>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u0445 \u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438. \u041c\u0435\u0440\u0447\u0430\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0446\u0435\u043b\u044b\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 \u043d\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0441\u0432\u044f\u0437\u044c Many-to-Many, \u0442.\u043a. \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438, \u043a\u0430\u043a \u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0440\u0430\u0437\u043d\u044b\u043c \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u044f\u043c \u043c\u0435\u0440\u0447\u0430\u043d\u0442\u0430.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0437\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0435\u0439 \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u0441\u0432\u044f\u0437\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c Many to Many, \u0442.\u043a. \u0437\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043a \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0443 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043a \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0443 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0441 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0432\u044f\u0437\u0438 many to many.<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c40\/ffe\/e92\/c40ffee92821e4670d4190f5f36dc3c4.png\" width=\"2000\" height=\"974\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c40\/ffe\/e92\/c40ffee92821e4670d4190f5f36dc3c4.png\"\/><\/figure>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u0435 \u0441\u0432\u044f\u0437\u0438 \u0432 NestJS.<\/p>\n<ul>\n<li>\n<p>Many-to-Many \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u043e\u043b\u0435 categories \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 CategoriesEntity[] <\/p>\n<ul>\n<li>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c @<strong><em>JoinTable<\/em><\/strong>() creates a junction table.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c @ManyToMany(() => CategoriesEntity) \u0433\u0434\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0432\u044f\u0437\u0438 \u0443\u043a\u0430\u0436\u0435\u043c CategoriesEntity<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>ORM \u0437\u0430 \u043d\u0430\u0441 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u043e \u043b\u043e\u0433\u0438\u043a\u0435 \u043f\u0435\u0440\u0435\u043a\u0440\u0451\u0441\u0442\u043d\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<p><em>campaigns.entity.ts<\/em><\/p>\n<pre><code class=\"typescript\">import {   Entity,   Column,   PrimaryGeneratedColumn,   OneToMany,   OneToOne,   JoinColumn,   ManyToOne,   CreateDateColumn,   UpdateDateColumn,   ManyToMany,   JoinTable, } from 'typeorm';  import { TemplatesEntity } from '.\/templates\/templates.entity'; import { CategoriesEntity } from '..\/categories\/categories.entity'; import { DiscountsEntity } from '.\/discounts\/discounts.entity'; import { DatesEntity } from '.\/dates\/dates.entity'; import { CampaignsHistoryEntity } from '.\/campaigns-history\/campaigns-history.entity'; import { StoresEntity } from '..\/stores\/stores.entity'; import { FacebookPagesEntity } from '..\/facebook-pages\/facebook-pages.entity';  @Entity('campaigns') export class CampaignsEntity {   @PrimaryGeneratedColumn()   id: number;    @Column('text')   type: string;    @Column('text')   name: string;    @Column('bool')   active: boolean;    @OneToMany(() => TemplatesEntity, (templates) => templates.campaign)   templates: TemplatesEntity[];    @ManyToMany(() => CategoriesEntity)   @JoinTable()   categories: CategoriesEntity[];    @OneToMany(() => DatesEntity, (categories) => categories.campaign)   dates: DatesEntity[];    @OneToMany(     () => CampaignsHistoryEntity,     (campaignsHistory) => campaignsHistory.campaign,   )   campaignsHistory: CampaignsHistoryEntity[];    @ManyToOne(() => StoresEntity, (store) => store.campaigns)   store: StoresEntity;    @OneToOne(() => DiscountsEntity)   @JoinColumn()   discount: DiscountsEntity;    @ManyToOne(     () => FacebookPagesEntity,     (facebookPage) => facebookPage.campaigns,   )   facebookPage: FacebookPagesEntity;    @CreateDateColumn({ type: 'timestamp' })   createdAt: Date;    @UpdateDateColumn({ type: 'timestamp' })   updatedAt: Date; }<\/code><\/pre>\n<p><em>categories.entity.ts<\/em><\/p>\n<pre><code class=\"typescript\">import {   Entity,   Column,   PrimaryGeneratedColumn,   CreateDateColumn,   UpdateDateColumn,   ManyToOne,   JoinColumn,   ManyToMany,   JoinTable,   OneToMany, } from 'typeorm'; import { StoresEntity } from '..\/stores\/stores.entity'; import { ProductsEntity } from '..\/products\/products.entity';  @Entity('categories') export class CategoriesEntity {   @PrimaryGeneratedColumn()   id: number;    @Column('bigint')   ecwidCategoryId: number;    @Column('text', { nullable: true })   thumbnailUrl: string;    @Column('text')   name: string;    @Column('boolean')   enabled: boolean;    @Column('integer', { nullable: true })   productCount: number;    @ManyToOne(() => StoresEntity)   @JoinColumn()   store: StoresEntity;    @ManyToMany(() => ProductsEntity, (products) => products.categories)   products: ProductsEntity[];    @ManyToOne((type) => CategoriesEntity, (category) => category.children)   parent: CategoriesEntity;    @OneToMany((type) => CategoriesEntity, (category) => category.parent)   children: CategoriesEntity[];    @CreateDateColumn({ type: 'timestamp' })   createdAt: Date;    @UpdateDateColumn({ type: 'timestamp' })   updatedAt: Date; }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7c0\/1d5\/f05\/7c01d5f05afedbd14d3291e1f42d4587.png\" width=\"2000\" height=\"1398\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7c0\/1d5\/f05\/7c01d5f05afedbd14d3291e1f42d4587.png\"\/><\/figure>\n<h3>\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0439<\/h3>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0439, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u043e\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0447\u0430\u0441 \u0438 \u0441\u0432\u0435\u0440\u044f\u0442\u044c \u0435\u0441\u0442\u044c \u043b\u0438 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438 \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u044d\u043a\u0435\u043d\u0434 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435 \u043c\u0435\u0440\u0447\u0430\u043d\u0442\u0430 \u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043b \u0432\u044b\u0431\u043e\u0440  \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0430 \u0431\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043c\u0438\u043d\u0443\u0442, \u0442.\u0435. \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e 24 \u0447\u0430\u0441\u0430 \u0438\u0437 \u0441\u0443\u0442\u043e\u043a.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c campaigns<\/p>\n<pre><code class=\"bash\">nest generate module campaigns<\/code><\/pre>\n<p>\u0418 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>campaigns.service.ts<\/code>, \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>async handleCron() {}<\/code> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c <code>import { Cron } from '@nestjs\/schedule';<\/code>  \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0434 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>handleCron<\/code> \u043a\u0430\u0436\u0434\u044b\u0439 \u0447\u0430\u0441 \u043d\u0430 50 \u043c\u0438\u043d\u0443\u0442\u0435.<\/p>\n<p>\u0412\u044b\u0437\u043e\u0432 \u043d\u0430 50 \u043c\u0438\u043d\u0443\u0442\u0435, \u0430 \u043d\u0435 \u0440\u043e\u0432\u043d\u043e \u043d\u0430 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u043c\u0438\u043d\u0443\u0442\u0435 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043f\u0435\u0442\u044c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u0432 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0438\u0445 \u043f\u043e \u0441\u0435\u0442\u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 facebook \u0438 \u0437\u0430\u0442\u0435\u043c \u043e\u0434\u043d\u0438\u043c \u0441\u043a\u043e\u0443\u043f\u043e\u043c \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ol>\n<li>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u0432. <\/p>\n<ol>\n<li>\n<p>\u041f\u043b\u044e\u0441 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u043c\u043e\u0436\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0447\u0430\u043d\u043a\u0438 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0441\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c 100 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439, server 1 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0435\u0440\u0432\u044b\u0435 50, server 2 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 50.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430 \u0447\u0430\u0441 \u0434\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438. \u0418 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 facebook \u0438 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u0442\u0430, \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0440\u0430\u0437\u044b \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u0435\u0434\u0438\u0430-\u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <a href=\"https:\/\/docs.nestjs.com\/techniques\/task-scheduling#task-scheduling\" rel=\"noopener noreferrer nofollow\"><strong>Task Scheduling<\/strong><\/a> \u0432 NestJS<\/p>\n<pre><code class=\"bash\">@Cron('0 55 *\/1 * * *') async handleCron() {   this.logger.debug('Called every 50 minutes'); } <\/code><\/pre>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<pre><code>* * * * * * | | | | | | | | | | | day of week (skip it) | | | | months (skip it) | | | day of month (skip it) | | hours (I set the step each hour) | minutes (I set the call at 55 minutes) seconds (skip it) <\/code><\/pre>\n<p><strong>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430<\/strong><\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u0442\u043e.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<\/th>\n<th>\n<p>\u0424\u043e\u0442\u043e \u0442\u043e\u0432\u0430\u0440\u0430<\/p>\n<\/th>\n<th>\n<p>\u0423 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u0441\u043a\u0438\u0434\u043a\u0430<\/p>\n<\/th>\n<th>\n<p>\u041d\u0443\u0436\u043d\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0444\u043e\u0442\u043e<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Variant 1<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705<\/p>\n<\/td>\n<td>\n<p align=\"left\">Yes<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Variant 2<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705<\/p>\n<\/td>\n<td>\n<p align=\"left\">Yes<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Variant 3<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c<\/p>\n<\/td>\n<td>\n<p align=\"left\">Yes<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Variant 4<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u274c<\/p>\n<\/td>\n<td>\n<p align=\"left\">No<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0444\u043e\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u043c\u043e\u043a\u043e\u0434 \u0434\u043b\u044f \u0442\u043e\u0432\u0430\u0440\u0430 \u0438 \u0443 \u0442\u043e\u0432\u0430\u0440\u0430 \u043d\u0435\u0442 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0443 \u0442\u043e\u0432\u0430\u0440\u0430 \u043d\u0435\u0442 \u0444\u043e\u0442\u043e, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430 \u0438 \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0438 \u0438\u043c\u044f \u0442\u043e\u0432\u0430\u0440\u0430.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c canvas<\/p>\n<pre><code class=\"typescript\">import { createCanvas, loadImage } from 'canvas'; import * as fs from 'fs'; import { v4 as uuidv4 } from 'uuid';  export class ProductPhoto {   private canvas = null;   private ctx = null;   private readonly MAX_WIDTH = 700;   private readonly MAX_HEIGHT = 875;    constructor(     private photoSrc,     private title,     private promocode,     private descriprion,     private storeName,     private productName,   ) {   }    async generatePhoto() {     const photoImg = await loadImage(       this.photoSrc || '.\/public\/assets\/empty-photo.jpg',     );      const {       width,       height,       canvasWidth,       canvasHeight,     } = ProductPhoto.getScalableSize(photoImg.width, photoImg.height);          const { x, y } = ProductPhoto.centerImageInCanvas(       width,       height,       canvasWidth,       canvasHeight,     );      this.createCanvas(canvasWidth, canvasHeight);     this.ctx.drawImage(photoImg, x, y, width, height);     this.ctx.quality = 'best';     this.ctx.patternQuality = 'best';     this.ctx.textDrawingMode = 'path';      if (!this.photoSrc) {       await this.createEmptyPhoto();     }      this.ctx.textAlign = 'left';     if (this.descriprion || this.promocode) {       await this.drawCoupon();       await this.drawDescription();     }      const dir = 'image-post';     const dirPublic = `.\/public\/${dir}`;     const file = `\/${uuidv4()}.jpeg`;      if (!fs.existsSync(dirPublic)) {       await fs.mkdirSync(dirPublic, { recursive: true });     }     const out = fs.createWriteStream(dirPublic + file);     console.log('creating');     const stream = await this.canvas.createJPEGStream({ quality: 1 });     await stream.pipe(out);     await out.on('finish', () => console.log('The JPEG file was created.'));     console.log('end');     return {       url: process.env.DOMAIN + dir + file,       path: dirPublic + file,     };   } } <\/code><\/pre>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0441\u0442\u043e\u0440\u043e\u043d \u0434\u043b\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c ProductPhoto.getScalableSize. \u041c\u0435\u0442\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d, \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 0.9 \u0438 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 1.9.<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 0.9, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0445\u043e\u043b\u0441\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 900 \u043d\u0430 1000 \u0438 \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0442\u043e\u0432\u0430\u0440\u0430 \u0432 \u044d\u0442\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u044b. <\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b width = <em>903 height = 4372. height \u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0430\u0432\u043d\u043e\u0439 = 1000 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u044b\u0441\u043e\u0442\u0435 \u0445\u043e\u043b\u0441\u0442\u0430, \u0430 \u0448\u0438\u0440\u0438\u043d\u0443 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0441\u043e\u0442\u0435.<\/em><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 1.9, \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u0451 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u0448\u0438\u0440\u0438\u043d\u0443 \u0445\u043e\u043b\u0441\u0442\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432 1080, \u0430 \u0432\u044b\u0441\u043e\u0442\u0443 \u0432 568<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 0.9 \u2264 x \u2264 1.9, \u0442\u043e \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0448\u0438\u0440\u0438\u043d\u044b \u0438 \u0432\u044b\u0441\u043e\u0442\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c maxSize \u0438 minSize. \u0415\u0441\u043b\u0438 minSize \u043c\u0435\u043d\u044c\u0448\u0435 MIN_WIDTH \u0438 maxSize \u043c\u0435\u043d\u044c\u0448\u0435 MIN_WIDTH, \u0442\u043e\u0433\u0434\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c ratio = MIN_WIDTH \/ minSize; <\/p>\n<ul>\n<li>\n<p>\u0418\u043d\u0430\u0447\u0435 \u0435\u0441\u043b\u0438 maxSize > MAX_WIDTH, \u0442\u043e\u0433\u0434\u0430 ratio = MAX_WIDTH \/ maxSize;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><code class=\"typescript\">private static getScalableSize(width, height) {   const MIN_RATIO = 0.9,     MAX_RATIO = 1.9;   const MIN_WIDTH = 600,     MAX_WIDTH = 1080;    let canvasWidth: number, canvasHeight: number;    const ratio = width \/ height;   \/\/ Example: 903 \/ 4372 = 0.2   if (ratio &lt; MIN_RATIO) {     canvasWidth = 900;     canvasHeight = 1000;      width = (canvasHeight * width) \/ height;     height = canvasHeight;   } else if (ratio > MAX_RATIO) {     \/\/ Example: 1080 \/ 437 = 2.47     canvasWidth = 1080;     canvasHeight = 568;      height = (canvasWidth * height) \/ width;     width = canvasWidth;   } else {     const maxSize = Math.max(width, height);     const minSize = Math.max(width, height);     let ratio = 1;     if (minSize &lt; MIN_WIDTH || maxSize &lt; MIN_WIDTH) {       ratio = MIN_WIDTH \/ minSize;     } else if (maxSize > MAX_WIDTH) {       ratio = MAX_WIDTH \/ maxSize;     }     width *= ratio;     height *= ratio;     canvasWidth = width;     canvasHeight = height;   }    return {     width,     height,     canvasWidth,     canvasHeight,   }; }<\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u043a\u0430\u043a \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c multiline text. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<p>\u0413\u0434\u0435 text &#8212; \u043d\u0430\u0448 \u0440\u0438\u0441\u0443\u0435\u043c\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, x,y &#8212;  \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u043d\u0442\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430, lineHeight &#8212; \u0432\u044b\u0441\u043e\u0442\u0430 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438, fitWidth &#8212; \u043c\u0430\u043a\u0441. \u0448\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0430<\/p>\n<pre><code class=\"typescript\">private drawMultilineText(text, x, y, lineHeight, fitWidth) {     fitWidth = fitWidth || 0;      if (fitWidth &lt;= 0) {       this.ctx.fillText(text, x, y);       return;     }     let words = text.split(' ');     let currentLine = 0;     let idx = 1;     while (words.length > 0 &amp;&amp; idx &lt;= words.length) {       const str = words.slice(0, idx).join(' ');       const w = this.ctx.measureText(str).width;       if (w > fitWidth) {         if (idx == 1) {           idx = 2;         }         this.ctx.fillText(           words.slice(0, idx - 1).join(' '),           x,           y + lineHeight * currentLine,         );         currentLine++;         words = words.splice(idx - 1);         idx = 1;       } else {         idx++;       }     }     if (idx > 0)       this.ctx.fillText(words.join(' '), x, y + lineHeight * currentLine);   }<\/code><\/pre>\n<p><strong>\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u0442\u0430 \u0432 Instagram<\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u0442\u0430\u043f &#8212; \u044d\u0442\u043e \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043f\u043e\u0441\u0442, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u0440\u043e\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438 \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u043f\u043e\u0441\u0442\u0430, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441 facebook-api.service.ts, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 API \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Instagram.<\/p>\n<ul>\n<li>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 createPhotoPost \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u0440\u043e\u0441 <code>\/v10.0\/${pageId}\/media<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u043e\u0441\u0442, \u0433\u0434\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438 \u0442\u0435\u043a\u0441\u0442 \u043f\u043e\u0441\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u0427\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u0440\u043e\u0441 <code>\/v10.0\/${pageId}\/media_publish<\/code> \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"typescript\">import { HttpException, HttpService, Inject, Injectable } from '@nestjs\/common'; import { catchError } from 'rxjs\/operators'; import * as FormData from 'form-data'; import { Logger as LoggerW } from 'winston';  @Injectable() export class FacebookApiService {   constructor(     @Inject('winston')     private readonly loggerW: LoggerW,     private httpService: HttpService,   ) {   }    public async createPhotoPost(pageId, message, photoUrl, token) {     const response = await this.httpService       .post(         `https:\/\/graph.facebook.com\/v10.0\/${pageId}\/media`,         {},         {           params: {             access_token: token,             caption: message,             image_url: photoUrl,           },         },       )       .pipe(         catchError((e) => {           console.log(e);           this.loggerW.error(e.response.data);           throw new HttpException(e.response.data, e.response.status);         }),       )       .toPromise();      const postRes = await this.httpService       .post(         `https:\/\/graph.facebook.com\/v10.0\/${pageId}\/media_publish`,         {},         {           params: {             access_token: token,             creation_id: response.data?.id,           },         },       )       .pipe(         catchError((e) => {           console.log(e);           this.loggerW.error(e.response.data);           throw new HttpException(e.response.data, e.response.status);         }),       )       .toPromise();      console.log(postRes.data);      return postRes.data;   } }<\/code><\/pre>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>\u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u044f \u0441\u043e\u0437\u0434\u0430\u043b front &amp; back \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043a\u0430\u043a\u0438\u0445 \u044d\u0442\u0430\u043f\u043e\u0432 \u043e\u043d\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043b\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438.<\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043b\u0430\u043d, \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0447\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0437\u0430\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0445 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u0442\u0443 \u044f \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u043e\u0442\u0432\u0435\u0447\u0443!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/819489\/\"> https:\/\/habr.com\/ru\/articles\/819489\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043a\u0430\u043a \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u0434\u0435\u044f \u0441\u0442\u0430\u0440\u0442\u0430\u043f\u0430, \u043a\u0430\u043a \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u0430\u043a \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f. \u0422\u0430\u043a\u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435  \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0434\u0438\u0437\u0430\u0439\u043d\u0430. \u041d\u0430\u043f\u043e\u043c\u043d\u044e \u0447\u0442\u043e \u044f \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f sass \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b ecwid, \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u0432 \u043e\u0434\u0438\u043d \u043a\u043b\u0438\u043a. \u042f \u0441\u043e\u0437\u0434\u0430\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b ecwid \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0437\u0430 \u043c\u0435\u0441\u044f\u0447\u043d\u0443\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 ($11). \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 Instagram \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b backend &amp; frontend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u044e \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u0435\u0440\u0447\u0430\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c \u0447\u0435\u0440\u0435\u0437 iframe. \u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u043e\u0432\u0430\u0440\u0430\u043c, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0440\u0447\u0430\u043d\u0442 \u043c\u043e\u0433 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u0432\u044b\u0435 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 Instagram.<\/p>\n<h2>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 frontend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0430\u043c\u043e\u043c\u0443, \u0442\u043e \u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u0441 frontend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u044b\u0441\u043e\u043a\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0447\u0442\u043e \u0432 \u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u043c\u043e\u0433 \u0447\u0442\u043e-\u0442\u043e \u0443\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u043c\u043e\u0442\u0440\u044e \u0443\u0434\u043e\u0431\u043d\u043e \u043b\u0438 \u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u044d\u043a\u0435\u043d\u0434\u0430. \u0427\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u043e \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u0432 \u043c\u0430\u043a\u0435\u0442\u0430\u0445 \u043d\u0435 user friendly \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u043c.<\/p>\n<h3>\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h3>\n<p>\u0414\u043b\u044f web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u044d\u043a: ReactJS +TypeScript + Mobx. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u044d\u043a \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u044e \u0435\u0433\u043e. \u0412\u044b\u0431\u0440\u0430\u043b React \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0443 \u043d\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043c\u044c\u044e\u043d\u0438\u0442\u0438 \u0438 \u044f \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u044e \u0435\u0433\u043e. \u0418 \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u044f\u0437\u044b\u043a\u0438 \u0438 \u044d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043f\u0430\u0441\u0430\u0435\u0442 \u043e\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u043f\u043e \u043c\u0435\u0440\u0435 \u0440\u043e\u0441\u0442\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f. \u0422\u0443\u0442 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e\u0442 \u0441\u0442\u044d\u043a \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0435 \u0441\u0435\u0431\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u043e\u0431\u044c\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 \u0441\u043b\u043e\u0438, \u044f \u0437\u0434\u0435\u0441\u044c \u0432\u0438\u0436\u0443 6 \u0441\u043b\u043e\u0451\u0432:<\/p>\n<ul>\n<li>\n<p>routing \u2013 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>models \u2013 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 mobx<\/p>\n<\/li>\n<li>\n<p>pages \u2013 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>ui-kit \u2013 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>components \u2013 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>lib \u2013 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<p><strong>Routing<\/strong><\/p>\n<p>\u041c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0438, \u043d\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c\u0443.<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044f \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Layout, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0412\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Outlet \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 react-router-dom \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"typescript\">import React from \"react\"; import { createBrowserRouter, RouterProvider } from \"react-router-dom\"; import Dashboard from \"@\/pages\/Dashboard\"; import CreateCampaign from \"@\/pages\/Campaign\/CreateCampaign\"; import EditCampaign from \"@\/pages\/Campaign\/EditCampaign\"; import Layout from \"@\/components\/Layout\";  const router = createBrowserRouter([ { path: \"\/\", element: &lt;Layout \/>, children: [ { path: \"\/\", element: &lt;Dashboard \/> }, { path: \"\/campaign\", element: null, children: [ { path: \"\/campaign\/create\", element: &lt;CreateCampaign \/> }, { path: \"\/campaign\/edit\/:id\", element: &lt;EditCampaign \/> }, ], }, ], }, ]);  export default function Router() { return &lt;RouterProvider router={router} \/>; }<\/code><\/pre>\n<p><strong>Storage<\/strong><\/p>\n<p>\u042f \u0441\u043e\u0437\u0434\u0430\u043b RootStore \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e factory create models. \u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"typescript\">import { createContext } from \"react\"; import Campaign from \".\/campaign\"; import Dashboard from \".\/dashboard\"; import Api from \"@\/api\";  export interface ModelInterface { [key: string]: any; }  interface ModelConstructor { new (context: RootStore): ModelInterface; }  function createModel&lt;T>( ctor: ModelConstructor, context: RootStore ): T { return new ctor(context) as T; }  export class RootStore { api: Api; campaign: Campaign; dashboard: Dashboard;  constructor(api: Api) { this.api = api;  this.campaign = createModel&lt;Campaign>(Campaign, this); this.dashboard = createModel&lt;Dashboard>(Dashboard, this); } } const api = new Api({ ecwidStore: { payload: \"c2bh2nmjkkoa2\" }, }); export const store = new RootStore(api); export type StoreType = RootStore | Record&lt;string, never>; export const StoreContext = createContext&lt;StoreType>({});<\/code><\/pre>\n<p><strong>API<\/strong><\/p>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 Axios \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0448\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 401.<\/p>\n<pre><code class=\"typescript\">import axios, {AxiosInstance} from \"axios\";  import {endpointsInitFactory} from \".\/endpoints\";  type InitialType = { ecwidStore: { payload: string } }  class Api { endpoints axios: AxiosInstance constructor(initial: InitialType) { this.axios = axios.create({ baseURL: process.env.REACT_APP_BASE_URL, headers: { \"Content-Type\": \"application\/json\", \"ecwid-payload\": initial.ecwidStore.payload, }, });  this.endpoints = endpointsInitFactory(this.axios) } }  export default Api; <\/code><\/pre>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0430\u043b\u0438\u0430\u0441\u043e\u0432<\/strong><\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b \u043f\u0440\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0435 \u043c\u043e\u0434\u0443\u043b\u0435\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c \u0432\u043c\u0435\u0441\u0442\u0435.<\/p>\n<p>\u0412 \u0432\u0430\u0448\u0435\u043c tsconfig.json \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043f\u0443\u0442\u044c:<\/p>\n<pre><code class=\"json\">{     \"compilerOptions\": {         \"paths\": {             \"@\/*\": [\".\/src\/*\"]         },     }, }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0430\u043a\u0435\u0442 <code>npm install <a class=\"mention\" href=\"\/users\/craco\">@craco<\/a>\/craco --save<\/code> \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0432\u0441\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 package.json<\/p>\n<pre><code class=\"json\">\"scripts\": {     \"start\": \"craco start\",     \"build\": \"craco build\",     \"test\": \"craco test\",     \"eject\": \"craco eject\"   },<\/code><\/pre>\n<h2>\u041e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b<\/h2>\n<p>\u041d\u0438\u0436\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 ReactJS \u043d\u0430 CodeSandbox.<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/665f31aa87bb36d4b3a0d179\" data-style=\"\" id=\"665f31aa87bb36d4b3a0d179\" width=\"\"><\/div>\n<h4>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 ui-kit<\/h4>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u044f \u043d\u0435 \u0441\u0442\u0430\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0438\u0437\u0430\u0439\u043d, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 Ecwid \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439 css framework <a href=\"https:\/\/developers.ecwid.com\/ecwid-css-framework\/\" rel=\"noopener noreferrer nofollow\">https:\/\/developers.ecwid.com\/ecwid-css-framework\/<\/a><\/p>\n<p>\u041e\u043d\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0432 html \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 css &amp; js \u0444\u0430\u0439\u043b\u044b. \u0418 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c html \u0432\u0451\u0440\u0442\u0441\u043a\u0443, \u043d\u043e \u044d\u0442\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e\u0434 React \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0443, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0430 ReactJS \u0441\u0442\u044d\u043a \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p><strong>Checkbox<\/strong><\/p>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 html \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430, \u0430 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c disabled \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u043b\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440?<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0430 disabled \u0438 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/p>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e!<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 src \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e ui-kit, \u0442\u0443\u0442 \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 Ecwid CSS framework. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e base \u2013 \u0442\u0443\u0442 \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u041e\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0432\u0441\u0435 class \u043d\u0430 className \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0442\u0435\u0433\u0438 \u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 Props<\/p>\n<\/li>\n<\/ol>\n<div class=\"floating-image\">\n<figure class=\"float bordered full-width\"><\/figure>\n<\/div>\n<div class=\"floating-image\">\n<figure class=\"float full-width\">\n<div><figcaption>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0441\u0442\u0438\u043b\u0438<\/figcaption><\/div>\n<\/figure>\n<\/div>\n<pre><code class=\"xml\">&lt;head>   &lt;link rel=\"stylesheet\" href=\"https:\/\/d35z3p2poghz10.cloudfront.net\/ecwid-sdk\/css\/1.3.19\/ecwid-app-ui.css\"\/> &lt;\/head>  &lt;body>      &lt;div>Some content&lt;\/div>    &lt;script type=\"text\/javascript\" src=\"https:\/\/d35z3p2poghz10.cloudfront.net\/ecwid-sdk\/css\/1.3.19\/ecwid-app-ui.min.js\">&lt;\/script> &lt;\/body><\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430.<\/p>\n<h2>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0434\u043b\u044f frontend \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0412 \u043d\u0430\u0448\u0438\u0445 \u043c\u0430\u043a\u0435\u0442\u0430\u0445 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 4 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<ul>\n<li>\n<p>Dashboard \u2013 \u0442\u0443\u0442 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c Instagram \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u043a\u0443\u0434\u0430<\/p>\n<\/li>\n<li>\n<p>Create campaign \u2013 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 2 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 <\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u0431\u043e\u0440 \u0442\u0438\u043f\u0430 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0424\u043e\u0440\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Edit campaign \u2013 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<h3>Dashboard page<\/h3>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0443 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0451\u0440\u0441\u0442\u043a\u0435, \u0430 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f Instagram account \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c SDK \u0432 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u043d\u0435\u0446 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0412\u044b\u043d\u0435\u0441\u0435\u043c appId \u0432 env (REACT_APP_FACEBOOK_APP_ID) \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u044f\u0441\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0434\u043e\u0432\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 window \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u0435 FB<\/p>\n<pre><code class=\"xml\">&lt;script>     window.fbAsyncInit = function() {         FB.init({             appId      : '%REACT_APP_FACEBOOK_APP_ID%',             cookie     : true,             xfbml      : true,             version    : 'v9.0'         });          FB.AppEvents.logPageView();      };      (function(d, s, id){         var js, fjs = d.getElementsByTagName(s)[0];         if (d.getElementById(id)) {return;}         js = d.createElement(s); js.id = id;         js.src = \"https:\/\/connect.facebook.net\/en_US\/sdk.js\";         fjs.parentNode.insertBefore(js, fjs);     }(document, 'script', 'facebook-jssdk')); &lt;\/script><\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Dashboard.jsx, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 3 \u0447\u0430\u0441\u0442\u0435\u0439, \u0448\u0430\u043f\u043a\u0430 \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c Instagram, \u043d\u0438\u0436\u0435 \u0431\u043b\u043e\u043a \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430, \u0442.\u043a. \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438 \u0442\u043e\u043a\u0435\u043d\u0430, \u0438 \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0430\u0440\u043e\u043b\u044c \u043e\u0442 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430, \u0442\u043e \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c \u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d.<\/p>\n<p>\u0412<code>useEffect<\/code> \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0435 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u044b, \u043f\u043e\u0441\u043b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430\u043c \u0432\u0435\u0440\u043d\u0451\u0442 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u044b \u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u043e\u043b\u0435 <code>fbNeedToUpdate == true<\/code> , \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c <code>useEffect<\/code> \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0436\u0438\u0434\u0430\u0442\u044c\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f <code>fbNeedToUpdate<\/code> \u0432 store. \u0415\u0441\u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 SDK \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d \u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u043e\u0439\u0434\u0451\u0442 \u0432\u0441\u0451 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e.<\/p>\n<blockquote>\n<p>\u0412\u0430\u0436\u043d\u043e! \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 Instagram \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u044f\u0437\u044c \u0431\u0438\u0437\u043d\u0435\u0441 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b Instagram &amp; Facebook Page, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043a\u043e\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f <\/p>\n<\/blockquote>\n<pre><code class=\"javascript\">\/\/ getting Facebook Page status useEffect(() => {     getSavePages(); }, [])  \/\/ Updating facebook token useEffect(() => {     if (fbNeedToUpdate !== null &amp;&amp; fbNeedToUpdate) {         getFBLoginStatus();     } }, [fbNeedToUpdate]);  const getFBLoginStatus = () => {     window.FB.getLoginStatus((response) => {         console.log('Good to see you, ', response);         const {status, authResponse} = response;         setFbLoginStatus(status);         if (status === 'connected') {             const {accessToken, userID} = authResponse;             setFacebookData(accessToken, userID);             getPages();         }     }); };<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0435\u0439\u0441, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0438 \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043f\u043e\u0432\u0435\u0441\u0438\u043c \u0435\u0433\u043e \u043d\u0430 button \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 onClick. \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c  \u0442\u043e\u043a\u0435\u043d \u0438 uderID \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<pre><code class=\"javascript\">const loginInst = () => {     window.FB.login((response) => {         if (response.status === 'connected') {             const {accessToken,<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-378031","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=378031"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378031\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=378031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=378031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=378031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}