(self.webpackChunk=self.webpackChunk||[]).push([[745],{14745:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>r});var i=s(5335);const o={props:["groups","type"],metaInfo:function(){return{title:this.trans("Archives")}},data:function(){return{visible:!1,selectedGroup:void 0,selectedType:this.type||"import",form:this.$inertia.form({title:void 0,type:"import",is_default:!1})}},computed:{columns:function(){var t=this;return i.map((function(e){return e.title=t.trans(e.title),e}))}},watch:{selectedType:function(t){this.$inertia.get(this.route("groups",{type:t}),{},{preserveState:!0}),this.form.type=t},visible:function(t){t&&this.selectedGroup?(this.form.title=this.selectedGroup.title,this.form.type=this.selectedGroup.type,this.form.is_default=!!this.selectedGroup.is_default):this.selectedGroup=void 0,this.selectedType!==this.form.type&&(this.form.type=this.selectedType)}},methods:{submit:function(){this.selectedGroup?this.update():this.create()},create:function(){var t=this;this.form.post(this.route("groups.store"),{onSuccess:function(){t.visible=!1,t.$message.success(t.trans("Success message")),t.form.reset()}})},update:function(){var t=this;this.form.put(this.route("groups.update",{group:this.selectedGroup.id}),{onSuccess:function(){t.visible=!1,t.$message.success(t.trans("Success message")),t.form.reset()}})},makeDefault:function(t){var e=this;this.$inertia.put(this.route("groups.update",{group:t}),{is_default:!0,type:this.selectedType},{onSuccess:function(){e.$message.success(e.trans("Success message"))}})}}};const r=(0,s(51900).Z)(o,(function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",[s("div",{staticClass:"flex bg-white p-4 text-lg border-b border-gray-300 h-20 items-center"},[s("div",{staticClass:"flex-1 font-semibold"},[t._v(t._s(t.trans("Archives")))]),t._v(" "),s("div",{staticClass:"space-x-3"},[s("a-radio-group",{attrs:{"button-style":"solid"},model:{value:t.selectedType,callback:function(e){t.selectedType=e},expression:"selectedType"}},[s("a-radio-button",{attrs:{value:"import"}},[t._v("\n          "+t._s(t.trans("Import"))+"\n        ")]),t._v(" "),s("a-radio-button",{attrs:{value:"export"}},[t._v("\n          "+t._s(t.trans("Export"))+"\n        ")])],1),t._v(" "),s("a-button",{attrs:{type:"primary"},on:{click:function(e){t.visible=!0}}},[t._v(t._s(t.trans("Create")))])],1)]),t._v(" "),s("a-table",{attrs:{dataSource:t.groups,columns:t.columns,pagination:!1,rowKey:"id"},scopedSlots:t._u([{key:"count",fn:function(e,i){return s("span",{},["export"===t.selectedType?s("span",[t._v(t._s(i.exports_count))]):s("span",[t._v(t._s(i.imports_count))])])}},{key:"is_default",fn:function(e){return s("span",{},[e?s("span",{staticClass:"px-2 py-1 rounded-md bg-primary uppercase font-semibold text-xs text-white"},[t._v(t._s(t.trans("Selected")))]):t._e()])}},{key:"actions",fn:function(e,i){return s("span",{},[i.file?s("a-tooltip",{attrs:{title:t.trans("Download excel")}},[s("a-button",{attrs:{icon:"file-excel"},on:{click:function(){return t.download(i.hashid)}}})],1):t._e(),t._v(" "),s("a-tooltip",{attrs:{title:t.trans("Select")}},[s("a-button",{attrs:{icon:"check"},on:{click:function(){return t.makeDefault(i.id)}}})],1),t._v(" "),s("a-tooltip",{attrs:{title:t.trans("Edit")}},[s("a-button",{attrs:{icon:"edit"},on:{click:function(){t.visible=!0,t.selectedGroup=i}}})],1),t._v(" "),s("a-tooltip",{attrs:{title:t.trans("Delete")}},[s("a-button",{attrs:{type:"danger",ghost:"",icon:"delete"},on:{click:function(){return t.destroy("groups",i.id)}}})],1)],1)}}])}),t._v(" "),s("a-modal",{attrs:{title:t.trans("Create"),"confirm-loading":t.form.processing,"ok-text":t.trans("OK"),"cancel-text":t.trans("Close"),"destroy-on-close":!0},on:{ok:t.submit},model:{value:t.visible,callback:function(e){t.visible=e},expression:"visible"}},[s("a-form",{nativeOn:{keypress:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.submit(e)}}},[s("a-form-item",{attrs:{label:t.trans("Title"),validateStatus:t.formStatus("title"),help:t.formHelp("title")}},[s("a-input",{attrs:{placeholder:t.trans("Title"),"auto-focus":""},model:{value:t.form.title,callback:function(e){t.$set(t.form,"title",e)},expression:"form.title"}})],1),t._v(" "),s("a-form-item",{attrs:{label:"",validateStatus:t.formStatus("is_default"),help:t.formHelp("is_default")}},[s("a-checkbox",{model:{value:t.form.is_default,callback:function(e){t.$set(t.form,"is_default",e)},expression:"form.is_default"}},[t._v(t._s(t.trans("Selected"))+"?")])],1)],1)],1)],1)}),[],!1,null,null,null).exports},5335:t=>{"use strict";t.exports=JSON.parse('[{"dataIndex":"title","key":"title","title":"Title"},{"key":"count","title":"Count","scopedSlots":{"customRender":"count"},"width":140},{"dataIndex":"is_default","key":"is_default","scopedSlots":{"customRender":"is_default"},"width":140},{"key":"actions","width":180,"align":"right","scopedSlots":{"customRender":"actions"}}]')}}]);