Files
biiproject-kit-v2/public/build/assets/Index-Cx7Ouq_R.js
T

1 line
18 KiB
JavaScript

import{a as e,c as t,d as n,l as r,n as i,o as a,t as o}from"./app-BK5KCPMc.js";import{t as s}from"./AuthenticatedLayout-BjuyW-Hp.js";import{t as c}from"./swal-D8hRpOIh.js";import{n as l,r as u,t as d}from"./filepond-plugin-file-validate-type-tybTRj_0.js";var f=n(t(),1),p=u(),m=n(l(),1),h=n(d(),1),g=o();(0,p.registerPlugin)(m.default,h.default);function _({title:e,description:t,children:n,delay:r=`0s`}){return(0,g.jsxs)(`div`,{className:`bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden h-full flex flex-col anim-up`,style:{animationDelay:r},children:[(0,g.jsxs)(`div`,{className:`px-6 py-4 border-b border-gray-50 bg-gray-50/30`,children:[(0,g.jsx)(`h2`,{className:`text-sm font-bold text-[#3D4E4B] tracking-tight`,children:e}),(0,g.jsx)(`p`,{className:`text-xs text-gray-400 font-semibold tracking-tight mt-1`,children:t})]}),(0,g.jsx)(`div`,{className:`p-8 flex-1`,children:n})]})}function v({label:e,description:t,checked:n,onChange:r}){return(0,g.jsxs)(`div`,{className:`flex items-center justify-between py-3 border-b border-gray-50 last:border-0 hover:bg-gray-50/30 px-2 -mx-2 rounded-xl transition-colors group`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-sm font-bold text-[#3D4E4B] tracking-tight group-hover:text-[#D4A017] transition-colors`,children:e}),(0,g.jsx)(`div`,{className:`text-xs text-gray-400 font-medium`,children:t})]}),(0,g.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,g.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:n,onChange:e=>r(e.target.checked)}),(0,g.jsx)(`div`,{className:`w-10 h-5 bg-gray-300 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-400 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#D4A017] peer-checked:after:border-[#D4A017] border border-gray-200`})]})]})}function y({label:e,value:t,onChange:n,type:r=`text`,placeholder:i=``,error:a=``,required:o=!1,maxLength:s,id:c}){return(0,g.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,g.jsxs)(`label`,{htmlFor:c,className:`block text-xs font-semibold text-gray-500 tracking-tight ml-1`,children:[e,` `,o&&(0,g.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,g.jsx)(`input`,{id:c,type:r,value:t,onChange:e=>n(e.target.value),placeholder:i,maxLength:s,className:`input-field${a?` is-error`:``}`}),a&&(0,g.jsx)(`p`,{className:`text-xs text-red-500 font-semibold ml-1 mt-1`,children:a})]})}var b=[`general`,`security`,`email`,`mobile`];function x(){let e=window.location.hash.replace(`#`,``);return b.includes(e)?e:`general`}function S({settings:t}){let[n,o]=(0,f.useState)(x);(0,f.useEffect)(()=>{let e=()=>o(x());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let l=e=>{window.location.hash=e,o(e)},{auth:u}=a().props,[d,m]=(0,f.useState)(u?.user?.email||``),[h,b]=(0,f.useState)(!1),S=async()=>{if(d){b(!0);try{let e=await r.post(route(`system.settings.test-email`),{recipient:d,mail_host:C.settings.mail_host,mail_port:C.settings.mail_port,mail_username:C.settings.mail_username,mail_password:C.settings.mail_password,mail_encryption:C.settings.mail_encryption,mail_from_address:C.settings.mail_from_address,mail_from_name:C.settings.mail_from_name});e.data.success?c.success(`Success`,e.data.message||`Test email sent successfully!`):c.error(`SMTP Error`,e.data.message||`Failed to send test email.`)}catch(e){c.error(`Error`,e.response?.data?.message||e.message||`An error occurred.`)}finally{b(!1)}}},{data:C,setData:w,post:T,processing:E,errors:D}=e({settings:{app_name:t.app_name||``,app_logo_text:t.app_logo_text||`B`,app_description:t.app_description||``,allow_registration:t.allow_registration===`1`||t.allow_registration===!0,require_email_verification:t.require_email_verification===`1`||t.require_email_verification===!0,password_minimum_length:parseInt(t.password_minimum_length)||8,password_require_symbols:t.password_require_symbols===`1`||t.password_require_symbols===!0,password_require_numbers:t.password_require_numbers===`1`||t.password_require_numbers===!0,password_require_mixed_case:t.password_require_mixed_case===`1`||t.password_require_mixed_case===!0,two_factor_totp_enabled:t.two_factor_totp_enabled===`1`||t.two_factor_totp_enabled===!0,two_factor_email_enabled:t.two_factor_email_enabled===`1`||t.two_factor_email_enabled===!0,oauth_google_enabled:t.oauth_google_enabled===`1`||t.oauth_google_enabled===!0,oauth_google_client_id:t.oauth_google_client_id||``,oauth_google_client_secret:t.oauth_google_client_secret||``,oauth_github_enabled:t.oauth_github_enabled===`1`||t.oauth_github_enabled===!0,oauth_github_client_id:t.oauth_github_client_id||``,oauth_github_client_secret:t.oauth_github_client_secret||``,mail_host:t.mail_host||``,mail_port:t.mail_port||``,mail_username:t.mail_username||``,mail_password:t.mail_password||``,mail_encryption:t.mail_encryption||`tls`,mail_from_address:t.mail_from_address||``,mail_from_name:t.mail_from_name||``,primary_color:t.primary_color||`#D4A017`,android_latest_version:t.android_latest_version||`1.0.0`,android_min_version:t.android_min_version||`1.0.0`,android_maintenance_mode:t.android_maintenance_mode===`1`||t.android_maintenance_mode===!0,android_playstore_url:t.android_playstore_url||``},logo_file:null,_method:`PATCH`}),[O,k]=(0,f.useState)([]),A=(e,t)=>{w(`settings`,{...C.settings,[e]:t})};return(0,g.jsxs)(s,{children:[(0,g.jsx)(i,{title:`System Settings`}),(0,g.jsxs)(`div`,{className:`flex items-center justify-between mb-8 anim-down`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h1`,{className:`text-xl font-bold text-[#3D4E4B] tracking-tight leading-none`,children:`System Configuration`}),(0,g.jsx)(`p`,{className:`text-sm font-semibold text-gray-400 tracking-tight mt-2`,children:`Manage global application behavior and external protocols`})]}),(0,g.jsx)(`button`,{onClick:e=>{e.preventDefault(),T(route(`system.settings.update`),{preserveScroll:!0,onSuccess:()=>c.success(`Saved`,`System settings updated successfully.`)})},disabled:E,className:`h-10 px-8 bg-[#3D4E4B] text-white text-sm font-bold tracking-tight rounded-xl hover:bg-[#2D3A38] transition-all shadow-lg shadow-[#3D4E4B]/20 disabled:opacity-60 disabled:cursor-not-allowed`,children:E?`Saving...`:`Save Configuration`})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-gray-100 w-full mb-8 anim-down`,style:{animationDelay:`0.05s`},children:[(0,g.jsxs)(`button`,{type:`button`,onClick:()=>l(`general`),className:`relative pb-3 px-1 mr-8 text-sm font-bold tracking-tight transition-colors ${n===`general`?`text-[#3D4E4B]`:`text-gray-400 hover:text-[#3D4E4B]`}`,children:[`General & Branding`,n===`general`&&(0,g.jsx)(`span`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-[#D4A017] rounded-t-full`})]}),(0,g.jsxs)(`button`,{type:`button`,onClick:()=>l(`security`),className:`relative pb-3 px-1 mr-8 text-sm font-bold tracking-tight transition-colors ${n===`security`?`text-[#3D4E4B]`:`text-gray-400 hover:text-[#3D4E4B]`}`,children:[`Security & OAuth`,n===`security`&&(0,g.jsx)(`span`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-[#D4A017] rounded-t-full`})]}),(0,g.jsxs)(`button`,{type:`button`,onClick:()=>l(`email`),className:`relative pb-3 px-1 mr-8 text-sm font-bold tracking-tight transition-colors ${n===`email`?`text-[#3D4E4B]`:`text-gray-400 hover:text-[#3D4E4B]`}`,children:[`Email Protocol`,n===`email`&&(0,g.jsx)(`span`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-[#D4A017] rounded-t-full`})]}),(0,g.jsxs)(`button`,{type:`button`,onClick:()=>l(`mobile`),className:`relative pb-3 px-1 text-sm font-bold tracking-tight transition-colors ${n===`mobile`?`text-[#3D4E4B]`:`text-gray-400 hover:text-[#3D4E4B]`}`,children:[`Mobile App Control`,n===`mobile`&&(0,g.jsx)(`span`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-[#D4A017] rounded-t-full`})]})]}),(0,g.jsxs)(`div`,{className:`space-y-8 pb-20`,children:[n===`general`&&(0,g.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-8 anim-fade`,children:[(0,g.jsx)(_,{title:`Application Branding`,description:`Logo and visual identity`,delay:`0.1s`,children:(0,g.jsxs)(`div`,{className:`space-y-8`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center gap-8`,children:[(0,g.jsx)(`div`,{className:`w-24 h-24 rounded-2xl flex items-center justify-center text-white text-3xl font-bold shrink-0 border border-gray-100 shadow-sm ${t.app_logo?`bg-white`:`bg-[#3D4E4B]`}`,children:t.app_logo?(0,g.jsx)(`img`,{src:t.app_logo,className:`w-full h-full object-contain`}):C.settings.app_logo_text||`B`}),(0,g.jsx)(`div`,{className:`flex-1 w-full`,children:(0,g.jsx)(p.FilePond,{files:O,onupdatefiles:e=>{k(e),w(`logo_file`,e[0]?.file||null)},allowMultiple:!1,maxFiles:1,labelIdle:`Drop Logo here`})})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-6`,children:[(0,g.jsx)(y,{label:`App Name`,value:C.settings.app_name,onChange:e=>A(`app_name`,e),required:!0,placeholder:`e.g. Biiskit Platform`}),(0,g.jsx)(y,{label:`Logo Text`,value:C.settings.app_logo_text,onChange:e=>A(`app_logo_text`,e),maxLength:3,required:!0,placeholder:`e.g. B`})]})]})}),(0,g.jsx)(_,{title:`Public Policy`,description:`Manage open registration and access`,delay:`0.15s`,children:(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(v,{label:`Public Registration`,description:`Allow new users to create accounts`,checked:C.settings.allow_registration,onChange:e=>A(`allow_registration`,e)}),(0,g.jsx)(v,{label:`Email Verification`,description:`Require email validation for new accounts`,checked:C.settings.require_email_verification,onChange:e=>A(`require_email_verification`,e)})]})})]}),n===`security`&&(0,g.jsxs)(`div`,{className:`space-y-8 anim-fade`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-8`,children:[(0,g.jsx)(_,{title:`Password Standards`,description:`Complexity requirements for user access`,delay:`0.1s`,children:(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(v,{label:`Require Symbols`,description:`Include special characters (!@#$)`,checked:C.settings.password_require_symbols,onChange:e=>A(`password_require_symbols`,e)}),(0,g.jsx)(v,{label:`Require Numbers`,description:`Include numerical digits (0-9)`,checked:C.settings.password_require_numbers,onChange:e=>A(`password_require_numbers`,e)}),(0,g.jsx)(v,{label:`Require Mixed Case`,description:`Force Uppercase and Lowercase letters`,checked:C.settings.password_require_mixed_case,onChange:e=>A(`password_require_mixed_case`,e)}),(0,g.jsxs)(`div`,{className:`flex items-center justify-between py-4 mt-2 border-t border-gray-50`,children:[(0,g.jsx)(`span`,{className:`text-sm font-bold text-[#3D4E4B]`,children:`Minimum Length`}),(0,g.jsx)(`input`,{type:`number`,value:C.settings.password_minimum_length,onChange:e=>A(`password_minimum_length`,parseInt(e.target.value)),className:`w-16 h-10 input-field text-center px-2 text-[#D4A017] font-bold`})]})]})}),(0,g.jsx)(_,{title:`Two-Factor Authentication (2FA)`,description:`Configure globally available 2FA options for users`,delay:`0.12s`,children:(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(v,{label:`Google Authenticator (TOTP)`,description:`Allow users to use Authenticator Apps (Google, Authy, etc.)`,checked:C.settings.two_factor_totp_enabled,onChange:e=>A(`two_factor_totp_enabled`,e)}),(0,g.jsx)(v,{label:`Email 2FA`,description:`Allow users to receive 6-digit OTP codes via email (requires SMTP configuration)`,checked:C.settings.two_factor_email_enabled,onChange:e=>A(`two_factor_email_enabled`,e)})]})})]}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-8`,children:(0,g.jsx)(_,{title:`OAuth Providers`,description:`Third-party authentication protocols`,delay:`0.15s`,children:(0,g.jsx)(`div`,{className:`space-y-6`,children:[`google`,`github`].map(e=>(0,g.jsxs)(`div`,{className:`p-6 rounded-2xl bg-gray-50/50 border border-gray-100`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,g.jsxs)(`div`,{className:`text-sm font-bold text-[#3D4E4B] tracking-tight capitalize flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`w-2 h-2 rounded-full ${C.settings[`oauth_${e}_enabled`]?`bg-green-500`:`bg-gray-300`}`}),e,` Login`]}),(0,g.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer scale-90`,children:[(0,g.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:C.settings[`oauth_${e}_enabled`],onChange:t=>A(`oauth_${e}_enabled`,t.target.checked)}),(0,g.jsx)(`div`,{className:`w-10 h-5 bg-gray-300 rounded-full peer peer-checked:bg-[#D4A017] after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-400 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:after:translate-x-full border border-gray-200`})]})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,g.jsx)(y,{label:`Client ID`,value:C.settings[`oauth_${e}_client_id`],onChange:t=>A(`oauth_${e}_client_id`,t),placeholder:`Enter ${e} Client ID`}),(0,g.jsx)(y,{label:`Client Secret`,type:`password`,value:C.settings[`oauth_${e}_client_secret`],onChange:t=>A(`oauth_${e}_client_secret`,t),placeholder:`••••••••`})]})]},e))})})})]}),n===`email`&&(0,g.jsxs)(`div`,{className:`max-w-5xl space-y-8 anim-fade`,children:[(0,g.jsx)(_,{title:`Mail Transmission`,description:`SMTP server configuration for system notifications`,delay:`0.1s`,children:(0,g.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-8`,children:[(0,g.jsxs)(`div`,{className:`md:col-span-2 space-y-6`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-3 gap-6`,children:[(0,g.jsx)(`div`,{className:`col-span-2`,children:(0,g.jsx)(y,{label:`Mail Host`,value:C.settings.mail_host,onChange:e=>A(`mail_host`,e),placeholder:`e.g. smtp.mailtrap.io`,required:!0})}),(0,g.jsx)(y,{label:`Port`,value:C.settings.mail_port,onChange:e=>A(`mail_port`,e),placeholder:`e.g. 587`,required:!0})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,g.jsx)(y,{label:`Username`,value:C.settings.mail_username,onChange:e=>A(`mail_username`,e),placeholder:`e.g. user_key_123`}),(0,g.jsx)(y,{label:`Password`,type:`password`,value:C.settings.mail_password,onChange:e=>A(`mail_password`,e),placeholder:`••••••••`})]})]}),(0,g.jsxs)(`div`,{className:`space-y-6 pt-6 md:pt-0 border-t md:border-t-0 md:border-l border-gray-100 md:pl-8`,children:[(0,g.jsx)(y,{label:`Sender Address`,value:C.settings.mail_from_address,onChange:e=>A(`mail_from_address`,e),placeholder:`e.g. no-reply@app.com`,required:!0}),(0,g.jsx)(y,{label:`Sender Name`,value:C.settings.mail_from_name,onChange:e=>A(`mail_from_name`,e),placeholder:`e.g. System Admin`,required:!0})]})]})}),(0,g.jsx)(_,{title:`SMTP Connection Test`,description:`Verify your SMTP transmission parameters by sending a test email`,delay:`0.15s`,children:(0,g.jsxs)(`div`,{className:`max-w-xl space-y-6`,children:[(0,g.jsxs)(`div`,{className:`p-4 rounded-xl bg-gray-50/50 border border-gray-100 flex items-start gap-3`,children:[(0,g.jsx)(`svg`,{className:`w-5 h-5 text-[#D4A017] mt-0.5 shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})}),(0,g.jsx)(`p`,{className:`text-xs text-[#3D4E4B] font-semibold leading-relaxed`,children:`This test will use the SMTP values entered in the form above. You don't need to save the configuration first to test it.`})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-6 items-end`,children:[(0,g.jsx)(`div`,{className:`sm:col-span-2`,children:(0,g.jsx)(y,{label:`Recipient Email Address`,value:d,onChange:m,placeholder:`e.g. you@example.com`,required:!0})}),(0,g.jsx)(`button`,{type:`button`,onClick:S,disabled:h||!d,className:`h-10 px-6 bg-[#3D4E4B] text-white text-xs font-bold tracking-tight rounded-xl hover:bg-[#2D3A38] transition-all shadow-md shadow-[#3D4E4B]/10 disabled:opacity-60 disabled:cursor-not-allowed flex items-center justify-center gap-2`,children:h?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`svg`,{className:`animate-spin h-4 w-4 text-white`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,g.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,g.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),(0,g.jsx)(`span`,{children:`Transmitting...`})]}):`Send Test Email`})]})]})})]}),n===`mobile`&&(0,g.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-8 anim-fade`,children:[(0,g.jsx)(_,{title:`Version Management`,description:`Control Android application lifecycle`,delay:`0.1s`,children:(0,g.jsxs)(`div`,{className:`space-y-8`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,g.jsx)(y,{label:`Latest Version`,value:C.settings.android_latest_version,onChange:e=>A(`android_latest_version`,e),placeholder:`e.g. 1.2.0`}),(0,g.jsx)(y,{label:`Min Required Version`,value:C.settings.android_min_version,onChange:e=>A(`android_min_version`,e),placeholder:`e.g. 1.0.5`})]}),(0,g.jsx)(y,{label:`Play Store URL`,value:C.settings.android_playstore_url,onChange:e=>A(`android_playstore_url`,e),placeholder:`https://play.google.com/store/apps/details?id=...`})]})}),(0,g.jsx)(_,{title:`Mobile Availability`,description:`Control API accessibility for devices`,delay:`0.15s`,children:(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsx)(v,{label:`Maintenance Mode`,description:`Block Android API access for maintenance`,checked:C.settings.android_maintenance_mode,onChange:e=>A(`android_maintenance_mode`,e)}),(0,g.jsxs)(`div`,{className:`p-4 rounded-xl bg-amber-50 border border-amber-100 mt-4`,children:[(0,g.jsx)(`p`,{className:`text-[10px] font-bold text-amber-800 leading-relaxed uppercase tracking-widest mb-1`,children:`Warning`}),(0,g.jsx)(`p`,{className:`text-[11px] text-amber-700 font-medium`,children:`Enabling maintenance mode will return a 503 error to all mobile devices connecting to the API.`})]})]})})]})]})]})}export{S as default};