%PDF- %PDF-
Direktori : /home/tradesc/www/relax/wp-content/plugins/woocommerce/assets/client/admin/chunks/ |
Current File : /home/tradesc/www/relax/wp-content/plugins/woocommerce/assets/client/admin/chunks/store-alerts.js |
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[8597],{93098:(e,t,o)=>{o.r(t),o.d(t,{StoreAlerts:()=>A,default:()=>L});var a=o(69307),s=o(65736),r=o(55609),n=o(7829),l=o(76357),c=o(9818),i=o(76292),m=o.n(i),d=o(23374),u=o(70048),_=o(83619),p=o(70261),g=o(67221),h=o(14599),w=o(10431),E=o(346),N=o(7862),b=o.n(N);class f extends a.Component{render(){const{hasMultipleAlerts:e,className:t}=this.props;return(0,a.createElement)(r.Card,{className:(0,n.Z)("woocommerce-store-alerts is-loading",t),"aria-hidden":!0,size:null},(0,a.createElement)(r.CardHeader,{isBorderless:!0},(0,a.createElement)("span",{className:"is-placeholder"}),e&&(0,a.createElement)("span",{className:"is-placeholder"})),(0,a.createElement)(r.CardBody,null,(0,a.createElement)("div",{className:"woocommerce-store-alerts__message"},(0,a.createElement)("span",{className:"is-placeholder"}),(0,a.createElement)("span",{className:"is-placeholder"}))),(0,a.createElement)(r.CardFooter,{isBorderless:!0},(0,a.createElement)("span",{className:"is-placeholder"})))}}const v=f;f.propTypes={hasMultipleAlerts:b().bool},f.defaultProps={hasMultipleAlerts:!1};var C=o(17062),T=o(53736),k=o(53332);const S={page:1,per_page:g.QUERY_DEFAULTS.pageSize,type:"error,update",status:"unactioned"};function y(e){return(e||[]).filter((e=>"unactioned"===e.status&&!0!==e.is_deleted))}const A=()=>{const[e,t]=(0,a.useState)(0),{alerts:o=[],isLoading:i,defaultHomescreenLayout:N,taskListComplete:b,isTaskListHidden:f,isLoadingTaskLists:A}=(0,c.useSelect)((e=>{const{getNotes:t,hasFinishedResolution:o}=e(g.NOTES_STORE_NAME),{getOption:a}=e(g.OPTIONS_STORE_NAME),{getTaskList:s,hasFinishedResolution:r}=e(g.ONBOARDING_STORE_NAME);return{alerts:y(t(S)),isLoading:!o("getNotes",[S]),defaultHomescreenLayout:a("woocommerce_default_homepage_layout")||"single_column",taskListComplete:s("setup")?.isComplete,isTaskListHidden:s("setup")?.isHidden,isLoadingTaskLists:!r("getTaskLists")}})),{triggerNoteAction:L,updateNote:M,removeNote:O}=(0,c.useDispatch)(g.NOTES_STORE_NAME),{createNotice:B}=(0,c.useDispatch)("core/notices"),Z=(0,g.useUserPreferences)();function x(o){o?.stopPropagation(),e>0&&t(e-1)}if(A)return null;const z=(0,C.O3)("alertCount",0,(e=>parseInt(e,10))),R=(0,w.isWCAdmin)(),F=R&&"homescreen"===(0,w.getScreenFromPath)(),H=(0,k.tv)(Z.homepage_layout,N,b,f);if(z>0&&i)return(0,a.createElement)(v,{className:(0,n.Z)({"is-wc-admin-page":R,"is-homescreen":F,"two-columns":H&&F}),hasMultipleAlerts:z>1});if(0===o.length)return null;const P=o.length,D=o[e],I=D.type,U=(0,n.Z)("woocommerce-store-alerts",{"is-alert-error":"error"===I,"is-alert-update":"update"===I,"is-wc-admin-page":R,"is-homescreen":F,"two-columns":H&&F});return(0,a.createElement)(r.Card,{className:U,size:null},(0,a.createElement)(r.CardHeader,{className:"woocommerce-store-alerts__header",isBorderless:!0},(0,a.createElement)("span",{className:"woocommerce-store-alerts__title"},D.title),P>1&&(0,a.createElement)("div",{className:"woocommerce-store-alerts__pagination"},(0,a.createElement)("span",{className:"woocommerce-store-alerts__pagination-label",role:"status","aria-live":"polite"},(0,l.Z)({mixedString:(0,s.__)("{{current /}} of {{total /}}","woocommerce"),components:{current:(0,a.createElement)(a.Fragment,null,e+1),total:(0,a.createElement)(a.Fragment,null,P)}})),(0,a.createElement)(r.Button,{onClick:x,disabled:0===e,label:(0,s.__)("Previous Alert","woocommerce")},(0,a.createElement)(d.Z,{icon:u.Z,className:"arrow-left-icon"})),(0,a.createElement)(r.Button,{onClick:function(a){a.stopPropagation(),e<o.length-1&&t(e+1)},disabled:P-1===e,label:(0,s.__)("Next Alert","woocommerce")},(0,a.createElement)(d.Z,{icon:_.Z,className:"arrow-right-icon"}))),(0,a.createElement)(r.Button,{className:"woocommerce-store-alerts__close",onClick:()=>(async e=>{const t=(0,T.GG)();(0,h.recordEvent)("inbox_action_dismiss",{note_name:e.name,note_title:e.title,note_name_dismiss_all:!1,note_name_dismiss_confirmation:!0,screen:t});const o=e.id;try{await O(o),B("success",(0,s.__)("Message dismissed","woocommerce"))}catch(e){B("error",(0,s._n)("Message could not be dismissed","Messages could not be dismissed",1,"woocommerce"))}})(D)},(0,a.createElement)(d.Z,{width:"18",height:"18",icon:p.Z}))),(0,a.createElement)(r.CardBody,null,(0,a.createElement)("div",{className:"woocommerce-store-alerts__message",dangerouslySetInnerHTML:(0,E.ZP)(D.content)})),(0,a.createElement)(r.CardFooter,{isBorderless:!0},function(e){const t=e.actions.map(((t,o)=>{const n=0===o?"secondary":"tertiary";return(0,a.createElement)(r.Button,{key:`${e.id}-${t.label}-${t.name}`,variant:n,href:t.url||void 0,onClick:async o=>{const a=o.currentTarget.getAttribute("href");o.preventDefault(),x();try{await L(e.id,t.id),a&&"#"!==a&&(0,w.parseAdminUrl)(a).href!==window.location.href&&(0,w.navigateTo)({url:a})}catch(e){throw B("error",(0,s.__)("Something went wrong while triggering this note's action.","woocommerce")),e}}},t.label)})),o=[{value:m()().add(4,"hours").unix().toString(),label:(0,s.__)("Later Today","woocommerce")},{value:m()().add(1,"day").hour(9).minute(0).second(0).millisecond(0).unix().toString(),label:(0,s.__)("Tomorrow","woocommerce")},{value:m()().add(1,"week").hour(9).minute(0).second(0).millisecond(0).unix().toString(),label:(0,s.__)("Next Week","woocommerce")},{value:m()().add(1,"month").hour(9).minute(0).second(0).millisecond(0).unix().toString(),label:(0,s.__)("Next Month","woocommerce")}],n=e.is_snoozable&&(0,a.createElement)(r.SelectControl,{className:"woocommerce-store-alerts__snooze",options:[{label:(0,s.__)("Remind Me Later","woocommerce"),value:"0"},...o],onChange:t=>{if("0"===t)return;const a=o.find((e=>e.value===t));(t=>{M(e.id,{status:"snoozed",date_reminder:t.value});const o={alert_name:e.name,alert_title:e.title,snooze_duration:t.value,snooze_label:t.label};(0,h.recordEvent)("store_alert_snooze",o)})({value:t,label:a&&a.label})}});if(t||n)return(0,a.createElement)("div",{className:"woocommerce-store-alerts__actions"},t,n)}(D)))},L=A}}]);