@webority/mobile-support 0.168.0 → 0.169.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/lib/commonjs/SupportProvider.js +1 -1
- package/lib/commonjs/components/NewSupportTicket.js +1 -1
- package/lib/commonjs/components/SupportTicketDetail.js +1 -1
- package/lib/commonjs/components/SupportUploadProgress.js +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/module/SupportProvider.js +1 -1
- package/lib/module/components/NewSupportTicket.js +1 -1
- package/lib/module/components/SupportTicketDetail.js +1 -1
- package/lib/module/components/SupportUploadProgress.js +1 -0
- package/lib/module/index.js +1 -1
- package/lib/typescript/commonjs/SupportProvider.d.ts +2 -1
- package/lib/typescript/commonjs/components/NewSupportTicket.d.ts +1 -1
- package/lib/typescript/commonjs/components/SupportUploadProgress.d.ts +7 -0
- package/lib/typescript/commonjs/index.d.ts +2 -1
- package/lib/typescript/module/SupportProvider.d.ts +2 -1
- package/lib/typescript/module/components/NewSupportTicket.d.ts +1 -1
- package/lib/typescript/module/components/SupportUploadProgress.d.ts +7 -0
- package/lib/typescript/module/index.d.ts +2 -1
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -124,6 +124,10 @@ const NewSupportTicketScreen = ({ navigation, route }) => (
|
|
|
124
124
|
the app tells the person the ticket is saved and will be sent when the device is back online,
|
|
125
125
|
in `onQueued`, which is also where the app leaves the form. Use `onQueued` to show the saved
|
|
126
126
|
entry in your own UI, and `onCreated` only for a ticket the server has.
|
|
127
|
+
While a file uploads, the new-ticket form and the reply composer show a progress bar with the percent sent.
|
|
128
|
+
`useSupportUploadProgress(queue)` returns the same progress (`null` when nothing is uploading) for an app drawing its own,
|
|
129
|
+
and `<SupportUploadProgress progress={progress} />` draws it as the forms do. Call the hook when the screen first renders,
|
|
130
|
+
not only while sending, so a small upload that reports before the bar appears is still shown.
|
|
127
131
|
- Both forms keep the focused field above the keyboard (mobile-ui's `KeyboardAwareScrollView`,
|
|
128
132
|
which needs the app's `KeyboardProvider` at the root).
|
|
129
133
|
- **SupportContact**: the support email with copy and compose, the phone number, and the hours.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useSupportTimeZone=exports.useSupportTickets=exports.useSupportTicket=exports.useSupportOutbox=exports.useSupportLabels=exports.useSupportConfig=exports.useSupportClient=exports.useCreateSupportTicket=exports.useAttachmentOpener=exports.useAttachmentLoader=exports.SupportProvider=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_client=require("./client.js"),_files=require("./files.js"),_types=require("./types.js"),_jsxRuntime=require("react/jsx-runtime");const SupportContext=(0,_react.createContext)(null),isRecord=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),isStringArray=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e),isSupportTicketDetail=e=>{if(!isRecord(e))return!1;const nullableString=e=>null===e||"string"==typeof e,nullableNumber=e=>null===e||"number"==typeof e,isLink=e=>isRecord(e)&&"string"==typeof e.id&&"string"==typeof e.number&&"string"==typeof e.subject;return"string"==typeof e.id&&"string"==typeof e.number&&"string"==typeof e.queue&&nullableNumber(e.accountId)&&nullableString(e.realm)&&"string"==typeof e.category&&"string"==typeof e.subject&&"string"==typeof e.status&&"string"==typeof e.statusLabel&&nullableString(e.priority)&&"string"==typeof e.reporterName&&(void 0===e.reporterPlace||"string"==typeof e.reporterPlace)&&"string"==typeof e.reporterEmail&&nullableNumber(e.assignedAgentUserId)&&nullableString(e.assignedAgentName)&&"boolean"==typeof e.isOverdue&&nullableString(e.pageUrl)&&nullableString(e.userAgent)&&nullableString(e.appVersion)&&nullableString(e.satisfaction)&&nullableString(e.satisfactionComment)&&"boolean"==typeof e.canReopen&&"boolean"==typeof e.canRate&&"boolean"==typeof e.canCancel&&"string"==typeof e.createdDateTimeUtc&&"string"==typeof e.updatedDateTimeUtc&&nullableString(e.resolvedDateTimeUtc)&&nullableString(e.closedDateTimeUtc)&&Array.isArray(e.messages)&&"string"==typeof e.version&&(void 0===e.mergedInto||isLink(e.mergedInto))&&(void 0===e.mergedTickets||Array.isArray(e.mergedTickets)&&e.mergedTickets.every(isLink))},parseSupportContactInfo=e=>{if(!isRecord(e))return null;const{productName:t,supportEmail:r,supportName:s,supportPhone:o,supportHours:a,categories:n,maxAttachmentBytes:u,maxAttachmentsPerMessage:c,allowedContentTypes:i,subjectMaxLength:p,bodyMaxLength:l,satisfactionCommentMaxLength:f}=e;return"string"!=typeof t||"string"!=typeof r||"string"!=typeof s||null!==o&&"string"!=typeof o||null!==a&&"string"!=typeof a||!isStringArray(n)||"number"!=typeof u||"number"!=typeof c||!isStringArray(i)||"number"!=typeof p||"number"!=typeof l||"number"!=typeof f?null:{productName:t,supportEmail:r,supportName:s,supportPhone:o,supportHours:a,categories:n,maxAttachmentBytes:u,maxAttachmentsPerMessage:c,allowedContentTypes:i,subjectMaxLength:p,bodyMaxLength:l,satisfactionCommentMaxLength:f}},SupportProvider=({client:e,outbox:t,openFile:r,timeZone:s,labels:o,children:a})=>{if(!t)throw new Error("[@webority/mobile-support] <SupportProvider> needs an outbox={...}, created with createOutbox from mobile-core.");const[n,u]=(0,_react.useState)(null),[c,i]=(0,_react.useState)(null),[p,l]=(0,_react.useState)(!0),[f,y]=(0,_react.useState)(0),_=(0,_react.useRef)(new Map),S=(0,_react.useCallback)(async()=>{l(!0);const t=`@webority/mobile-support/config:${e.basePath}`;try{const r=await e.getConfig();_mobileCore.Storage.setItem(t,JSON.stringify(r)),u(r),i(null)}catch(e){const r=(0,_client.toSupportApiError)(e);if(i(r),"offline"===r.code||"network"===r.code){const e=await _mobileCore.Storage.getJson(t,parseSupportContactInfo);e&&u(e)}}finally{l(!1)}},[e]);(0,_react.useEffect)(()=>{_.current.clear(),S()},[S]);const d=(0,_react.useCallback)(t=>{const r=_.current.get(t.id);if(r)return r;const s=e.getAttachmentDataUri(t);return _.current.set(t.id,s),s.catch(()=>_.current.delete(t.id)),s},[e]),g=(0,_react.useMemo)(()=>r?async t=>{const s=await(0,_files.saveAttachmentToCache)(t,()=>e.getAttachmentBytes(t.id));await r({uri:s,name:t.fileName,contentType:t.contentType})}:null,[e,r]),m=(0,_react.useCallback)(()=>y(e=>e+1),[]);(0,_react.useEffect)(()=>t.subscribe(e=>{"sent"!==e.type||e.entry.queue!==_types.SUPPORT_TICKET_QUEUE&&e.entry.queue!==_types.SUPPORT_REPLY_QUEUE||m()}),[t,m]);const b=(0,_react.useMemo)(()=>({client:e,outbox:t,config:n,configError:c,configLoading:p,reloadConfig:S,loadAttachment:d,openAttachment:g,timeZone:s,labels:o,revision:f,bumpRevision:m}),[e,t,n,c,p,S,d,g,s,o,f,m]);return(0,_jsxRuntime.jsx)(SupportContext.Provider,{value:b,children:a})};exports.SupportProvider=SupportProvider;const useSupportContext=()=>{const e=(0,_react.useContext)(SupportContext);if(!e)throw new Error("[@webority/mobile-support] Support screens and hooks need a <SupportProvider client={...}> above them.");return e},useSupportClient=()=>useSupportContext().client;exports.useSupportClient=useSupportClient;const useAttachmentLoader=()=>useSupportContext().loadAttachment;exports.useAttachmentLoader=useAttachmentLoader;const useAttachmentOpener=()=>useSupportContext().openAttachment;exports.useAttachmentOpener=useAttachmentOpener;const useSupportTimeZone=()=>useSupportContext().timeZone;exports.useSupportTimeZone=useSupportTimeZone;const useSupportLabels=(e,t)=>{const r=useSupportContext().labels?.[e];return(0,_react.useMemo)(()=>r?{...t,...r}:t,[r,t])};exports.useSupportLabels=useSupportLabels;const useSupportConfig=()=>{const{config:e,configLoading:t,configError:r,reloadConfig:s}=useSupportContext();return{config:e,loading:t,error:r,reload:s}};exports.useSupportConfig=useSupportConfig;const DEFAULT_PAGE_SIZE=20,useSupportTickets=(e={})=>{const t=e.pageSize??20,{client:r,revision:s}=useSupportContext(),[o,a]=(0,_react.useState)(null),[n,u]=(0,_react.useState)(""),[c,i]=(0,_react.useState)([]),[p,l]=(0,_react.useState)(null),[f,y]=(0,_react.useState)(0),[_,S]=(0,_react.useState)(0),[d,g]=(0,_react.useState)(!0),[m,b]=(0,_react.useState)(!1),[x,h]=(0,_react.useState)(!1),[C,E]=(0,_react.useState)(null),[T,k]=(0,_react.useState)(null),A=(0,_react.useRef)(!0),w=(0,_react.useRef)(0),P=(0,_react.useRef)(!1),R=(0,_react.useRef)(null);(0,_react.useEffect)(()=>(A.current=!0,()=>{A.current=!1}),[]);const v=(0,_react.useCallback)(e=>{const r=n.trim();return{...o?{status:o}:{},...r?{search:r}:{},page:e,pageSize:t}},[o,n,t]),U=(0,_react.useCallback)(async e=>{w.current+=1;const t=w.current,current=()=>A.current&&t===w.current;P.current=!1,h(!1),"refresh"===e?b(!0):"replace"===e&&(g(!0),i([]));const s="replace"!==e||R.current!==r;try{const[e,t]=await Promise.all([r.listTickets(v(1)),s?r.getTicketCounts():null]);current()&&(i(e.items),y(e.page),S(e.totalPages),t&&(l(t),R.current=r),E(null),k(null))}catch(e){current()&&E((0,_client.toSupportApiError)(e))}finally{current()&&(g(!1),b(!1))}},[r,v]),L=(0,_react.useRef)(s);(0,_react.useEffect)(()=>{const e=L.current===s?"replace":"quiet";L.current=s,U(e)},[U,s]);const O=f<_,q=(0,_react.useCallback)(async()=>{if(P.current||d||m||!O)return;const e=w.current,current=()=>A.current&&e===w.current;P.current=!0,h(!0),k(null);try{const e=await r.listTickets(v(f+1));current()&&(i(t=>{const r=new Set(t.map(e=>e.id));return[...t,...e.items.filter(e=>!r.has(e.id))]}),y(e.page),S(e.totalPages))}catch(e){current()&&k((0,_client.toSupportApiError)(e))}finally{current()&&(P.current=!1,h(!1))}},[r,v,f,O,d,m]),M=(0,_react.useCallback)(()=>U("refresh"),[U]),j=useCreateSupportTicket();return{tickets:c,counts:p,status:o,search:n,setStatus:a,setSearch:u,loading:d,refreshing:m,loadingMore:x,hasMore:O,error:C,loadMoreError:T,refresh:M,loadMore:q,createTicket:j}};exports.useSupportTickets=useSupportTickets;const sendThroughOutbox=async(e,t,r,s)=>{try{const o=await e.send({queue:t,label:r,request:s});if("Sent"===o.status){const{data:e}=o;return isSupportTicketDetail(e)?{status:"Sent",ticket:e}:{status:"Failed",error:new _client.SupportApiError("invalid-reply","The support desk sent a reply this app could not read. Try again.",null)}}return"Queued"===o.status?{status:"Queued",entry:o.entry}:{status:"Failed",error:new _client.SupportApiError(o.failure.code,o.failure.message,o.failure.status)}}catch(e){if(e instanceof Error&&"OutboxFullError"===e.name)return{status:"Failed",error:new _client.SupportApiError("outbox_full",e.message,null)};if(e instanceof Error&&"OutboxSignedOutError"===e.name)return{status:"Failed",error:new _client.SupportApiError("signed_out",e.message,null)};throw e}},useCreateSupportTicket=()=>{const{client:e,outbox:t}=useSupportContext();return(0,_react.useCallback)(r=>sendThroughOutbox(t,_types.SUPPORT_TICKET_QUEUE,r.subject,e.ticketRequest(r)),[e,t])};exports.useCreateSupportTicket=useCreateSupportTicket;const TICKET_REFRESH_MS=3e4,useSupportTicket=e=>{const{client:t,outbox:r,bumpRevision:s}=useSupportContext(),[o,a]=(0,_react.useState)(null),[n,u]=(0,_react.useState)(!0),[c,i]=(0,_react.useState)(null),[p,l]=(0,_react.useState)(null),[f,y]=(0,_react.useState)(!1),[_,S]=(0,_react.useState)([]),d=(0,_react.useRef)(!0),g=(0,_react.useRef)(!1),m=(0,_react.useMemo)(()=>(0,_client.supportRepliesUrl)(t.basePath,e),[t,e]);(0,_react.useEffect)(()=>{g.current=f},[f]),(0,_react.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);const b=(0,_react.useCallback)(async()=>{const e=await r.list(_types.SUPPORT_REPLY_QUEUE);d.current&&S(e.filter(e=>e.request.url===m))},[r,m]),x=(0,_react.useCallback)(async()=>{u(!0);try{const r=await t.getTicket(e);d.current&&(a(r),i(null))}catch(e){d.current&&i((0,_client.toSupportApiError)(e))}finally{d.current&&u(!1)}},[t,e]);(0,_react.useEffect)(()=>{x()},[x]);const h=(0,_react.useCallback)(async()=>{if(!g.current)try{const r=await t.getTicket(e);d.current&&a(e=>!e||Date.parse(r.updatedDateTimeUtc)>=Date.parse(e.updatedDateTimeUtc)?r:e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-support] background refresh of the support ticket failed",e)}},[t,e]);(0,_react.useEffect)(()=>(b(),r.subscribe(e=>{"sent"===e.type&&e.entry.queue===_types.SUPPORT_REPLY_QUEUE&&e.entry.request.url===m&&d.current&&(isSupportTicketDetail(e.data)?a(e.data):(_mobileCore.Logger.warn("[mobile-support] an outbox reply was not a ticket; refreshing"),h())),("changed"===e.type?e.queue:e.entry.queue)===_types.SUPPORT_REPLY_QUEUE&&b()})),[r,b,h,m]),(0,_react.useEffect)(()=>{let e=null;const start=()=>{e??=setInterval(()=>{h()},3e4)},stop=()=>{null!==e&&(clearInterval(e),e=null)};let t="active"===_reactNative.AppState.currentState;t&&start();const r=_reactNative.AppState.addEventListener("change",e=>{const r="active"===e;r!==t&&(t=r,r?(h(),start()):stop())});return()=>{r.remove(),stop()}},[h]);const C=(0,_react.useCallback)(async e=>{y(!0),l(null);try{const t=await e();return d.current&&a(t),s(),!0}catch(e){return d.current&&l((0,_client.toSupportApiError)(e)),!1}finally{d.current&&y(!1)}},[s]),E=(0,_react.useCallback)(async s=>{y(!0),l(null);try{const o=await sendThroughOutbox(r,_types.SUPPORT_REPLY_QUEUE,s.body.slice(0,80),t.replyRequest(e,s));return d.current&&("Sent"===o.status&&a(o.ticket),"Failed"===o.status&&l(o.error)),o.status}finally{d.current&&y(!1)}},[r,t,e]),T=(0,_react.useCallback)(()=>C(()=>t.reopen(e)),[C,t,e]),k=(0,_react.useCallback)(()=>C(()=>t.cancel(e)),[C,t,e]),A=(0,_react.useCallback)(r=>C(()=>t.rate(e,r)),[C,t,e]);return{ticket:o,loading:n,error:c,actionError:p,busy:f,pendingReplies:_,reload:x,reply:E,reopen:T,cancel:k,rate:A}};exports.useSupportTicket=useSupportTicket;const useSupportOutbox=e=>{const{outbox:t}=useSupportContext(),[r,s]=(0,_react.useState)([]),o=(0,_react.useRef)(!0);(0,_react.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);const a=(0,_react.useCallback)(async()=>{const r=await t.list(e);o.current&&s(r)},[t,e]);(0,_react.useEffect)(()=>(a(),t.subscribe(t=>{("changed"===t.type?t.queue:t.entry.queue)===e&&a()})),[t,e,a]);return{entries:r,retry:(0,_react.useCallback)(async e=>{await t.retry(e),await a()},[t,a]),discard:(0,_react.useCallback)(async e=>{await t.discard(e),await a()},[t,a])}};exports.useSupportOutbox=useSupportOutbox;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useSupportUploadProgress=exports.useSupportTimeZone=exports.useSupportTickets=exports.useSupportTicket=exports.useSupportOutbox=exports.useSupportLabels=exports.useSupportConfig=exports.useSupportClient=exports.useCreateSupportTicket=exports.useAttachmentOpener=exports.useAttachmentLoader=exports.SupportProvider=void 0;var _mobileCore=require("@webority/mobile-core"),_outbox=require("@webority/mobile-core/outbox"),_react=require("react"),_reactNative=require("react-native"),_client=require("./client.js"),_files=require("./files.js"),_types=require("./types.js"),_jsxRuntime=require("react/jsx-runtime");const SupportContext=(0,_react.createContext)(null),changedQueue=e=>{switch(e.type){case"changed":return e.queue;case"sent":case"failed":return e.entry.queue;case"progress":return null;default:return e}},isRecord=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),isStringArray=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e),isSupportTicketDetail=e=>{if(!isRecord(e))return!1;const nullableString=e=>null===e||"string"==typeof e,nullableNumber=e=>null===e||"number"==typeof e,isLink=e=>isRecord(e)&&"string"==typeof e.id&&"string"==typeof e.number&&"string"==typeof e.subject;return"string"==typeof e.id&&"string"==typeof e.number&&"string"==typeof e.queue&&nullableNumber(e.accountId)&&nullableString(e.realm)&&"string"==typeof e.category&&"string"==typeof e.subject&&"string"==typeof e.status&&"string"==typeof e.statusLabel&&nullableString(e.priority)&&"string"==typeof e.reporterName&&(void 0===e.reporterPlace||"string"==typeof e.reporterPlace)&&"string"==typeof e.reporterEmail&&nullableNumber(e.assignedAgentUserId)&&nullableString(e.assignedAgentName)&&"boolean"==typeof e.isOverdue&&nullableString(e.pageUrl)&&nullableString(e.userAgent)&&nullableString(e.appVersion)&&nullableString(e.satisfaction)&&nullableString(e.satisfactionComment)&&"boolean"==typeof e.canReopen&&"boolean"==typeof e.canRate&&"boolean"==typeof e.canCancel&&"string"==typeof e.createdDateTimeUtc&&"string"==typeof e.updatedDateTimeUtc&&nullableString(e.resolvedDateTimeUtc)&&nullableString(e.closedDateTimeUtc)&&Array.isArray(e.messages)&&"string"==typeof e.version&&(void 0===e.mergedInto||isLink(e.mergedInto))&&(void 0===e.mergedTickets||Array.isArray(e.mergedTickets)&&e.mergedTickets.every(isLink))},parseSupportContactInfo=e=>{if(!isRecord(e))return null;const{productName:t,supportEmail:r,supportName:o,supportPhone:s,supportHours:a,categories:u,maxAttachmentBytes:n,maxAttachmentsPerMessage:c,allowedContentTypes:p,subjectMaxLength:i,bodyMaxLength:l,satisfactionCommentMaxLength:f}=e;return"string"!=typeof t||"string"!=typeof r||"string"!=typeof o||null!==s&&"string"!=typeof s||null!==a&&"string"!=typeof a||!isStringArray(u)||"number"!=typeof n||"number"!=typeof c||!isStringArray(p)||"number"!=typeof i||"number"!=typeof l||"number"!=typeof f?null:{productName:t,supportEmail:r,supportName:o,supportPhone:s,supportHours:a,categories:u,maxAttachmentBytes:n,maxAttachmentsPerMessage:c,allowedContentTypes:p,subjectMaxLength:i,bodyMaxLength:l,satisfactionCommentMaxLength:f}},SupportProvider=({client:e,outbox:t,openFile:r,timeZone:o,labels:s,children:a})=>{if(!t)throw new Error("[@webority/mobile-support] <SupportProvider> needs an outbox={...}, created with createOutbox from mobile-core.");const[u,n]=(0,_react.useState)(null),[c,p]=(0,_react.useState)(null),[i,l]=(0,_react.useState)(!0),[f,S]=(0,_react.useState)(0),_=(0,_react.useRef)(new Map),y=(0,_react.useCallback)(async()=>{l(!0);const t=`@webority/mobile-support/config:${e.basePath}`;try{const r=await e.getConfig();_mobileCore.Storage.setItem(t,JSON.stringify(r)),n(r),p(null)}catch(e){const r=(0,_client.toSupportApiError)(e);if(p(r),"offline"===r.code||"network"===r.code){const e=await _mobileCore.Storage.getJson(t,parseSupportContactInfo);e&&n(e)}}finally{l(!1)}},[e]);(0,_react.useEffect)(()=>{_.current.clear(),y()},[y]);const d=(0,_react.useCallback)(t=>{const r=_.current.get(t.id);if(r)return r;const o=e.getAttachmentDataUri(t);return _.current.set(t.id,o),o.catch(()=>_.current.delete(t.id)),o},[e]),g=(0,_react.useMemo)(()=>r?async t=>{const o=await(0,_files.saveAttachmentToCache)(t,()=>e.getAttachmentBytes(t.id));await r({uri:o,name:t.fileName,contentType:t.contentType})}:null,[e,r]),b=(0,_react.useCallback)(()=>S(e=>e+1),[]);(0,_react.useEffect)(()=>t.subscribe(e=>{"sent"!==e.type||e.entry.queue!==_types.SUPPORT_TICKET_QUEUE&&e.entry.queue!==_types.SUPPORT_REPLY_QUEUE||b()}),[t,b]);const m=(0,_react.useMemo)(()=>({client:e,outbox:t,config:u,configError:c,configLoading:i,reloadConfig:y,loadAttachment:d,openAttachment:g,timeZone:o,labels:s,revision:f,bumpRevision:b}),[e,t,u,c,i,y,d,g,o,s,f,b]);return(0,_jsxRuntime.jsx)(SupportContext.Provider,{value:m,children:a})};exports.SupportProvider=SupportProvider;const useSupportContext=()=>{const e=(0,_react.useContext)(SupportContext);if(!e)throw new Error("[@webority/mobile-support] Support screens and hooks need a <SupportProvider client={...}> above them.");return e},useSupportClient=()=>useSupportContext().client;exports.useSupportClient=useSupportClient;const useAttachmentLoader=()=>useSupportContext().loadAttachment;exports.useAttachmentLoader=useAttachmentLoader;const useAttachmentOpener=()=>useSupportContext().openAttachment;exports.useAttachmentOpener=useAttachmentOpener;const useSupportTimeZone=()=>useSupportContext().timeZone;exports.useSupportTimeZone=useSupportTimeZone;const useSupportLabels=(e,t)=>{const r=useSupportContext().labels?.[e];return(0,_react.useMemo)(()=>r?{...t,...r}:t,[r,t])};exports.useSupportLabels=useSupportLabels;const useSupportConfig=()=>{const{config:e,configLoading:t,configError:r,reloadConfig:o}=useSupportContext();return{config:e,loading:t,error:r,reload:o}};exports.useSupportConfig=useSupportConfig;const DEFAULT_PAGE_SIZE=20,useSupportTickets=(e={})=>{const t=e.pageSize??20,{client:r,revision:o}=useSupportContext(),[s,a]=(0,_react.useState)(null),[u,n]=(0,_react.useState)(""),[c,p]=(0,_react.useState)([]),[i,l]=(0,_react.useState)(null),[f,S]=(0,_react.useState)(0),[_,y]=(0,_react.useState)(0),[d,g]=(0,_react.useState)(!0),[b,m]=(0,_react.useState)(!1),[x,h]=(0,_react.useState)(!1),[C,E]=(0,_react.useState)(null),[T,k]=(0,_react.useState)(null),A=(0,_react.useRef)(!0),P=(0,_react.useRef)(0),w=(0,_react.useRef)(!1),R=(0,_react.useRef)(null);(0,_react.useEffect)(()=>(A.current=!0,()=>{A.current=!1}),[]);const v=(0,_react.useCallback)(e=>{const r=u.trim();return{...s?{status:s}:{},...r?{search:r}:{},page:e,pageSize:t}},[s,u,t]),U=(0,_react.useCallback)(async e=>{P.current+=1;const t=P.current,current=()=>A.current&&t===P.current;w.current=!1,h(!1),"refresh"===e?m(!0):"replace"===e&&(g(!0),p([]));const o="replace"!==e||R.current!==r;try{const[e,t]=await Promise.all([r.listTickets(v(1)),o?r.getTicketCounts():null]);current()&&(p(e.items),S(e.page),y(e.totalPages),t&&(l(t),R.current=r),E(null),k(null))}catch(e){current()&&E((0,_client.toSupportApiError)(e))}finally{current()&&(g(!1),m(!1))}},[r,v]),L=(0,_react.useRef)(o);(0,_react.useEffect)(()=>{const e=L.current===o?"replace":"quiet";L.current=o,U(e)},[U,o]);const O=f<_,q=(0,_react.useCallback)(async()=>{if(w.current||d||b||!O)return;const e=P.current,current=()=>A.current&&e===P.current;w.current=!0,h(!0),k(null);try{const e=await r.listTickets(v(f+1));current()&&(p(t=>{const r=new Set(t.map(e=>e.id));return[...t,...e.items.filter(e=>!r.has(e.id))]}),S(e.page),y(e.totalPages))}catch(e){current()&&k((0,_client.toSupportApiError)(e))}finally{current()&&(w.current=!1,h(!1))}},[r,v,f,O,d,b]),M=(0,_react.useCallback)(()=>U("refresh"),[U]),j=useCreateSupportTicket();return{tickets:c,counts:i,status:s,search:u,setStatus:a,setSearch:n,loading:d,refreshing:b,loadingMore:x,hasMore:O,error:C,loadMoreError:T,refresh:M,loadMore:q,createTicket:j}};exports.useSupportTickets=useSupportTickets;const sendThroughOutbox=async(e,t,r,o)=>{try{const s=await e.send({queue:t,label:r,request:o});if("Sent"===s.status){const{data:e}=s;return isSupportTicketDetail(e)?{status:"Sent",ticket:e}:{status:"Failed",error:new _client.SupportApiError("invalid-reply","The support desk sent a reply this app could not read. Try again.",null)}}return"Queued"===s.status?{status:"Queued",entry:s.entry}:{status:"Failed",error:new _client.SupportApiError(s.failure.code,s.failure.message,s.failure.status)}}catch(e){if(e instanceof Error&&"OutboxFullError"===e.name)return{status:"Failed",error:new _client.SupportApiError("outbox_full",e.message,null)};if(e instanceof Error&&"OutboxSignedOutError"===e.name)return{status:"Failed",error:new _client.SupportApiError("signed_out",e.message,null)};throw e}},useCreateSupportTicket=()=>{const{client:e,outbox:t}=useSupportContext();return(0,_react.useCallback)(r=>sendThroughOutbox(t,_types.SUPPORT_TICKET_QUEUE,r.subject,e.ticketRequest(r)),[e,t])};exports.useCreateSupportTicket=useCreateSupportTicket;const useSupportUploadProgress=e=>(0,_outbox.useOutboxProgress)(useSupportContext().outbox,e);exports.useSupportUploadProgress=useSupportUploadProgress;const TICKET_REFRESH_MS=3e4,useSupportTicket=e=>{const{client:t,outbox:r,bumpRevision:o}=useSupportContext(),[s,a]=(0,_react.useState)(null),[u,n]=(0,_react.useState)(!0),[c,p]=(0,_react.useState)(null),[i,l]=(0,_react.useState)(null),[f,S]=(0,_react.useState)(!1),[_,y]=(0,_react.useState)([]),d=(0,_react.useRef)(!0),g=(0,_react.useRef)(!1),b=(0,_react.useMemo)(()=>(0,_client.supportRepliesUrl)(t.basePath,e),[t,e]);(0,_react.useEffect)(()=>{g.current=f},[f]),(0,_react.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);const m=(0,_react.useCallback)(async()=>{const e=await r.list(_types.SUPPORT_REPLY_QUEUE);d.current&&y(e.filter(e=>e.request.url===b))},[r,b]),x=(0,_react.useCallback)(async()=>{n(!0);try{const r=await t.getTicket(e);d.current&&(a(r),p(null))}catch(e){d.current&&p((0,_client.toSupportApiError)(e))}finally{d.current&&n(!1)}},[t,e]);(0,_react.useEffect)(()=>{x()},[x]);const h=(0,_react.useCallback)(async()=>{if(!g.current)try{const r=await t.getTicket(e);d.current&&a(e=>!e||Date.parse(r.updatedDateTimeUtc)>=Date.parse(e.updatedDateTimeUtc)?r:e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-support] background refresh of the support ticket failed",e)}},[t,e]);(0,_react.useEffect)(()=>(m(),r.subscribe(e=>{"sent"===e.type&&e.entry.queue===_types.SUPPORT_REPLY_QUEUE&&e.entry.request.url===b&&d.current&&(isSupportTicketDetail(e.data)?a(e.data):(_mobileCore.Logger.warn("[mobile-support] an outbox reply was not a ticket; refreshing"),h())),changedQueue(e)===_types.SUPPORT_REPLY_QUEUE&&m()})),[r,m,h,b]),(0,_react.useEffect)(()=>{let e=null;const start=()=>{e??=setInterval(()=>{h()},3e4)},stop=()=>{null!==e&&(clearInterval(e),e=null)};let t="active"===_reactNative.AppState.currentState;t&&start();const r=_reactNative.AppState.addEventListener("change",e=>{const r="active"===e;r!==t&&(t=r,r?(h(),start()):stop())});return()=>{r.remove(),stop()}},[h]);const C=(0,_react.useCallback)(async e=>{S(!0),l(null);try{const t=await e();return d.current&&a(t),o(),!0}catch(e){return d.current&&l((0,_client.toSupportApiError)(e)),!1}finally{d.current&&S(!1)}},[o]),E=(0,_react.useCallback)(async o=>{S(!0),l(null);try{const s=await sendThroughOutbox(r,_types.SUPPORT_REPLY_QUEUE,o.body.slice(0,80),t.replyRequest(e,o));return d.current&&("Sent"===s.status&&a(s.ticket),"Failed"===s.status&&l(s.error)),s.status}finally{d.current&&S(!1)}},[r,t,e]),T=(0,_react.useCallback)(()=>C(()=>t.reopen(e)),[C,t,e]),k=(0,_react.useCallback)(()=>C(()=>t.cancel(e)),[C,t,e]),A=(0,_react.useCallback)(r=>C(()=>t.rate(e,r)),[C,t,e]);return{ticket:s,loading:u,error:c,actionError:i,busy:f,pendingReplies:_,reload:x,reply:E,reopen:T,cancel:k,rate:A}};exports.useSupportTicket=useSupportTicket;const useSupportOutbox=e=>{const{outbox:t}=useSupportContext(),[r,o]=(0,_react.useState)([]),s=(0,_react.useRef)(!0);(0,_react.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]);const a=(0,_react.useCallback)(async()=>{const r=await t.list(e);s.current&&o(r)},[t,e]);(0,_react.useEffect)(()=>(a(),t.subscribe(t=>{changedQueue(t)===e&&a()})),[t,e,a]);return{entries:r,retry:(0,_react.useCallback)(async e=>{await t.retry(e),await a()},[t,a]),discard:(0,_react.useCallback)(async e=>{await t.discard(e),await a()},[t,a])}};exports.useSupportOutbox=useSupportOutbox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewSupportTicket=void 0;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactHookForm=require("react-hook-form"),_reactNative=require("react-native"),_client=require("../client.js"),_device=require("../device.js"),_labels=require("../labels.js"),_SupportProvider=require("../SupportProvider.js"),_subject=require("../subject.js"),_validation=require("../validation.js"),_PhotoTray=require("./PhotoTray.js"),_SuggestedAnswers=require("./SuggestedAnswers.js"),_jsxRuntime=require("react/jsx-runtime");const LABELS={intro:"Tell us what you need. We reply by email and in this ticket.",messageLabel:"Message",messagePlaceholder:"What happened, and what did you expect?",subjectLabel:"Subject",subjectPlaceholder:"A short summary",subjectHelper:"Filled in from your message. You can change it.",categoryLabel:"Category (optional)",categoryPlaceholder:"Choose a category",categoryHelper:"Not sure? Leave it empty and we will sort it.",screenshotLabel:"Screenshot",photosLabel:"Photos",photoLimit:"Add up to {count} photos.",cancel:"Cancel",send:"Send ticket",loading:"Loading",retry:"Try again",unavailable:"Support is not available right now."},SUGGESTION_PAUSE_MS=500,SUGGESTION_MIN_CHARS=3,TicketForm=({config:e,styles:t,onCreated:r,onQueued:o,onCancel:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewSupportTicket=void 0;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactHookForm=require("react-hook-form"),_reactNative=require("react-native"),_client=require("../client.js"),_device=require("../device.js"),_labels=require("../labels.js"),_SupportProvider=require("../SupportProvider.js"),_subject=require("../subject.js"),_types=require("../types.js"),_validation=require("../validation.js"),_PhotoTray=require("./PhotoTray.js"),_SuggestedAnswers=require("./SuggestedAnswers.js"),_SupportUploadProgress=require("./SupportUploadProgress.js"),_jsxRuntime=require("react/jsx-runtime");const LABELS={intro:"Tell us what you need. We reply by email and in this ticket.",messageLabel:"Message",messagePlaceholder:"What happened, and what did you expect?",subjectLabel:"Subject",subjectPlaceholder:"A short summary",subjectHelper:"Filled in from your message. You can change it.",categoryLabel:"Category (optional)",categoryPlaceholder:"Choose a category",categoryHelper:"Not sure? Leave it empty and we will sort it.",screenshotLabel:"Screenshot",photosLabel:"Photos",photoLimit:"Add up to {count} photos.",cancel:"Cancel",send:"Send ticket",loading:"Loading",retry:"Try again",unavailable:"Support is not available right now."},SUGGESTION_PAUSE_MS=500,SUGGESTION_MIN_CHARS=3,TicketForm=({config:e,styles:t,onCreated:r,onQueued:o,onCancel:s,initialDraft:a,defaultCategory:i,appVersion:n})=>{const l=(0,_SupportProvider.useSupportLabels)("newTicket",LABELS),u=(0,_SupportProvider.useSupportLabels)("shared",_labels.SHARED_LABELS),c=(0,_SupportProvider.useCreateSupportTicket)(),d=(0,_SupportProvider.useSupportClient)(),{isConnected:p,isInternetReachable:b}=(0,_mobileCore.useNetworkStatus)(),m=!p||!1===b,[g,_]=(0,_react.useState)([]),listed=t=>t&&e.categories.includes(t)?t:void 0,[j,h]=(0,_react.useState)([]),[x,y]=(0,_react.useState)(a?.screenshots??[]),[S,v]=(0,_react.useState)(null),[L,P]=(0,_react.useState)(null),w=(0,_react.useRef)(Boolean(a?.subject?.trim())&&a?.subject!==(0,_subject.subjectFromMessage)(a?.body??"",e.subjectMaxLength)),T=(0,_reactHookForm.useForm)({defaultValues:{category:listed(a?.category)??listed(i)??"",subject:a?.subject||(0,_subject.subjectFromMessage)(a?.body??"",e.subjectMaxLength),body:a?.body??""}}),U=T.handleSubmit(async t=>{const s=(0,_validation.validateFiles)([...x,...j],e,u);if(v(s??null),!s){P(null);try{const s=await c({category:t.category,subject:t.subject.trim()||(0,_subject.subjectFromMessage)(t.body,e.subjectMaxLength),body:t.body.trim(),pageUrl:a?.pageUrl,userAgent:a?.userAgent??(0,_device.describeDevice)(),appVersion:a?.appVersion??n,files:j,screenshots:x});"Sent"===s.status?r(s.ticket):"Queued"===s.status?o(s.entry):P(s.error.message)}catch(e){P((0,_client.toSupportApiError)(e).message)}}}),R=T.formState.isSubmitting,f=(0,_SupportProvider.useSupportUploadProgress)(_types.SUPPORT_TICKET_QUEUE),C=(0,_mobileUi.useHookFormField)({control:T.control,name:"category",rules:{validate:t=>(0,_validation.validateCategory)(t,e,u)}}),A=(0,_mobileUi.useHookFormField)({control:T.control,name:"subject",rules:{validate:t=>""===t.trim()?void 0:(0,_validation.validateSubject)(t,e,u)}}),k=(0,_mobileUi.useHookFormField)({control:T.control,name:"body",rules:{validate:t=>(0,_validation.validateBody)(t,e,u)}}),F=x.length+j.length;(0,_react.useEffect)(()=>{S&&v((0,_validation.validateFiles)([...x,...j],e,u)??null)},[j,x,S,e,u]);const B=A.value.trim();return(0,_react.useEffect)(()=>{if(m||B.length<3)return void _([]);let e=!0;const t=setTimeout(async()=>{try{const t=await(d.getSuggestions?.(B))??[];e&&_(t)}catch{e&&_([])}},500);return()=>{e=!1,clearTimeout(t)}},[d,B,m]),(0,_jsxRuntime.jsxs)(_mobileUi.KeyboardAwareScrollView,{contentContainerStyle:t.content,safeAreaEdges:[],children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:l.intro}),(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:l.messageLabel,placeholder:l.messagePlaceholder,required:!0,multiline:!0,maxLength:e.bodyMaxLength,value:k.value,onChangeText:t=>{k.onChangeText(t),w.current||T.setValue("subject",(0,_subject.subjectFromMessage)(t,e.subjectMaxLength))},onBlur:k.onBlur,error:k.error,testID:"support-new-body"}),(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:l.subjectLabel,placeholder:l.subjectPlaceholder,helperText:l.subjectHelper,maxLength:e.subjectMaxLength,value:A.value,onChangeText:e=>{w.current=""!==e.trim(),A.onChangeText(e)},onBlur:A.onBlur,error:A.error,testID:"support-new-subject"}),g.length>0&&(0,_jsxRuntime.jsx)(_SuggestedAnswers.SuggestedAnswers,{articles:g,testID:"support-new-suggestions"}),(0,_jsxRuntime.jsx)(_mobileUi.Select,{label:l.categoryLabel,placeholder:l.categoryPlaceholder,helperText:l.categoryHelper,options:e.categories.map(e=>({label:e,value:e})),value:C.value||void 0,onChange:e=>C.onChange(String(e)),error:C.error,testID:"support-new-category"}),x.length>0&&(0,_jsxRuntime.jsx)(_PhotoTray.PhotoTray,{label:l.screenshotLabel,photos:x,onChange:y,remaining:0,allowAdd:!1,maxBytes:e.maxAttachmentBytes,disabled:R}),(0,_jsxRuntime.jsx)(_PhotoTray.PhotoTray,{label:l.photosLabel,photos:j,onChange:h,remaining:e.maxAttachmentsPerMessage-F,maxBytes:e.maxAttachmentBytes,disabled:R}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_labels.fillLabel)(l.photoLimit,{count:e.maxAttachmentsPerMessage})}),R&&(0,_jsxRuntime.jsx)(_SupportUploadProgress.SupportUploadProgress,{progress:f,testID:"support-new-progress"}),(S||L)&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:S??L}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:t.actions,children:[s&&(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:l.cancel,variant:"ghost",tone:"neutral",onPress:s,disabled:R}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:l.send,loading:R,disabled:R,onPress:()=>{U()},testID:"support-new-submit"})]})]})},NewSupportTicket=e=>{const t=(0,_SupportProvider.useSupportLabels)("newTicket",LABELS),r=(0,_mobileUi.useTheme)(),o=(0,_react.useMemo)(()=>buildStyles(r),[r]),{config:s,loading:a,error:i,reload:n}=(0,_SupportProvider.useSupportConfig)(),l=e.testID??"support-new-ticket";return s?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.root,testID:l,children:[(0,_jsxRuntime.jsx)(_mobileUi.NetworkStatusBanner,{}),(0,_jsxRuntime.jsx)(TicketForm,{...e,config:s,styles:o})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:o.center,testID:l,children:a?(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{accessibilityLabel:t.loading}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",color:"danger",align:"center",children:i?.message??t.unavailable}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.retry,variant:"ghost",onPress:()=>{n()}})]})})};exports.NewSupportTicket=NewSupportTicket;const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},content:{padding:e.space.md,gap:e.space.md},center:{flex:1,alignItems:"center",justifyContent:"center",padding:e.space.xl,gap:e.space.sm},actions:{flexDirection:"row",justifyContent:"flex-end",gap:e.space.sm}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SupportTicketDetail=void 0;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_SupportProvider=require("../SupportProvider.js"),_types=require("../types.js"),_validation=require("../validation.js"),_Attachments=require("./Attachments.js"),_PhotoTray=require("./PhotoTray.js"),_SupportTicketList=require("./SupportTicketList.js"),_jsxRuntime=require("react/jsx-runtime");const LABELS={sendNow:"Send now",discard:"Discard",loading:"Loading the ticket",retry:"Try again",replyReopens:"Replying reopens this ticket.",opened:"Opened {date}",updated:"Updated {date}",merged:"This ticket was merged into {number}. The conversation carries on there.",openMerged:"Open {number}",resolvedNote:"This ticket is {status}. Reopen it if you still need help.",reopen:"Reopen ticket",withdraw:"Withdraw request",withdrawTitle:"Withdraw this request?",withdrawMessage:"Our team will stop working on this ticket. You can open a new ticket later if you still need help.",withdrawConfirm:"Withdraw request",withdrawCancel:"Keep request",yourComment:"Your comment: {comment}",solved:"Yes, it is solved",notSolved:"No, it is not",commentLabel:"Anything to add? (optional)",commentHelper:"Your comment goes to the support team.",sendAnswer:"Send answer",conversation:"Conversation",mergedBadge:"Merged into this ticket",replyPlaceholder:"Write a reply to the support team",replyLabel:"Your reply",attachPhoto:"Attach a photo",sendReply:"Send reply",you:"You",writeMessage:"Write a message.",supportTeam:"Support team",replyFailed:"Your reply did not send. Please try again.",waitingToSend:"Waiting to send",notFound:"That ticket could not be found.",discardTitle:"Discard this report?",discardMessage:"It has not been sent.",statusAccessibility:"Status: {label}",waitingText:"We need your answer to carry on. Reply below and the ticket goes back to our team.",satisfied:"You told us this solved your problem.",unsatisfied:"You told us this did not solve your problem.",ratingQuestion:"Did this solve your problem?",detailsTitle:"Ticket details",detailStatus:"Status",detailCategory:"Category",detailTicket:"Ticket",detailOpened:"Opened",detailLastUpdate:"Last update"},MessageBubble=({message:e,styles:t,timeZone:i,labels:s,onOpenImage:a})=>{if("System"===e.authorKind)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:t.system,testID:`support-message-${e.id}`,children:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:`${e.body}, ${(0,_mobileCore.formatDateTime)(e.createdDateTimeUtc,{zone:i})}`})});const n="Customer"===e.authorKind;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[t.bubbleRow,n?t.mineRow:t.theirsRow],testID:`support-message-${e.id}`,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[t.bubble,n?t.mine:t.theirs],children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",color:n?"primary":"secondary",children:e.authorName??(n?s.you:s.supportTeam)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",selectable:!0,children:e.body}),(0,_jsxRuntime.jsx)(_Attachments.AttachmentList,{attachments:e.attachments,onOpenImage:a}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_mobileCore.formatDateTime)(e.createdDateTimeUtc,{zone:i})})]})})},pendingReplyBody=e=>{const{body:t}=e.request;if("json"===t.kind){const e=t.value;return"object"==typeof e&&null!==e&&"body"in e&&"string"==typeof e.body?e.body:""}const i=t.fields.find(e=>"body"===e.name);return i&&"value"in i?i.value:""},PendingReplyBubble=({entry:e,styles:t,labels:i,onSendNow:s,onDiscard:a})=>{const n="Failed"===e.state;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[t.bubbleRow,t.mineRow],testID:`support-pending-${e.id}`,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[t.bubble,t.mine],children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",color:"primary",children:i.you}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",selectable:!0,children:pendingReplyBody(e)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:n?"danger":"tertiary",accessibilityLiveRegion:"polite",children:n?i.replyFailed:i.waitingToSend}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:t.ratingRow,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.sendNow,size:"sm",variant:"outline",onPress:()=>s(e.id),testID:`support-pending-send-${e.id}`}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.discard,size:"sm",variant:"ghost",onPress:()=>a(e.id),testID:`support-pending-discard-${e.id}`})]})]})})},SupportTicketDetail=({ticketId:e,onOpenTicket:t,testID:i="support-ticket-detail"})=>{const s=(0,_SupportProvider.useSupportLabels)("ticketDetail",LABELS),a=(0,_SupportProvider.useSupportLabels)("shared",_labels.SHARED_LABELS),n=(0,_mobileUi.useTheme)(),o=(0,_react.useMemo)(()=>buildStyles(n),[n]),{config:l}=(0,_SupportProvider.useSupportConfig)(),r=(0,_SupportProvider.useSupportTimeZone)(),{ticket:d,loading:c,error:m,actionError:u,busy:p,pendingReplies:b,reload:x,reply:_,reopen:y,cancel:j,rate:g}=(0,_SupportProvider.useSupportTicket)(e),h=(0,_SupportProvider.useSupportOutbox)(_types.SUPPORT_REPLY_QUEUE),[R,v]=(0,_react.useState)(null),[S,T]=(0,_react.useState)(""),[w,U]=(0,_react.useState)([]),[f,D]=(0,_react.useState)(!1),[L,C]=(0,_react.useState)(null),[k,I]=(0,_react.useState)(null),[P,B]=(0,_react.useState)(""),[N,A]=(0,_react.useState)(!1);if(!d)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:o.center,testID:i,children:c?(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{accessibilityLabel:s.loading}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",color:"danger",align:"center",children:m?.message??s.notFound}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.retry,variant:"ghost",onPress:()=>{x()}})]})});const q={Satisfied:s.satisfied,Unsatisfied:s.unsatisfied},z=d.mergedInto,M=d.messages.filter(e=>!e.isInternal),O=d.updatedDateTimeUtc!==d.createdDateTimeUtc,V=L??u?.message??null,$=Boolean(l)&&(f||w.length>0),E=$||V||d.canReopen?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[$&&l&&(0,_jsxRuntime.jsx)(_PhotoTray.PhotoTray,{photos:w,onChange:e=>{U(e),C(null)},remaining:l.maxAttachmentsPerMessage-w.length,maxBytes:l.maxAttachmentBytes,disabled:p}),V&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:V}),d.canReopen&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.replyReopens})]}):void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.root,testID:i,children:[(0,_jsxRuntime.jsxs)(_mobileUi.KeyboardAwareScrollView,{contentContainerStyle:o.content,safeAreaEdges:[],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.head,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"h3",accessibilityRole:"header",children:d.subject}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:`${d.number}, ${d.category}`}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.headRow,children:[(0,_jsxRuntime.jsx)(_mobileUi.StatusBadge,{label:d.statusLabel,tone:_SupportTicketList.STATUS_TONES[d.status]??"neutral",accessibilityLabel:(0,_labels.fillLabel)(s.statusAccessibility,{label:d.statusLabel})}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_labels.fillLabel)(s.opened,{date:(0,_mobileCore.formatDateTime)(d.createdDateTimeUtc,{zone:r})})}),O&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_labels.fillLabel)(s.updated,{date:(0,_mobileCore.formatDateTime)(d.updatedDateTimeUtc,{zone:r})})})]})]}),z&&(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,testID:"support-merged-into",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",accessibilityLiveRegion:"polite",children:(0,_labels.fillLabel)(s.merged,{number:z.number})}),t&&(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:(0,_labels.fillLabel)(s.openMerged,{number:z.number}),variant:"link",size:"sm",onPress:()=>t(z.id),testID:"support-merged-into-open"})]}),"WaitingOnCustomer"===d.status&&(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,testID:"support-waiting",children:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:s.waitingText})}),d.canReopen&&(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:(0,_labels.fillLabel)(s.resolvedNote,{status:d.statusLabel.toLowerCase()})}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.reopen,variant:"outline",size:"sm",loading:p,disabled:p,onPress:()=>{y()},testID:"support-reopen"})]}),d.canCancel&&(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.withdraw,variant:"outline",size:"sm",loading:p,disabled:p,onPress:()=>A(!0),testID:"support-withdraw"}),(0,_jsxRuntime.jsx)(_mobileUi.Dialog,{open:N,onClose:()=>A(!1),title:s.withdrawTitle,message:s.withdrawMessage,tone:"danger",actions:[{label:s.withdrawCancel,onPress:()=>A(!1),tone:"neutral"},{label:s.withdrawConfirm,onPress:()=>{j()},tone:"danger"}]})]}),d.satisfaction?(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,testID:"support-rating",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",accessibilityLiveRegion:"polite",children:q[d.satisfaction]}),d.satisfactionComment?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:(0,_labels.fillLabel)(s.yourComment,{comment:d.satisfactionComment})}):null]}):d.canRate?(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,testID:"support-rating",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:s.ratingQuestion}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.ratingRow,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.solved,size:"sm",leftIcon:"like",variant:"Satisfied"===k?"solid":"outline",tone:"success",accessibilityState:{selected:"Satisfied"===k},"aria-selected":"Satisfied"===k,onPress:()=>I("Satisfied"),testID:"support-rate-satisfied"}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.notSolved,size:"sm",leftIcon:"dislike",variant:"Unsatisfied"===k?"solid":"outline",tone:"danger",accessibilityState:{selected:"Unsatisfied"===k},"aria-selected":"Unsatisfied"===k,onPress:()=>I("Unsatisfied"),testID:"support-rate-unsatisfied"})]}),k&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:s.commentLabel,helperText:s.commentHelper,value:P,onChangeText:B,multiline:!0,maxLength:l?.satisfactionCommentMaxLength,testID:"support-rating-comment"}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.sendAnswer,size:"sm",loading:p,disabled:p,onPress:()=>{(async()=>{k&&await g({satisfaction:k,comment:P})&&(I(null),B(""))})()},testID:"support-rating-send"})]})]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.thread,accessibilityLabel:s.conversation,children:[M.map(e=>(0,_jsxRuntime.jsx)(MessageBubble,{message:e,styles:o,timeZone:r,labels:s,onOpenImage:(e,t)=>v({uri:e,name:t})},e.id)),b.map(e=>(0,_jsxRuntime.jsx)(PendingReplyBubble,{entry:e,styles:o,labels:s,onSendNow:e=>{h.retry(e)},onDiscard:e=>{(async e=>{await(0,_mobileUi.confirm)({title:s.discardTitle,message:s.discardMessage,confirmLabel:s.discard,tone:"danger"})&&await h.discard(e)})(e)}},e.id))]}),d.mergedTickets&&d.mergedTickets.length>0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.section,testID:"support-merged-tickets",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",accessibilityRole:"header",children:s.mergedBadge}),d.mergedTickets.map(e=>t?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:`${e.number}: ${e.subject}`,variant:"link",size:"sm",onPress:()=>t(e.id),testID:`support-merged-ticket-${e.id}`},e.id):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",testID:`support-merged-ticket-${e.id}`,children:`${e.number}: ${e.subject}`},e.id))]}),(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,testID:"support-details",accessibilityRole:"summary",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:s.detailsTitle}),(0,_jsxRuntime.jsx)(_mobileUi.Descriptions,{items:[{label:s.detailStatus,value:(0,_jsxRuntime.jsx)(_mobileUi.StatusBadge,{label:d.statusLabel,tone:_SupportTicketList.STATUS_TONES[d.status]??"neutral",accessibilityLabel:(0,_labels.fillLabel)(s.statusAccessibility,{label:d.statusLabel})})},{label:s.detailCategory,value:d.category||"-"},{label:s.detailTicket,value:d.number},{label:s.detailOpened,value:(0,_mobileCore.formatDateTime)(d.createdDateTimeUtc,{zone:r})},{label:s.detailLastUpdate,value:(0,_mobileCore.formatDateTime)(d.updatedDateTimeUtc,{zone:r})}]})]})]}),!z&&(0,_jsxRuntime.jsx)(_mobileUi.Composer,{value:S,onChangeText:e=>{T(e),C(null)},onSend:e=>{(async e=>{const t=e.trim(),i=l?(0,_validation.validateBody)(t,l,a)??(0,_validation.validateFiles)(w,l,a):t?void 0:s.writeMessage;if(i)return C(i),void T(e);"Failed"!==await _({body:t,files:w})?(U([]),D(!1)):T(e)})(e)},loading:p,maxLength:l?.bodyMaxLength,placeholder:s.replyPlaceholder,accessibilityLabel:s.replyLabel,labels:{send:s.sendReply,message:s.replyLabel},leading:(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"paperclip",size:"md",accessibilityLabel:s.attachPhoto,disabled:p||!l,onPress:()=>D(e=>!e),testID:"support-reply-attach"}),above:E,testID:"support-reply-composer"}),(0,_jsxRuntime.jsx)(_Attachments.ImageViewer,{image:R,onClose:()=>v(null)})]})};exports.SupportTicketDetail=SupportTicketDetail;const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},content:{padding:e.space.md,gap:e.space.md},center:{flex:1,alignItems:"center",justifyContent:"center",padding:e.space.xl,gap:e.space.sm},head:{gap:e.space.xxs},headRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm,marginTop:e.space.xs},section:{gap:e.space.sm},ratingRow:{flexDirection:"row",flexWrap:"wrap",gap:e.space.sm},thread:{gap:e.space.sm},system:{paddingHorizontal:e.space.lg,paddingVertical:e.space.xxs},bubbleRow:{flexDirection:"row"},mineRow:{justifyContent:"flex-end"},theirsRow:{justifyContent:"flex-start"},bubble:{maxWidth:"85%",borderRadius:e.radius.lg,padding:e.space.sm,gap:e.space.xxs},mine:{backgroundColor:e.colors["primary-soft"]},theirs:{backgroundColor:e.colors["bg-subtle"]}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SupportTicketDetail=void 0;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_SupportProvider=require("../SupportProvider.js"),_types=require("../types.js"),_validation=require("../validation.js"),_Attachments=require("./Attachments.js"),_PhotoTray=require("./PhotoTray.js"),_SupportTicketList=require("./SupportTicketList.js"),_SupportUploadProgress=require("./SupportUploadProgress.js"),_jsxRuntime=require("react/jsx-runtime");const LABELS={sendNow:"Send now",discard:"Discard",loading:"Loading the ticket",retry:"Try again",replyReopens:"Replying reopens this ticket.",opened:"Opened {date}",updated:"Updated {date}",merged:"This ticket was merged into {number}. The conversation carries on there.",openMerged:"Open {number}",resolvedNote:"This ticket is {status}. Reopen it if you still need help.",reopen:"Reopen ticket",withdraw:"Withdraw request",withdrawTitle:"Withdraw this request?",withdrawMessage:"Our team will stop working on this ticket. You can open a new ticket later if you still need help.",withdrawConfirm:"Withdraw request",withdrawCancel:"Keep request",yourComment:"Your comment: {comment}",solved:"Yes, it is solved",notSolved:"No, it is not",commentLabel:"Anything to add? (optional)",commentHelper:"Your comment goes to the support team.",sendAnswer:"Send answer",conversation:"Conversation",mergedBadge:"Merged into this ticket",replyPlaceholder:"Write a reply to the support team",replyLabel:"Your reply",attachPhoto:"Attach a photo",sendReply:"Send reply",you:"You",writeMessage:"Write a message.",supportTeam:"Support team",replyFailed:"Your reply did not send. Please try again.",waitingToSend:"Waiting to send",notFound:"That ticket could not be found.",discardTitle:"Discard this report?",discardMessage:"It has not been sent.",statusAccessibility:"Status: {label}",waitingText:"We need your answer to carry on. Reply below and the ticket goes back to our team.",satisfied:"You told us this solved your problem.",unsatisfied:"You told us this did not solve your problem.",ratingQuestion:"Did this solve your problem?",detailsTitle:"Ticket details",detailStatus:"Status",detailCategory:"Category",detailTicket:"Ticket",detailOpened:"Opened",detailLastUpdate:"Last update"},MessageBubble=({message:e,styles:t,timeZone:i,labels:s,onOpenImage:a})=>{if("System"===e.authorKind)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:t.system,testID:`support-message-${e.id}`,children:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:`${e.body}, ${(0,_mobileCore.formatDateTime)(e.createdDateTimeUtc,{zone:i})}`})});const n="Customer"===e.authorKind;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[t.bubbleRow,n?t.mineRow:t.theirsRow],testID:`support-message-${e.id}`,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[t.bubble,n?t.mine:t.theirs],children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",color:n?"primary":"secondary",children:e.authorName??(n?s.you:s.supportTeam)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",selectable:!0,children:e.body}),(0,_jsxRuntime.jsx)(_Attachments.AttachmentList,{attachments:e.attachments,onOpenImage:a}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_mobileCore.formatDateTime)(e.createdDateTimeUtc,{zone:i})})]})})},pendingReplyBody=e=>{const{body:t}=e.request;switch(t.kind){case"json":{const e=t.value;return"object"==typeof e&&null!==e&&"body"in e&&"string"==typeof e.body?e.body:""}case"multipart":{const e=t.fields.find(e=>"body"===e.name);return e&&"value"in e?e.value:""}case"resumable":return"";default:return t}},PendingReplyBubble=({entry:e,styles:t,labels:i,onSendNow:s,onDiscard:a})=>{const n="Failed"===e.state;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[t.bubbleRow,t.mineRow],testID:`support-pending-${e.id}`,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[t.bubble,t.mine],children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",color:"primary",children:i.you}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",selectable:!0,children:pendingReplyBody(e)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:n?"danger":"tertiary",accessibilityLiveRegion:"polite",children:n?i.replyFailed:i.waitingToSend}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:t.ratingRow,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.sendNow,size:"sm",variant:"outline",onPress:()=>s(e.id),testID:`support-pending-send-${e.id}`}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.discard,size:"sm",variant:"ghost",onPress:()=>a(e.id),testID:`support-pending-discard-${e.id}`})]})]})})},SupportTicketDetail=({ticketId:e,onOpenTicket:t,testID:i="support-ticket-detail"})=>{const s=(0,_SupportProvider.useSupportLabels)("ticketDetail",LABELS),a=(0,_SupportProvider.useSupportLabels)("shared",_labels.SHARED_LABELS),n=(0,_mobileUi.useTheme)(),o=(0,_react.useMemo)(()=>buildStyles(n),[n]),{config:r}=(0,_SupportProvider.useSupportConfig)(),l=(0,_SupportProvider.useSupportTimeZone)(),{ticket:d,loading:u,error:c,actionError:m,busy:p,pendingReplies:b,reload:x,reply:_,reopen:y,cancel:j,rate:g}=(0,_SupportProvider.useSupportTicket)(e),h=(0,_SupportProvider.useSupportOutbox)(_types.SUPPORT_REPLY_QUEUE),R=(0,_SupportProvider.useSupportUploadProgress)(_types.SUPPORT_REPLY_QUEUE),[v,S]=(0,_react.useState)(null),[T,w]=(0,_react.useState)(""),[U,f]=(0,_react.useState)([]),[D,L]=(0,_react.useState)(!1),[P,C]=(0,_react.useState)(null),[k,I]=(0,_react.useState)(null),[B,N]=(0,_react.useState)(""),[A,q]=(0,_react.useState)(!1);if(!d)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:o.center,testID:i,children:u?(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{accessibilityLabel:s.loading}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",color:"danger",align:"center",children:c?.message??s.notFound}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.retry,variant:"ghost",onPress:()=>{x()}})]})});const z={Satisfied:s.satisfied,Unsatisfied:s.unsatisfied},O=d.mergedInto,M=d.messages.filter(e=>!e.isInternal),V=d.updatedDateTimeUtc!==d.createdDateTimeUtc,$=P??m?.message??null,E=Boolean(r)&&(D||U.length>0),Y=E||$||d.canReopen||p?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p&&(0,_jsxRuntime.jsx)(_SupportUploadProgress.SupportUploadProgress,{progress:R,testID:"support-reply-progress"}),E&&r&&(0,_jsxRuntime.jsx)(_PhotoTray.PhotoTray,{photos:U,onChange:e=>{f(e),C(null)},remaining:r.maxAttachmentsPerMessage-U.length,maxBytes:r.maxAttachmentBytes,disabled:p}),$&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:$}),d.canReopen&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.replyReopens})]}):void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.root,testID:i,children:[(0,_jsxRuntime.jsxs)(_mobileUi.KeyboardAwareScrollView,{contentContainerStyle:o.content,safeAreaEdges:[],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.head,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"h3",accessibilityRole:"header",children:d.subject}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:`${d.number}, ${d.category}`}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.headRow,children:[(0,_jsxRuntime.jsx)(_mobileUi.StatusBadge,{label:d.statusLabel,tone:_SupportTicketList.STATUS_TONES[d.status]??"neutral",accessibilityLabel:(0,_labels.fillLabel)(s.statusAccessibility,{label:d.statusLabel})}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_labels.fillLabel)(s.opened,{date:(0,_mobileCore.formatDateTime)(d.createdDateTimeUtc,{zone:l})})}),V&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_labels.fillLabel)(s.updated,{date:(0,_mobileCore.formatDateTime)(d.updatedDateTimeUtc,{zone:l})})})]})]}),O&&(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,testID:"support-merged-into",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",accessibilityLiveRegion:"polite",children:(0,_labels.fillLabel)(s.merged,{number:O.number})}),t&&(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:(0,_labels.fillLabel)(s.openMerged,{number:O.number}),variant:"link",size:"sm",onPress:()=>t(O.id),testID:"support-merged-into-open"})]}),"WaitingOnCustomer"===d.status&&(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,testID:"support-waiting",children:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:s.waitingText})}),d.canReopen&&(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:(0,_labels.fillLabel)(s.resolvedNote,{status:d.statusLabel.toLowerCase()})}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.reopen,variant:"outline",size:"sm",loading:p,disabled:p,onPress:()=>{y()},testID:"support-reopen"})]}),d.canCancel&&(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.withdraw,variant:"outline",size:"sm",loading:p,disabled:p,onPress:()=>q(!0),testID:"support-withdraw"}),(0,_jsxRuntime.jsx)(_mobileUi.Dialog,{open:A,onClose:()=>q(!1),title:s.withdrawTitle,message:s.withdrawMessage,tone:"danger",actions:[{label:s.withdrawCancel,onPress:()=>q(!1),tone:"neutral"},{label:s.withdrawConfirm,onPress:()=>{j()},tone:"danger"}]})]}),d.satisfaction?(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,testID:"support-rating",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",accessibilityLiveRegion:"polite",children:z[d.satisfaction]}),d.satisfactionComment?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:(0,_labels.fillLabel)(s.yourComment,{comment:d.satisfactionComment})}):null]}):d.canRate?(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,testID:"support-rating",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:s.ratingQuestion}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.ratingRow,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.solved,size:"sm",leftIcon:"like",variant:"Satisfied"===k?"solid":"outline",tone:"success",accessibilityState:{selected:"Satisfied"===k},"aria-selected":"Satisfied"===k,onPress:()=>I("Satisfied"),testID:"support-rate-satisfied"}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.notSolved,size:"sm",leftIcon:"dislike",variant:"Unsatisfied"===k?"solid":"outline",tone:"danger",accessibilityState:{selected:"Unsatisfied"===k},"aria-selected":"Unsatisfied"===k,onPress:()=>I("Unsatisfied"),testID:"support-rate-unsatisfied"})]}),k&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:s.commentLabel,helperText:s.commentHelper,value:B,onChangeText:N,multiline:!0,maxLength:r?.satisfactionCommentMaxLength,testID:"support-rating-comment"}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.sendAnswer,size:"sm",loading:p,disabled:p,onPress:()=>{(async()=>{k&&await g({satisfaction:k,comment:B})&&(I(null),N(""))})()},testID:"support-rating-send"})]})]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.thread,accessibilityLabel:s.conversation,children:[M.map(e=>(0,_jsxRuntime.jsx)(MessageBubble,{message:e,styles:o,timeZone:l,labels:s,onOpenImage:(e,t)=>S({uri:e,name:t})},e.id)),b.map(e=>(0,_jsxRuntime.jsx)(PendingReplyBubble,{entry:e,styles:o,labels:s,onSendNow:e=>{h.retry(e)},onDiscard:e=>{(async e=>{await(0,_mobileUi.confirm)({title:s.discardTitle,message:s.discardMessage,confirmLabel:s.discard,tone:"danger"})&&await h.discard(e)})(e)}},e.id))]}),d.mergedTickets&&d.mergedTickets.length>0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.section,testID:"support-merged-tickets",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",accessibilityRole:"header",children:s.mergedBadge}),d.mergedTickets.map(e=>t?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:`${e.number}: ${e.subject}`,variant:"link",size:"sm",onPress:()=>t(e.id),testID:`support-merged-ticket-${e.id}`},e.id):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",testID:`support-merged-ticket-${e.id}`,children:`${e.number}: ${e.subject}`},e.id))]}),(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",bodyStyle:o.section,testID:"support-details",accessibilityRole:"summary",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:s.detailsTitle}),(0,_jsxRuntime.jsx)(_mobileUi.Descriptions,{items:[{label:s.detailStatus,value:(0,_jsxRuntime.jsx)(_mobileUi.StatusBadge,{label:d.statusLabel,tone:_SupportTicketList.STATUS_TONES[d.status]??"neutral",accessibilityLabel:(0,_labels.fillLabel)(s.statusAccessibility,{label:d.statusLabel})})},{label:s.detailCategory,value:d.category||"-"},{label:s.detailTicket,value:d.number},{label:s.detailOpened,value:(0,_mobileCore.formatDateTime)(d.createdDateTimeUtc,{zone:l})},{label:s.detailLastUpdate,value:(0,_mobileCore.formatDateTime)(d.updatedDateTimeUtc,{zone:l})}]})]})]}),!O&&(0,_jsxRuntime.jsx)(_mobileUi.Composer,{value:T,onChangeText:e=>{w(e),C(null)},onSend:e=>{(async e=>{const t=e.trim(),i=r?(0,_validation.validateBody)(t,r,a)??(0,_validation.validateFiles)(U,r,a):t?void 0:s.writeMessage;if(i)return C(i),void w(e);"Failed"!==await _({body:t,files:U})?(f([]),L(!1)):w(e)})(e)},loading:p,maxLength:r?.bodyMaxLength,placeholder:s.replyPlaceholder,accessibilityLabel:s.replyLabel,labels:{send:s.sendReply,message:s.replyLabel},leading:(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"paperclip",size:"md",accessibilityLabel:s.attachPhoto,disabled:p||!r,onPress:()=>L(e=>!e),testID:"support-reply-attach"}),above:Y,testID:"support-reply-composer"}),(0,_jsxRuntime.jsx)(_Attachments.ImageViewer,{image:v,onClose:()=>S(null)})]})};exports.SupportTicketDetail=SupportTicketDetail;const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},content:{padding:e.space.md,gap:e.space.md},center:{flex:1,alignItems:"center",justifyContent:"center",padding:e.space.xl,gap:e.space.sm},head:{gap:e.space.xxs},headRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm,marginTop:e.space.xs},section:{gap:e.space.sm},ratingRow:{flexDirection:"row",flexWrap:"wrap",gap:e.space.sm},thread:{gap:e.space.sm},system:{paddingHorizontal:e.space.lg,paddingVertical:e.space.xxs},bubbleRow:{flexDirection:"row"},mineRow:{justifyContent:"flex-end"},theirsRow:{justifyContent:"flex-start"},bubble:{maxWidth:"85%",borderRadius:e.radius.lg,padding:e.space.sm,gap:e.space.xxs},mine:{backgroundColor:e.colors["primary-soft"]},theirs:{backgroundColor:e.colors["bg-subtle"]}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SupportUploadProgress=void 0;var _mobileUi=require("@webority/mobile-ui"),_labels=require("../labels.js"),_SupportProvider=require("../SupportProvider.js"),_jsxRuntime=require("react/jsx-runtime");const LABELS={sending:"Sending",sendingPercent:"Sending, {percent} percent"},SupportUploadProgress=({progress:e,testID:r})=>{const s=(0,_SupportProvider.useSupportLabels)("upload",LABELS);if(!e)return null;const o=e.fraction;return(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:o??void 0,indeterminate:null===o,showPercent:null!==o,label:s.sending,accessibilityLabel:null===o?s.sending:(0,_labels.fillLabel)(s.sendingPercent,{percent:Math.round(100*o)}),testID:r})};exports.SupportUploadProgress=SupportUploadProgress;
|
package/lib/commonjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"HelpArticle",{enumerable:!0,get:function(){return _HelpArticle.HelpArticle}}),Object.defineProperty(exports,"HelpCentre",{enumerable:!0,get:function(){return _HelpCentre.HelpCentre}}),Object.defineProperty(exports,"NewSupportTicket",{enumerable:!0,get:function(){return _NewSupportTicket.NewSupportTicket}}),Object.defineProperty(exports,"SHARED_LABELS",{enumerable:!0,get:function(){return _labels.SHARED_LABELS}}),Object.defineProperty(exports,"SUPPORT_REPLY_QUEUE",{enumerable:!0,get:function(){return _types.SUPPORT_REPLY_QUEUE}}),Object.defineProperty(exports,"SUPPORT_TICKET_QUEUE",{enumerable:!0,get:function(){return _types.SUPPORT_TICKET_QUEUE}}),Object.defineProperty(exports,"SupportApiError",{enumerable:!0,get:function(){return _client.SupportApiError}}),Object.defineProperty(exports,"SupportContact",{enumerable:!0,get:function(){return _SupportContact.SupportContact}}),Object.defineProperty(exports,"SupportProvider",{enumerable:!0,get:function(){return _SupportProvider.SupportProvider}}),Object.defineProperty(exports,"SupportTicketDetail",{enumerable:!0,get:function(){return _SupportTicketDetail.SupportTicketDetail}}),Object.defineProperty(exports,"SupportTicketList",{enumerable:!0,get:function(){return _SupportTicketList.SupportTicketList}}),Object.defineProperty(exports,"createSupportClient",{enumerable:!0,get:function(){return _client.createSupportClient}}),Object.defineProperty(exports,"describeDevice",{enumerable:!0,get:function(){return _device.describeDevice}}),Object.defineProperty(exports,"toSupportApiError",{enumerable:!0,get:function(){return _client.toSupportApiError}}),Object.defineProperty(exports,"useCreateSupportTicket",{enumerable:!0,get:function(){return _SupportProvider.useCreateSupportTicket}}),Object.defineProperty(exports,"useHelpCentre",{enumerable:!0,get:function(){return _useHelpCentre.useHelpCentre}}),Object.defineProperty(exports,"useSupportClient",{enumerable:!0,get:function(){return _SupportProvider.useSupportClient}}),Object.defineProperty(exports,"useSupportConfig",{enumerable:!0,get:function(){return _SupportProvider.useSupportConfig}}),Object.defineProperty(exports,"useSupportLabels",{enumerable:!0,get:function(){return _SupportProvider.useSupportLabels}}),Object.defineProperty(exports,"useSupportOutbox",{enumerable:!0,get:function(){return _SupportProvider.useSupportOutbox}}),Object.defineProperty(exports,"useSupportTicket",{enumerable:!0,get:function(){return _SupportProvider.useSupportTicket}}),Object.defineProperty(exports,"useSupportTickets",{enumerable:!0,get:function(){return _SupportProvider.useSupportTickets}});var _client=require("./client.js"),_NewSupportTicket=require("./components/NewSupportTicket.js"),_SupportContact=require("./components/SupportContact.js"),_SupportTicketDetail=require("./components/SupportTicketDetail.js"),_SupportTicketList=require("./components/SupportTicketList.js"),_device=require("./device.js"),_HelpArticle=require("./helpCentre/HelpArticle.js"),_HelpCentre=require("./helpCentre/HelpCentre.js"),_useHelpCentre=require("./helpCentre/useHelpCentre.js"),_labels=require("./labels.js"),_SupportProvider=require("./SupportProvider.js"),_types=require("./types.js");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"HelpArticle",{enumerable:!0,get:function(){return _HelpArticle.HelpArticle}}),Object.defineProperty(exports,"HelpCentre",{enumerable:!0,get:function(){return _HelpCentre.HelpCentre}}),Object.defineProperty(exports,"NewSupportTicket",{enumerable:!0,get:function(){return _NewSupportTicket.NewSupportTicket}}),Object.defineProperty(exports,"SHARED_LABELS",{enumerable:!0,get:function(){return _labels.SHARED_LABELS}}),Object.defineProperty(exports,"SUPPORT_REPLY_QUEUE",{enumerable:!0,get:function(){return _types.SUPPORT_REPLY_QUEUE}}),Object.defineProperty(exports,"SUPPORT_TICKET_QUEUE",{enumerable:!0,get:function(){return _types.SUPPORT_TICKET_QUEUE}}),Object.defineProperty(exports,"SupportApiError",{enumerable:!0,get:function(){return _client.SupportApiError}}),Object.defineProperty(exports,"SupportContact",{enumerable:!0,get:function(){return _SupportContact.SupportContact}}),Object.defineProperty(exports,"SupportProvider",{enumerable:!0,get:function(){return _SupportProvider.SupportProvider}}),Object.defineProperty(exports,"SupportTicketDetail",{enumerable:!0,get:function(){return _SupportTicketDetail.SupportTicketDetail}}),Object.defineProperty(exports,"SupportTicketList",{enumerable:!0,get:function(){return _SupportTicketList.SupportTicketList}}),Object.defineProperty(exports,"SupportUploadProgress",{enumerable:!0,get:function(){return _SupportUploadProgress.SupportUploadProgress}}),Object.defineProperty(exports,"createSupportClient",{enumerable:!0,get:function(){return _client.createSupportClient}}),Object.defineProperty(exports,"describeDevice",{enumerable:!0,get:function(){return _device.describeDevice}}),Object.defineProperty(exports,"toSupportApiError",{enumerable:!0,get:function(){return _client.toSupportApiError}}),Object.defineProperty(exports,"useCreateSupportTicket",{enumerable:!0,get:function(){return _SupportProvider.useCreateSupportTicket}}),Object.defineProperty(exports,"useHelpCentre",{enumerable:!0,get:function(){return _useHelpCentre.useHelpCentre}}),Object.defineProperty(exports,"useSupportClient",{enumerable:!0,get:function(){return _SupportProvider.useSupportClient}}),Object.defineProperty(exports,"useSupportConfig",{enumerable:!0,get:function(){return _SupportProvider.useSupportConfig}}),Object.defineProperty(exports,"useSupportLabels",{enumerable:!0,get:function(){return _SupportProvider.useSupportLabels}}),Object.defineProperty(exports,"useSupportOutbox",{enumerable:!0,get:function(){return _SupportProvider.useSupportOutbox}}),Object.defineProperty(exports,"useSupportTicket",{enumerable:!0,get:function(){return _SupportProvider.useSupportTicket}}),Object.defineProperty(exports,"useSupportTickets",{enumerable:!0,get:function(){return _SupportProvider.useSupportTickets}}),Object.defineProperty(exports,"useSupportUploadProgress",{enumerable:!0,get:function(){return _SupportProvider.useSupportUploadProgress}});var _client=require("./client.js"),_NewSupportTicket=require("./components/NewSupportTicket.js"),_SupportContact=require("./components/SupportContact.js"),_SupportTicketDetail=require("./components/SupportTicketDetail.js"),_SupportTicketList=require("./components/SupportTicketList.js"),_SupportUploadProgress=require("./components/SupportUploadProgress.js"),_device=require("./device.js"),_HelpArticle=require("./helpCentre/HelpArticle.js"),_HelpCentre=require("./helpCentre/HelpCentre.js"),_useHelpCentre=require("./helpCentre/useHelpCentre.js"),_labels=require("./labels.js"),_SupportProvider=require("./SupportProvider.js"),_types=require("./types.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Logger,Storage}from"@webority/mobile-core";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{AppState}from"react-native";import{SupportApiError,supportRepliesUrl,toSupportApiError}from"./client.js";import{saveAttachmentToCache}from"./files.js";import{SUPPORT_REPLY_QUEUE,SUPPORT_TICKET_QUEUE}from"./types.js";import{jsx as _jsx}from"react/jsx-runtime";const SupportContext=createContext(null),isRecord=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),isStringArray=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e),isSupportTicketDetail=e=>{if(!isRecord(e))return!1;const nullableString=e=>null===e||"string"==typeof e,nullableNumber=e=>null===e||"number"==typeof e,isLink=e=>isRecord(e)&&"string"==typeof e.id&&"string"==typeof e.number&&"string"==typeof e.subject;return"string"==typeof e.id&&"string"==typeof e.number&&"string"==typeof e.queue&&nullableNumber(e.accountId)&&nullableString(e.realm)&&"string"==typeof e.category&&"string"==typeof e.subject&&"string"==typeof e.status&&"string"==typeof e.statusLabel&&nullableString(e.priority)&&"string"==typeof e.reporterName&&(void 0===e.reporterPlace||"string"==typeof e.reporterPlace)&&"string"==typeof e.reporterEmail&&nullableNumber(e.assignedAgentUserId)&&nullableString(e.assignedAgentName)&&"boolean"==typeof e.isOverdue&&nullableString(e.pageUrl)&&nullableString(e.userAgent)&&nullableString(e.appVersion)&&nullableString(e.satisfaction)&&nullableString(e.satisfactionComment)&&"boolean"==typeof e.canReopen&&"boolean"==typeof e.canRate&&"boolean"==typeof e.canCancel&&"string"==typeof e.createdDateTimeUtc&&"string"==typeof e.updatedDateTimeUtc&&nullableString(e.resolvedDateTimeUtc)&&nullableString(e.closedDateTimeUtc)&&Array.isArray(e.messages)&&"string"==typeof e.version&&(void 0===e.mergedInto||isLink(e.mergedInto))&&(void 0===e.mergedTickets||Array.isArray(e.mergedTickets)&&e.mergedTickets.every(isLink))},parseSupportContactInfo=e=>{if(!isRecord(e))return null;const{productName:t,supportEmail:r,supportName:o,supportPhone:n,supportHours:s,categories:a,maxAttachmentBytes:u,maxAttachmentsPerMessage:c,allowedContentTypes:i,subjectMaxLength:p,bodyMaxLength:l,satisfactionCommentMaxLength:f}=e;return"string"!=typeof t||"string"!=typeof r||"string"!=typeof o||null!==n&&"string"!=typeof n||null!==s&&"string"!=typeof s||!isStringArray(a)||"number"!=typeof u||"number"!=typeof c||!isStringArray(i)||"number"!=typeof p||"number"!=typeof l||"number"!=typeof f?null:{productName:t,supportEmail:r,supportName:o,supportPhone:n,supportHours:s,categories:a,maxAttachmentBytes:u,maxAttachmentsPerMessage:c,allowedContentTypes:i,subjectMaxLength:p,bodyMaxLength:l,satisfactionCommentMaxLength:f}};export const SupportProvider=({client:e,outbox:t,openFile:r,timeZone:o,labels:n,children:s})=>{if(!t)throw new Error("[@webority/mobile-support] <SupportProvider> needs an outbox={...}, created with createOutbox from mobile-core.");const[a,u]=useState(null),[c,i]=useState(null),[p,l]=useState(!0),[f,y]=useState(0),g=useRef(new Map),m=useCallback(async()=>{l(!0);const t=`@webority/mobile-support/config:${e.basePath}`;try{const r=await e.getConfig();Storage.setItem(t,JSON.stringify(r)),u(r),i(null)}catch(e){const r=toSupportApiError(e);if(i(r),"offline"===r.code||"network"===r.code){const e=await Storage.getJson(t,parseSupportContactInfo);e&&u(e)}}finally{l(!1)}},[e]);useEffect(()=>{g.current.clear(),m()},[m]);const d=useCallback(t=>{const r=g.current.get(t.id);if(r)return r;const o=e.getAttachmentDataUri(t);return g.current.set(t.id,o),o.catch(()=>g.current.delete(t.id)),o},[e]),S=useMemo(()=>r?async t=>{const o=await saveAttachmentToCache(t,()=>e.getAttachmentBytes(t.id));await r({uri:o,name:t.fileName,contentType:t.contentType})}:null,[e,r]),b=useCallback(()=>y(e=>e+1),[]);useEffect(()=>t.subscribe(e=>{"sent"!==e.type||e.entry.queue!==SUPPORT_TICKET_QUEUE&&e.entry.queue!==SUPPORT_REPLY_QUEUE||b()}),[t,b]);const E=useMemo(()=>({client:e,outbox:t,config:a,configError:c,configLoading:p,reloadConfig:m,loadAttachment:d,openAttachment:S,timeZone:o,labels:n,revision:f,bumpRevision:b}),[e,t,a,c,p,m,d,S,o,n,f,b]);return _jsx(SupportContext.Provider,{value:E,children:s})};const useSupportContext=()=>{const e=useContext(SupportContext);if(!e)throw new Error("[@webority/mobile-support] Support screens and hooks need a <SupportProvider client={...}> above them.");return e};export const useSupportClient=()=>useSupportContext().client;export const useAttachmentLoader=()=>useSupportContext().loadAttachment;export const useAttachmentOpener=()=>useSupportContext().openAttachment;export const useSupportTimeZone=()=>useSupportContext().timeZone;export const useSupportLabels=(e,t)=>{const r=useSupportContext().labels?.[e];return useMemo(()=>r?{...t,...r}:t,[r,t])};export const useSupportConfig=()=>{const{config:e,configLoading:t,configError:r,reloadConfig:o}=useSupportContext();return{config:e,loading:t,error:r,reload:o}};const DEFAULT_PAGE_SIZE=20;export const useSupportTickets=(e={})=>{const t=e.pageSize??20,{client:r,revision:o}=useSupportContext(),[n,s]=useState(null),[a,u]=useState(""),[c,i]=useState([]),[p,l]=useState(null),[f,y]=useState(0),[g,m]=useState(0),[d,S]=useState(!0),[b,E]=useState(!1),[h,C]=useState(!1),[x,T]=useState(null),[k,A]=useState(null),w=useRef(!0),P=useRef(0),R=useRef(!1),U=useRef(null);useEffect(()=>(w.current=!0,()=>{w.current=!1}),[]);const v=useCallback(e=>{const r=a.trim();return{...n?{status:n}:{},...r?{search:r}:{},page:e,pageSize:t}},[n,a,t]),_=useCallback(async e=>{P.current+=1;const t=P.current,current=()=>w.current&&t===P.current;R.current=!1,C(!1),"refresh"===e?E(!0):"replace"===e&&(S(!0),i([]));const o="replace"!==e||U.current!==r;try{const[e,t]=await Promise.all([r.listTickets(v(1)),o?r.getTicketCounts():null]);current()&&(i(e.items),y(e.page),m(e.totalPages),t&&(l(t),U.current=r),T(null),A(null))}catch(e){current()&&T(toSupportApiError(e))}finally{current()&&(S(!1),E(!1))}},[r,v]),L=useRef(o);useEffect(()=>{const e=L.current===o?"replace":"quiet";L.current=o,_(e)},[_,o]);const O=f<g,M=useCallback(async()=>{if(R.current||d||b||!O)return;const e=P.current,current=()=>w.current&&e===P.current;R.current=!0,C(!0),A(null);try{const e=await r.listTickets(v(f+1));current()&&(i(t=>{const r=new Set(t.map(e=>e.id));return[...t,...e.items.filter(e=>!r.has(e.id))]}),y(e.page),m(e.totalPages))}catch(e){current()&&A(toSupportApiError(e))}finally{current()&&(R.current=!1,C(!1))}},[r,v,f,O,d,b]),q=useCallback(()=>_("refresh"),[_]),I=useCreateSupportTicket();return{tickets:c,counts:p,status:n,search:a,setStatus:s,setSearch:u,loading:d,refreshing:b,loadingMore:h,hasMore:O,error:x,loadMoreError:k,refresh:q,loadMore:M,createTicket:I}};const sendThroughOutbox=async(e,t,r,o)=>{try{const n=await e.send({queue:t,label:r,request:o});if("Sent"===n.status){const{data:e}=n;return isSupportTicketDetail(e)?{status:"Sent",ticket:e}:{status:"Failed",error:new SupportApiError("invalid-reply","The support desk sent a reply this app could not read. Try again.",null)}}return"Queued"===n.status?{status:"Queued",entry:n.entry}:{status:"Failed",error:new SupportApiError(n.failure.code,n.failure.message,n.failure.status)}}catch(e){if(e instanceof Error&&"OutboxFullError"===e.name)return{status:"Failed",error:new SupportApiError("outbox_full",e.message,null)};if(e instanceof Error&&"OutboxSignedOutError"===e.name)return{status:"Failed",error:new SupportApiError("signed_out",e.message,null)};throw e}};export const useCreateSupportTicket=()=>{const{client:e,outbox:t}=useSupportContext();return useCallback(r=>sendThroughOutbox(t,SUPPORT_TICKET_QUEUE,r.subject,e.ticketRequest(r)),[e,t])};const TICKET_REFRESH_MS=3e4;export const useSupportTicket=e=>{const{client:t,outbox:r,bumpRevision:o}=useSupportContext(),[n,s]=useState(null),[a,u]=useState(!0),[c,i]=useState(null),[p,l]=useState(null),[f,y]=useState(!1),[g,m]=useState([]),d=useRef(!0),S=useRef(!1),b=useMemo(()=>supportRepliesUrl(t.basePath,e),[t,e]);useEffect(()=>{S.current=f},[f]),useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]);const E=useCallback(async()=>{const e=await r.list(SUPPORT_REPLY_QUEUE);d.current&&m(e.filter(e=>e.request.url===b))},[r,b]),h=useCallback(async()=>{u(!0);try{const r=await t.getTicket(e);d.current&&(s(r),i(null))}catch(e){d.current&&i(toSupportApiError(e))}finally{d.current&&u(!1)}},[t,e]);useEffect(()=>{h()},[h]);const C=useCallback(async()=>{if(!S.current)try{const r=await t.getTicket(e);d.current&&s(e=>!e||Date.parse(r.updatedDateTimeUtc)>=Date.parse(e.updatedDateTimeUtc)?r:e)}catch(e){Logger.warn("[@webority/mobile-support] background refresh of the support ticket failed",e)}},[t,e]);useEffect(()=>(E(),r.subscribe(e=>{"sent"===e.type&&e.entry.queue===SUPPORT_REPLY_QUEUE&&e.entry.request.url===b&&d.current&&(isSupportTicketDetail(e.data)?s(e.data):(Logger.warn("[mobile-support] an outbox reply was not a ticket; refreshing"),C())),("changed"===e.type?e.queue:e.entry.queue)===SUPPORT_REPLY_QUEUE&&E()})),[r,E,C,b]),useEffect(()=>{let e=null;const start=()=>{e??=setInterval(()=>{C()},3e4)},stop=()=>{null!==e&&(clearInterval(e),e=null)};let t="active"===AppState.currentState;t&&start();const r=AppState.addEventListener("change",e=>{const r="active"===e;r!==t&&(t=r,r?(C(),start()):stop())});return()=>{r.remove(),stop()}},[C]);const x=useCallback(async e=>{y(!0),l(null);try{const t=await e();return d.current&&s(t),o(),!0}catch(e){return d.current&&l(toSupportApiError(e)),!1}finally{d.current&&y(!1)}},[o]),T=useCallback(async o=>{y(!0),l(null);try{const n=await sendThroughOutbox(r,SUPPORT_REPLY_QUEUE,o.body.slice(0,80),t.replyRequest(e,o));return d.current&&("Sent"===n.status&&s(n.ticket),"Failed"===n.status&&l(n.error)),n.status}finally{d.current&&y(!1)}},[r,t,e]),k=useCallback(()=>x(()=>t.reopen(e)),[x,t,e]),A=useCallback(()=>x(()=>t.cancel(e)),[x,t,e]),w=useCallback(r=>x(()=>t.rate(e,r)),[x,t,e]);return{ticket:n,loading:a,error:c,actionError:p,busy:f,pendingReplies:g,reload:h,reply:T,reopen:k,cancel:A,rate:w}};export const useSupportOutbox=e=>{const{outbox:t}=useSupportContext(),[r,o]=useState([]),n=useRef(!0);useEffect(()=>(n.current=!0,()=>{n.current=!1}),[]);const s=useCallback(async()=>{const r=await t.list(e);n.current&&o(r)},[t,e]);useEffect(()=>(s(),t.subscribe(t=>{("changed"===t.type?t.queue:t.entry.queue)===e&&s()})),[t,e,s]);return{entries:r,retry:useCallback(async e=>{await t.retry(e),await s()},[t,s]),discard:useCallback(async e=>{await t.discard(e),await s()},[t,s])}};
|
|
1
|
+
"use strict";import{Logger,Storage}from"@webority/mobile-core";import{useOutboxProgress}from"@webority/mobile-core/outbox";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{AppState}from"react-native";import{SupportApiError,supportRepliesUrl,toSupportApiError}from"./client.js";import{saveAttachmentToCache}from"./files.js";import{SUPPORT_REPLY_QUEUE,SUPPORT_TICKET_QUEUE}from"./types.js";import{jsx as _jsx}from"react/jsx-runtime";const SupportContext=createContext(null),changedQueue=e=>{switch(e.type){case"changed":return e.queue;case"sent":case"failed":return e.entry.queue;case"progress":return null;default:return e}},isRecord=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),isStringArray=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e),isSupportTicketDetail=e=>{if(!isRecord(e))return!1;const nullableString=e=>null===e||"string"==typeof e,nullableNumber=e=>null===e||"number"==typeof e,isLink=e=>isRecord(e)&&"string"==typeof e.id&&"string"==typeof e.number&&"string"==typeof e.subject;return"string"==typeof e.id&&"string"==typeof e.number&&"string"==typeof e.queue&&nullableNumber(e.accountId)&&nullableString(e.realm)&&"string"==typeof e.category&&"string"==typeof e.subject&&"string"==typeof e.status&&"string"==typeof e.statusLabel&&nullableString(e.priority)&&"string"==typeof e.reporterName&&(void 0===e.reporterPlace||"string"==typeof e.reporterPlace)&&"string"==typeof e.reporterEmail&&nullableNumber(e.assignedAgentUserId)&&nullableString(e.assignedAgentName)&&"boolean"==typeof e.isOverdue&&nullableString(e.pageUrl)&&nullableString(e.userAgent)&&nullableString(e.appVersion)&&nullableString(e.satisfaction)&&nullableString(e.satisfactionComment)&&"boolean"==typeof e.canReopen&&"boolean"==typeof e.canRate&&"boolean"==typeof e.canCancel&&"string"==typeof e.createdDateTimeUtc&&"string"==typeof e.updatedDateTimeUtc&&nullableString(e.resolvedDateTimeUtc)&&nullableString(e.closedDateTimeUtc)&&Array.isArray(e.messages)&&"string"==typeof e.version&&(void 0===e.mergedInto||isLink(e.mergedInto))&&(void 0===e.mergedTickets||Array.isArray(e.mergedTickets)&&e.mergedTickets.every(isLink))},parseSupportContactInfo=e=>{if(!isRecord(e))return null;const{productName:t,supportEmail:r,supportName:o,supportPhone:s,supportHours:n,categories:u,maxAttachmentBytes:a,maxAttachmentsPerMessage:c,allowedContentTypes:i,subjectMaxLength:p,bodyMaxLength:l,satisfactionCommentMaxLength:f}=e;return"string"!=typeof t||"string"!=typeof r||"string"!=typeof o||null!==s&&"string"!=typeof s||null!==n&&"string"!=typeof n||!isStringArray(u)||"number"!=typeof a||"number"!=typeof c||!isStringArray(i)||"number"!=typeof p||"number"!=typeof l||"number"!=typeof f?null:{productName:t,supportEmail:r,supportName:o,supportPhone:s,supportHours:n,categories:u,maxAttachmentBytes:a,maxAttachmentsPerMessage:c,allowedContentTypes:i,subjectMaxLength:p,bodyMaxLength:l,satisfactionCommentMaxLength:f}};export const SupportProvider=({client:e,outbox:t,openFile:r,timeZone:o,labels:s,children:n})=>{if(!t)throw new Error("[@webority/mobile-support] <SupportProvider> needs an outbox={...}, created with createOutbox from mobile-core.");const[u,a]=useState(null),[c,i]=useState(null),[p,l]=useState(!0),[f,g]=useState(0),y=useRef(new Map),d=useCallback(async()=>{l(!0);const t=`@webority/mobile-support/config:${e.basePath}`;try{const r=await e.getConfig();Storage.setItem(t,JSON.stringify(r)),a(r),i(null)}catch(e){const r=toSupportApiError(e);if(i(r),"offline"===r.code||"network"===r.code){const e=await Storage.getJson(t,parseSupportContactInfo);e&&a(e)}}finally{l(!1)}},[e]);useEffect(()=>{y.current.clear(),d()},[d]);const m=useCallback(t=>{const r=y.current.get(t.id);if(r)return r;const o=e.getAttachmentDataUri(t);return y.current.set(t.id,o),o.catch(()=>y.current.delete(t.id)),o},[e]),S=useMemo(()=>r?async t=>{const o=await saveAttachmentToCache(t,()=>e.getAttachmentBytes(t.id));await r({uri:o,name:t.fileName,contentType:t.contentType})}:null,[e,r]),b=useCallback(()=>g(e=>e+1),[]);useEffect(()=>t.subscribe(e=>{"sent"!==e.type||e.entry.queue!==SUPPORT_TICKET_QUEUE&&e.entry.queue!==SUPPORT_REPLY_QUEUE||b()}),[t,b]);const E=useMemo(()=>({client:e,outbox:t,config:u,configError:c,configLoading:p,reloadConfig:d,loadAttachment:m,openAttachment:S,timeZone:o,labels:s,revision:f,bumpRevision:b}),[e,t,u,c,p,d,m,S,o,s,f,b]);return _jsx(SupportContext.Provider,{value:E,children:n})};const useSupportContext=()=>{const e=useContext(SupportContext);if(!e)throw new Error("[@webority/mobile-support] Support screens and hooks need a <SupportProvider client={...}> above them.");return e};export const useSupportClient=()=>useSupportContext().client;export const useAttachmentLoader=()=>useSupportContext().loadAttachment;export const useAttachmentOpener=()=>useSupportContext().openAttachment;export const useSupportTimeZone=()=>useSupportContext().timeZone;export const useSupportLabels=(e,t)=>{const r=useSupportContext().labels?.[e];return useMemo(()=>r?{...t,...r}:t,[r,t])};export const useSupportConfig=()=>{const{config:e,configLoading:t,configError:r,reloadConfig:o}=useSupportContext();return{config:e,loading:t,error:r,reload:o}};const DEFAULT_PAGE_SIZE=20;export const useSupportTickets=(e={})=>{const t=e.pageSize??20,{client:r,revision:o}=useSupportContext(),[s,n]=useState(null),[u,a]=useState(""),[c,i]=useState([]),[p,l]=useState(null),[f,g]=useState(0),[y,d]=useState(0),[m,S]=useState(!0),[b,E]=useState(!1),[h,x]=useState(!1),[C,T]=useState(null),[k,A]=useState(null),P=useRef(!0),w=useRef(0),R=useRef(!1),U=useRef(null);useEffect(()=>(P.current=!0,()=>{P.current=!1}),[]);const v=useCallback(e=>{const r=u.trim();return{...s?{status:s}:{},...r?{search:r}:{},page:e,pageSize:t}},[s,u,t]),_=useCallback(async e=>{w.current+=1;const t=w.current,current=()=>P.current&&t===w.current;R.current=!1,x(!1),"refresh"===e?E(!0):"replace"===e&&(S(!0),i([]));const o="replace"!==e||U.current!==r;try{const[e,t]=await Promise.all([r.listTickets(v(1)),o?r.getTicketCounts():null]);current()&&(i(e.items),g(e.page),d(e.totalPages),t&&(l(t),U.current=r),T(null),A(null))}catch(e){current()&&T(toSupportApiError(e))}finally{current()&&(S(!1),E(!1))}},[r,v]),L=useRef(o);useEffect(()=>{const e=L.current===o?"replace":"quiet";L.current=o,_(e)},[_,o]);const O=f<y,M=useCallback(async()=>{if(R.current||m||b||!O)return;const e=w.current,current=()=>P.current&&e===w.current;R.current=!0,x(!0),A(null);try{const e=await r.listTickets(v(f+1));current()&&(i(t=>{const r=new Set(t.map(e=>e.id));return[...t,...e.items.filter(e=>!r.has(e.id))]}),g(e.page),d(e.totalPages))}catch(e){current()&&A(toSupportApiError(e))}finally{current()&&(R.current=!1,x(!1))}},[r,v,f,O,m,b]),I=useCallback(()=>_("refresh"),[_]),Q=useCreateSupportTicket();return{tickets:c,counts:p,status:s,search:u,setStatus:n,setSearch:a,loading:m,refreshing:b,loadingMore:h,hasMore:O,error:C,loadMoreError:k,refresh:I,loadMore:M,createTicket:Q}};const sendThroughOutbox=async(e,t,r,o)=>{try{const s=await e.send({queue:t,label:r,request:o});if("Sent"===s.status){const{data:e}=s;return isSupportTicketDetail(e)?{status:"Sent",ticket:e}:{status:"Failed",error:new SupportApiError("invalid-reply","The support desk sent a reply this app could not read. Try again.",null)}}return"Queued"===s.status?{status:"Queued",entry:s.entry}:{status:"Failed",error:new SupportApiError(s.failure.code,s.failure.message,s.failure.status)}}catch(e){if(e instanceof Error&&"OutboxFullError"===e.name)return{status:"Failed",error:new SupportApiError("outbox_full",e.message,null)};if(e instanceof Error&&"OutboxSignedOutError"===e.name)return{status:"Failed",error:new SupportApiError("signed_out",e.message,null)};throw e}};export const useCreateSupportTicket=()=>{const{client:e,outbox:t}=useSupportContext();return useCallback(r=>sendThroughOutbox(t,SUPPORT_TICKET_QUEUE,r.subject,e.ticketRequest(r)),[e,t])};export const useSupportUploadProgress=e=>useOutboxProgress(useSupportContext().outbox,e);const TICKET_REFRESH_MS=3e4;export const useSupportTicket=e=>{const{client:t,outbox:r,bumpRevision:o}=useSupportContext(),[s,n]=useState(null),[u,a]=useState(!0),[c,i]=useState(null),[p,l]=useState(null),[f,g]=useState(!1),[y,d]=useState([]),m=useRef(!0),S=useRef(!1),b=useMemo(()=>supportRepliesUrl(t.basePath,e),[t,e]);useEffect(()=>{S.current=f},[f]),useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);const E=useCallback(async()=>{const e=await r.list(SUPPORT_REPLY_QUEUE);m.current&&d(e.filter(e=>e.request.url===b))},[r,b]),h=useCallback(async()=>{a(!0);try{const r=await t.getTicket(e);m.current&&(n(r),i(null))}catch(e){m.current&&i(toSupportApiError(e))}finally{m.current&&a(!1)}},[t,e]);useEffect(()=>{h()},[h]);const x=useCallback(async()=>{if(!S.current)try{const r=await t.getTicket(e);m.current&&n(e=>!e||Date.parse(r.updatedDateTimeUtc)>=Date.parse(e.updatedDateTimeUtc)?r:e)}catch(e){Logger.warn("[@webority/mobile-support] background refresh of the support ticket failed",e)}},[t,e]);useEffect(()=>(E(),r.subscribe(e=>{"sent"===e.type&&e.entry.queue===SUPPORT_REPLY_QUEUE&&e.entry.request.url===b&&m.current&&(isSupportTicketDetail(e.data)?n(e.data):(Logger.warn("[mobile-support] an outbox reply was not a ticket; refreshing"),x())),changedQueue(e)===SUPPORT_REPLY_QUEUE&&E()})),[r,E,x,b]),useEffect(()=>{let e=null;const start=()=>{e??=setInterval(()=>{x()},3e4)},stop=()=>{null!==e&&(clearInterval(e),e=null)};let t="active"===AppState.currentState;t&&start();const r=AppState.addEventListener("change",e=>{const r="active"===e;r!==t&&(t=r,r?(x(),start()):stop())});return()=>{r.remove(),stop()}},[x]);const C=useCallback(async e=>{g(!0),l(null);try{const t=await e();return m.current&&n(t),o(),!0}catch(e){return m.current&&l(toSupportApiError(e)),!1}finally{m.current&&g(!1)}},[o]),T=useCallback(async o=>{g(!0),l(null);try{const s=await sendThroughOutbox(r,SUPPORT_REPLY_QUEUE,o.body.slice(0,80),t.replyRequest(e,o));return m.current&&("Sent"===s.status&&n(s.ticket),"Failed"===s.status&&l(s.error)),s.status}finally{m.current&&g(!1)}},[r,t,e]),k=useCallback(()=>C(()=>t.reopen(e)),[C,t,e]),A=useCallback(()=>C(()=>t.cancel(e)),[C,t,e]),P=useCallback(r=>C(()=>t.rate(e,r)),[C,t,e]);return{ticket:s,loading:u,error:c,actionError:p,busy:f,pendingReplies:y,reload:h,reply:T,reopen:k,cancel:A,rate:P}};export const useSupportOutbox=e=>{const{outbox:t}=useSupportContext(),[r,o]=useState([]),s=useRef(!0);useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]);const n=useCallback(async()=>{const r=await t.list(e);s.current&&o(r)},[t,e]);useEffect(()=>(n(),t.subscribe(t=>{changedQueue(t)===e&&n()})),[t,e,n]);return{entries:r,retry:useCallback(async e=>{await t.retry(e),await n()},[t,n]),discard:useCallback(async e=>{await t.discard(e),await n()},[t,n])}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useNetworkStatus}from"@webority/mobile-core";import{Button,Input,KeyboardAwareScrollView,NetworkStatusBanner,Select,Spinner,Text,useHookFormField,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{useForm}from"react-hook-form";import{StyleSheet,View}from"react-native";import{toSupportApiError}from"../client.js";import{describeDevice}from"../device.js";import{fillLabel,SHARED_LABELS}from"../labels.js";import{useCreateSupportTicket,useSupportClient,useSupportConfig,useSupportLabels}from"../SupportProvider.js";import{subjectFromMessage}from"../subject.js";import{validateBody,validateCategory,validateFiles,validateSubject}from"../validation.js";import{PhotoTray}from"./PhotoTray.js";import{SuggestedAnswers}from"./SuggestedAnswers.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const LABELS={intro:"Tell us what you need. We reply by email and in this ticket.",messageLabel:"Message",messagePlaceholder:"What happened, and what did you expect?",subjectLabel:"Subject",subjectPlaceholder:"A short summary",subjectHelper:"Filled in from your message. You can change it.",categoryLabel:"Category (optional)",categoryPlaceholder:"Choose a category",categoryHelper:"Not sure? Leave it empty and we will sort it.",screenshotLabel:"Screenshot",photosLabel:"Photos",photoLimit:"Add up to {count} photos.",cancel:"Cancel",send:"Send ticket",loading:"Loading",retry:"Try again",unavailable:"Support is not available right now."},SUGGESTION_PAUSE_MS=500,SUGGESTION_MIN_CHARS=3,TicketForm=({config:e,styles:t,onCreated:o,onQueued:s,onCancel:r,initialDraft:a,defaultCategory:
|
|
1
|
+
"use strict";import{useNetworkStatus}from"@webority/mobile-core";import{Button,Input,KeyboardAwareScrollView,NetworkStatusBanner,Select,Spinner,Text,useHookFormField,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{useForm}from"react-hook-form";import{StyleSheet,View}from"react-native";import{toSupportApiError}from"../client.js";import{describeDevice}from"../device.js";import{fillLabel,SHARED_LABELS}from"../labels.js";import{useCreateSupportTicket,useSupportClient,useSupportConfig,useSupportLabels,useSupportUploadProgress}from"../SupportProvider.js";import{subjectFromMessage}from"../subject.js";import{SUPPORT_TICKET_QUEUE}from"../types.js";import{validateBody,validateCategory,validateFiles,validateSubject}from"../validation.js";import{PhotoTray}from"./PhotoTray.js";import{SuggestedAnswers}from"./SuggestedAnswers.js";import{SupportUploadProgress}from"./SupportUploadProgress.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const LABELS={intro:"Tell us what you need. We reply by email and in this ticket.",messageLabel:"Message",messagePlaceholder:"What happened, and what did you expect?",subjectLabel:"Subject",subjectPlaceholder:"A short summary",subjectHelper:"Filled in from your message. You can change it.",categoryLabel:"Category (optional)",categoryPlaceholder:"Choose a category",categoryHelper:"Not sure? Leave it empty and we will sort it.",screenshotLabel:"Screenshot",photosLabel:"Photos",photoLimit:"Add up to {count} photos.",cancel:"Cancel",send:"Send ticket",loading:"Loading",retry:"Try again",unavailable:"Support is not available right now."},SUGGESTION_PAUSE_MS=500,SUGGESTION_MIN_CHARS=3,TicketForm=({config:e,styles:t,onCreated:o,onQueued:s,onCancel:r,initialDraft:a,defaultCategory:l,appVersion:n})=>{const i=useSupportLabels("newTicket",LABELS),u=useSupportLabels("shared",SHARED_LABELS),c=useCreateSupportTicket(),p=useSupportClient(),{isConnected:d,isInternetReachable:g}=useNetworkStatus(),m=!d||!1===g,[b,h]=useState([]),listed=t=>t&&e.categories.includes(t)?t:void 0,[y,S]=useState([]),[j,x]=useState(a?.screenshots??[]),[f,v]=useState(null),[L,w]=useState(null),T=useRef(Boolean(a?.subject?.trim())&&a?.subject!==subjectFromMessage(a?.body??"",e.subjectMaxLength)),_=useForm({defaultValues:{category:listed(a?.category)??listed(l)??"",subject:a?.subject||subjectFromMessage(a?.body??"",e.subjectMaxLength),body:a?.body??""}}),C=_.handleSubmit(async t=>{const r=validateFiles([...j,...y],e,u);if(v(r??null),!r){w(null);try{const r=await c({category:t.category,subject:t.subject.trim()||subjectFromMessage(t.body,e.subjectMaxLength),body:t.body.trim(),pageUrl:a?.pageUrl,userAgent:a?.userAgent??describeDevice(),appVersion:a?.appVersion??n,files:y,screenshots:j});"Sent"===r.status?o(r.ticket):"Queued"===r.status?s(r.entry):w(r.error.message)}catch(e){w(toSupportApiError(e).message)}}}),P=_.formState.isSubmitting,A=useSupportUploadProgress(SUPPORT_TICKET_QUEUE),F=useHookFormField({control:_.control,name:"category",rules:{validate:t=>validateCategory(t,e,u)}}),B=useHookFormField({control:_.control,name:"subject",rules:{validate:t=>""===t.trim()?void 0:validateSubject(t,e,u)}}),E=useHookFormField({control:_.control,name:"body",rules:{validate:t=>validateBody(t,e,u)}}),k=j.length+y.length;useEffect(()=>{f&&v(validateFiles([...j,...y],e,u)??null)},[y,j,f,e,u]);const I=B.value.trim();return useEffect(()=>{if(m||I.length<3)return void h([]);let e=!0;const t=setTimeout(async()=>{try{const t=await(p.getSuggestions?.(I))??[];e&&h(t)}catch{e&&h([])}},500);return()=>{e=!1,clearTimeout(t)}},[p,I,m]),_jsxs(KeyboardAwareScrollView,{contentContainerStyle:t.content,safeAreaEdges:[],children:[_jsx(Text,{variant:"bodySmall",color:"secondary",children:i.intro}),_jsx(Input,{label:i.messageLabel,placeholder:i.messagePlaceholder,required:!0,multiline:!0,maxLength:e.bodyMaxLength,value:E.value,onChangeText:t=>{E.onChangeText(t),T.current||_.setValue("subject",subjectFromMessage(t,e.subjectMaxLength))},onBlur:E.onBlur,error:E.error,testID:"support-new-body"}),_jsx(Input,{label:i.subjectLabel,placeholder:i.subjectPlaceholder,helperText:i.subjectHelper,maxLength:e.subjectMaxLength,value:B.value,onChangeText:e=>{T.current=""!==e.trim(),B.onChangeText(e)},onBlur:B.onBlur,error:B.error,testID:"support-new-subject"}),b.length>0&&_jsx(SuggestedAnswers,{articles:b,testID:"support-new-suggestions"}),_jsx(Select,{label:i.categoryLabel,placeholder:i.categoryPlaceholder,helperText:i.categoryHelper,options:e.categories.map(e=>({label:e,value:e})),value:F.value||void 0,onChange:e=>F.onChange(String(e)),error:F.error,testID:"support-new-category"}),j.length>0&&_jsx(PhotoTray,{label:i.screenshotLabel,photos:j,onChange:x,remaining:0,allowAdd:!1,maxBytes:e.maxAttachmentBytes,disabled:P}),_jsx(PhotoTray,{label:i.photosLabel,photos:y,onChange:S,remaining:e.maxAttachmentsPerMessage-k,maxBytes:e.maxAttachmentBytes,disabled:P}),_jsx(Text,{variant:"caption",color:"tertiary",children:fillLabel(i.photoLimit,{count:e.maxAttachmentsPerMessage})}),P&&_jsx(SupportUploadProgress,{progress:A,testID:"support-new-progress"}),(f||L)&&_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:f??L}),_jsxs(View,{style:t.actions,children:[r&&_jsx(Button,{label:i.cancel,variant:"ghost",tone:"neutral",onPress:r,disabled:P}),_jsx(Button,{label:i.send,loading:P,disabled:P,onPress:()=>{C()},testID:"support-new-submit"})]})]})};export const NewSupportTicket=e=>{const t=useSupportLabels("newTicket",LABELS),o=useTheme(),s=useMemo(()=>buildStyles(o),[o]),{config:r,loading:a,error:l,reload:n}=useSupportConfig(),i=e.testID??"support-new-ticket";return r?_jsxs(View,{style:s.root,testID:i,children:[_jsx(NetworkStatusBanner,{}),_jsx(TicketForm,{...e,config:r,styles:s})]}):_jsx(View,{style:s.center,testID:i,children:a?_jsx(Spinner,{accessibilityLabel:t.loading}):_jsxs(_Fragment,{children:[_jsx(Text,{variant:"body",color:"danger",align:"center",children:l?.message??t.unavailable}),_jsx(Button,{label:t.retry,variant:"ghost",onPress:()=>{n()}})]})})};const buildStyles=e=>StyleSheet.create({root:{flex:1},content:{padding:e.space.md,gap:e.space.md},center:{flex:1,alignItems:"center",justifyContent:"center",padding:e.space.xl,gap:e.space.sm},actions:{flexDirection:"row",justifyContent:"flex-end",gap:e.space.sm}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{formatDateTime}from"@webority/mobile-core";import{Button,Card,Composer,confirm,Descriptions,Dialog,IconButton,Input,KeyboardAwareScrollView,Spinner,StatusBadge,Text,useTheme}from"@webority/mobile-ui";import{useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{fillLabel,SHARED_LABELS}from"../labels.js";import{useSupportConfig,useSupportLabels,useSupportOutbox,useSupportTicket,useSupportTimeZone}from"../SupportProvider.js";import{SUPPORT_REPLY_QUEUE}from"../types.js";import{validateBody,validateFiles}from"../validation.js";import{AttachmentList,ImageViewer}from"./Attachments.js";import{PhotoTray}from"./PhotoTray.js";import{STATUS_TONES}from"./SupportTicketList.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const LABELS={sendNow:"Send now",discard:"Discard",loading:"Loading the ticket",retry:"Try again",replyReopens:"Replying reopens this ticket.",opened:"Opened {date}",updated:"Updated {date}",merged:"This ticket was merged into {number}. The conversation carries on there.",openMerged:"Open {number}",resolvedNote:"This ticket is {status}. Reopen it if you still need help.",reopen:"Reopen ticket",withdraw:"Withdraw request",withdrawTitle:"Withdraw this request?",withdrawMessage:"Our team will stop working on this ticket. You can open a new ticket later if you still need help.",withdrawConfirm:"Withdraw request",withdrawCancel:"Keep request",yourComment:"Your comment: {comment}",solved:"Yes, it is solved",notSolved:"No, it is not",commentLabel:"Anything to add? (optional)",commentHelper:"Your comment goes to the support team.",sendAnswer:"Send answer",conversation:"Conversation",mergedBadge:"Merged into this ticket",replyPlaceholder:"Write a reply to the support team",replyLabel:"Your reply",attachPhoto:"Attach a photo",sendReply:"Send reply",you:"You",writeMessage:"Write a message.",supportTeam:"Support team",replyFailed:"Your reply did not send. Please try again.",waitingToSend:"Waiting to send",notFound:"That ticket could not be found.",discardTitle:"Discard this report?",discardMessage:"It has not been sent.",statusAccessibility:"Status: {label}",waitingText:"We need your answer to carry on. Reply below and the ticket goes back to our team.",satisfied:"You told us this solved your problem.",unsatisfied:"You told us this did not solve your problem.",ratingQuestion:"Did this solve your problem?",detailsTitle:"Ticket details",detailStatus:"Status",detailCategory:"Category",detailTicket:"Ticket",detailOpened:"Opened",detailLastUpdate:"Last update"},MessageBubble=({message:e,styles:t,timeZone:s,labels:a,onOpenImage:i})=>{if("System"===e.authorKind)return _jsx(View,{style:t.system,testID:`support-message-${e.id}`,children:_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:`${e.body}, ${formatDateTime(e.createdDateTimeUtc,{zone:s})}`})});const n="Customer"===e.authorKind;return _jsx(View,{style:[t.bubbleRow,n?t.mineRow:t.theirsRow],testID:`support-message-${e.id}`,children:_jsxs(View,{style:[t.bubble,n?t.mine:t.theirs],children:[_jsx(Text,{variant:"label",color:n?"primary":"secondary",children:e.authorName??(n?a.you:a.supportTeam)}),_jsx(Text,{variant:"body",selectable:!0,children:e.body}),_jsx(AttachmentList,{attachments:e.attachments,onOpenImage:i}),_jsx(Text,{variant:"caption",color:"tertiary",children:formatDateTime(e.createdDateTimeUtc,{zone:s})})]})})},pendingReplyBody=e=>{const{body:t}=e.request;if("json"===t.kind){const e=t.value;return"object"==typeof e&&null!==e&&"body"in e&&"string"==typeof e.body?e.body:""}const s=t.fields.find(e=>"body"===e.name);return s&&"value"in s?s.value:""},PendingReplyBubble=({entry:e,styles:t,labels:s,onSendNow:a,onDiscard:i})=>{const n="Failed"===e.state;return _jsx(View,{style:[t.bubbleRow,t.mineRow],testID:`support-pending-${e.id}`,children:_jsxs(View,{style:[t.bubble,t.mine],children:[_jsx(Text,{variant:"label",color:"primary",children:s.you}),_jsx(Text,{variant:"body",selectable:!0,children:pendingReplyBody(e)}),_jsx(Text,{variant:"caption",color:n?"danger":"tertiary",accessibilityLiveRegion:"polite",children:n?s.replyFailed:s.waitingToSend}),_jsxs(View,{style:t.ratingRow,children:[_jsx(Button,{label:s.sendNow,size:"sm",variant:"outline",onPress:()=>a(e.id),testID:`support-pending-send-${e.id}`}),_jsx(Button,{label:s.discard,size:"sm",variant:"ghost",onPress:()=>i(e.id),testID:`support-pending-discard-${e.id}`})]})]})})};export const SupportTicketDetail=({ticketId:e,onOpenTicket:t,testID:s="support-ticket-detail"})=>{const a=useSupportLabels("ticketDetail",LABELS),i=useSupportLabels("shared",SHARED_LABELS),n=useTheme(),o=useMemo(()=>buildStyles(n),[n]),{config:r}=useSupportConfig(),l=useSupportTimeZone(),{ticket:d,loading:c,error:p,actionError:u,busy:m,pendingReplies:b,reload:y,reply:g,reopen:h,cancel:x,rate:S}=useSupportTicket(e),j=useSupportOutbox(SUPPORT_REPLY_QUEUE),[w,T]=useState(null),[f,_]=useState(""),[v,D]=useState([]),[L,R]=useState(!1),[I,C]=useState(null),[k,B]=useState(null),[P,U]=useState(""),[A,V]=useState(!1);if(!d)return _jsx(View,{style:o.center,testID:s,children:c?_jsx(Spinner,{accessibilityLabel:a.loading}):_jsxs(_Fragment,{children:[_jsx(Text,{variant:"body",color:"danger",align:"center",children:p?.message??a.notFound}),_jsx(Button,{label:a.retry,variant:"ghost",onPress:()=>{y()}})]})});const O={Satisfied:a.satisfied,Unsatisfied:a.unsatisfied},z=d.mergedInto,E=d.messages.filter(e=>!e.isInternal),M=d.updatedDateTimeUtc!==d.createdDateTimeUtc,$=I??u?.message??null,F=Boolean(r)&&(L||v.length>0),N=F||$||d.canReopen?_jsxs(_Fragment,{children:[F&&r&&_jsx(PhotoTray,{photos:v,onChange:e=>{D(e),C(null)},remaining:r.maxAttachmentsPerMessage-v.length,maxBytes:r.maxAttachmentBytes,disabled:m}),$&&_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:$}),d.canReopen&&_jsx(Text,{variant:"caption",color:"secondary",children:a.replyReopens})]}):void 0;return _jsxs(View,{style:o.root,testID:s,children:[_jsxs(KeyboardAwareScrollView,{contentContainerStyle:o.content,safeAreaEdges:[],children:[_jsxs(View,{style:o.head,children:[_jsx(Text,{variant:"h3",accessibilityRole:"header",children:d.subject}),_jsx(Text,{variant:"bodySmall",color:"secondary",children:`${d.number}, ${d.category}`}),_jsxs(View,{style:o.headRow,children:[_jsx(StatusBadge,{label:d.statusLabel,tone:STATUS_TONES[d.status]??"neutral",accessibilityLabel:fillLabel(a.statusAccessibility,{label:d.statusLabel})}),_jsx(Text,{variant:"caption",color:"tertiary",children:fillLabel(a.opened,{date:formatDateTime(d.createdDateTimeUtc,{zone:l})})}),M&&_jsx(Text,{variant:"caption",color:"tertiary",children:fillLabel(a.updated,{date:formatDateTime(d.updatedDateTimeUtc,{zone:l})})})]})]}),z&&_jsxs(Card,{variant:"outline",bodyStyle:o.section,testID:"support-merged-into",children:[_jsx(Text,{variant:"bodySmall",accessibilityLiveRegion:"polite",children:fillLabel(a.merged,{number:z.number})}),t&&_jsx(Button,{label:fillLabel(a.openMerged,{number:z.number}),variant:"link",size:"sm",onPress:()=>t(z.id),testID:"support-merged-into-open"})]}),"WaitingOnCustomer"===d.status&&_jsx(Card,{variant:"outline",bodyStyle:o.section,testID:"support-waiting",children:_jsx(Text,{variant:"bodySmall",children:a.waitingText})}),d.canReopen&&_jsxs(Card,{variant:"outline",bodyStyle:o.section,children:[_jsx(Text,{variant:"bodySmall",children:fillLabel(a.resolvedNote,{status:d.statusLabel.toLowerCase()})}),_jsx(Button,{label:a.reopen,variant:"outline",size:"sm",loading:m,disabled:m,onPress:()=>{h()},testID:"support-reopen"})]}),d.canCancel&&_jsxs(Card,{variant:"outline",bodyStyle:o.section,children:[_jsx(Button,{label:a.withdraw,variant:"outline",size:"sm",loading:m,disabled:m,onPress:()=>V(!0),testID:"support-withdraw"}),_jsx(Dialog,{open:A,onClose:()=>V(!1),title:a.withdrawTitle,message:a.withdrawMessage,tone:"danger",actions:[{label:a.withdrawCancel,onPress:()=>V(!1),tone:"neutral"},{label:a.withdrawConfirm,onPress:()=>{x()},tone:"danger"}]})]}),d.satisfaction?_jsxs(Card,{variant:"outline",bodyStyle:o.section,testID:"support-rating",children:[_jsx(Text,{variant:"bodySmall",accessibilityLiveRegion:"polite",children:O[d.satisfaction]}),d.satisfactionComment?_jsx(Text,{variant:"bodySmall",color:"secondary",children:fillLabel(a.yourComment,{comment:d.satisfactionComment})}):null]}):d.canRate?_jsxs(Card,{variant:"outline",bodyStyle:o.section,testID:"support-rating",children:[_jsx(Text,{variant:"label",children:a.ratingQuestion}),_jsxs(View,{style:o.ratingRow,children:[_jsx(Button,{label:a.solved,size:"sm",leftIcon:"like",variant:"Satisfied"===k?"solid":"outline",tone:"success",accessibilityState:{selected:"Satisfied"===k},"aria-selected":"Satisfied"===k,onPress:()=>B("Satisfied"),testID:"support-rate-satisfied"}),_jsx(Button,{label:a.notSolved,size:"sm",leftIcon:"dislike",variant:"Unsatisfied"===k?"solid":"outline",tone:"danger",accessibilityState:{selected:"Unsatisfied"===k},"aria-selected":"Unsatisfied"===k,onPress:()=>B("Unsatisfied"),testID:"support-rate-unsatisfied"})]}),k&&_jsxs(_Fragment,{children:[_jsx(Input,{label:a.commentLabel,helperText:a.commentHelper,value:P,onChangeText:U,multiline:!0,maxLength:r?.satisfactionCommentMaxLength,testID:"support-rating-comment"}),_jsx(Button,{label:a.sendAnswer,size:"sm",loading:m,disabled:m,onPress:()=>{(async()=>{k&&await S({satisfaction:k,comment:P})&&(B(null),U(""))})()},testID:"support-rating-send"})]})]}):null,_jsxs(View,{style:o.thread,accessibilityLabel:a.conversation,children:[E.map(e=>_jsx(MessageBubble,{message:e,styles:o,timeZone:l,labels:a,onOpenImage:(e,t)=>T({uri:e,name:t})},e.id)),b.map(e=>_jsx(PendingReplyBubble,{entry:e,styles:o,labels:a,onSendNow:e=>{j.retry(e)},onDiscard:e=>{(async e=>{await confirm({title:a.discardTitle,message:a.discardMessage,confirmLabel:a.discard,tone:"danger"})&&await j.discard(e)})(e)}},e.id))]}),d.mergedTickets&&d.mergedTickets.length>0&&_jsxs(View,{style:o.section,testID:"support-merged-tickets",children:[_jsx(Text,{variant:"label",accessibilityRole:"header",children:a.mergedBadge}),d.mergedTickets.map(e=>t?_jsx(Button,{label:`${e.number}: ${e.subject}`,variant:"link",size:"sm",onPress:()=>t(e.id),testID:`support-merged-ticket-${e.id}`},e.id):_jsx(Text,{variant:"bodySmall",testID:`support-merged-ticket-${e.id}`,children:`${e.number}: ${e.subject}`},e.id))]}),_jsxs(Card,{variant:"outline",bodyStyle:o.section,testID:"support-details",accessibilityRole:"summary",children:[_jsx(Text,{variant:"label",children:a.detailsTitle}),_jsx(Descriptions,{items:[{label:a.detailStatus,value:_jsx(StatusBadge,{label:d.statusLabel,tone:STATUS_TONES[d.status]??"neutral",accessibilityLabel:fillLabel(a.statusAccessibility,{label:d.statusLabel})})},{label:a.detailCategory,value:d.category||"-"},{label:a.detailTicket,value:d.number},{label:a.detailOpened,value:formatDateTime(d.createdDateTimeUtc,{zone:l})},{label:a.detailLastUpdate,value:formatDateTime(d.updatedDateTimeUtc,{zone:l})}]})]})]}),!z&&_jsx(Composer,{value:f,onChangeText:e=>{_(e),C(null)},onSend:e=>{(async e=>{const t=e.trim(),s=r?validateBody(t,r,i)??validateFiles(v,r,i):t?void 0:a.writeMessage;if(s)return C(s),void _(e);"Failed"!==await g({body:t,files:v})?(D([]),R(!1)):_(e)})(e)},loading:m,maxLength:r?.bodyMaxLength,placeholder:a.replyPlaceholder,accessibilityLabel:a.replyLabel,labels:{send:a.sendReply,message:a.replyLabel},leading:_jsx(IconButton,{icon:"paperclip",size:"md",accessibilityLabel:a.attachPhoto,disabled:m||!r,onPress:()=>R(e=>!e),testID:"support-reply-attach"}),above:N,testID:"support-reply-composer"}),_jsx(ImageViewer,{image:w,onClose:()=>T(null)})]})};const buildStyles=e=>StyleSheet.create({root:{flex:1},content:{padding:e.space.md,gap:e.space.md},center:{flex:1,alignItems:"center",justifyContent:"center",padding:e.space.xl,gap:e.space.sm},head:{gap:e.space.xxs},headRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm,marginTop:e.space.xs},section:{gap:e.space.sm},ratingRow:{flexDirection:"row",flexWrap:"wrap",gap:e.space.sm},thread:{gap:e.space.sm},system:{paddingHorizontal:e.space.lg,paddingVertical:e.space.xxs},bubbleRow:{flexDirection:"row"},mineRow:{justifyContent:"flex-end"},theirsRow:{justifyContent:"flex-start"},bubble:{maxWidth:"85%",borderRadius:e.radius.lg,padding:e.space.sm,gap:e.space.xxs},mine:{backgroundColor:e.colors["primary-soft"]},theirs:{backgroundColor:e.colors["bg-subtle"]}});
|
|
1
|
+
"use strict";import{formatDateTime}from"@webority/mobile-core";import{Button,Card,Composer,confirm,Descriptions,Dialog,IconButton,Input,KeyboardAwareScrollView,Spinner,StatusBadge,Text,useTheme}from"@webority/mobile-ui";import{useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{fillLabel,SHARED_LABELS}from"../labels.js";import{useSupportConfig,useSupportLabels,useSupportOutbox,useSupportTicket,useSupportTimeZone,useSupportUploadProgress}from"../SupportProvider.js";import{SUPPORT_REPLY_QUEUE}from"../types.js";import{validateBody,validateFiles}from"../validation.js";import{AttachmentList,ImageViewer}from"./Attachments.js";import{PhotoTray}from"./PhotoTray.js";import{STATUS_TONES}from"./SupportTicketList.js";import{SupportUploadProgress}from"./SupportUploadProgress.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const LABELS={sendNow:"Send now",discard:"Discard",loading:"Loading the ticket",retry:"Try again",replyReopens:"Replying reopens this ticket.",opened:"Opened {date}",updated:"Updated {date}",merged:"This ticket was merged into {number}. The conversation carries on there.",openMerged:"Open {number}",resolvedNote:"This ticket is {status}. Reopen it if you still need help.",reopen:"Reopen ticket",withdraw:"Withdraw request",withdrawTitle:"Withdraw this request?",withdrawMessage:"Our team will stop working on this ticket. You can open a new ticket later if you still need help.",withdrawConfirm:"Withdraw request",withdrawCancel:"Keep request",yourComment:"Your comment: {comment}",solved:"Yes, it is solved",notSolved:"No, it is not",commentLabel:"Anything to add? (optional)",commentHelper:"Your comment goes to the support team.",sendAnswer:"Send answer",conversation:"Conversation",mergedBadge:"Merged into this ticket",replyPlaceholder:"Write a reply to the support team",replyLabel:"Your reply",attachPhoto:"Attach a photo",sendReply:"Send reply",you:"You",writeMessage:"Write a message.",supportTeam:"Support team",replyFailed:"Your reply did not send. Please try again.",waitingToSend:"Waiting to send",notFound:"That ticket could not be found.",discardTitle:"Discard this report?",discardMessage:"It has not been sent.",statusAccessibility:"Status: {label}",waitingText:"We need your answer to carry on. Reply below and the ticket goes back to our team.",satisfied:"You told us this solved your problem.",unsatisfied:"You told us this did not solve your problem.",ratingQuestion:"Did this solve your problem?",detailsTitle:"Ticket details",detailStatus:"Status",detailCategory:"Category",detailTicket:"Ticket",detailOpened:"Opened",detailLastUpdate:"Last update"},MessageBubble=({message:e,styles:t,timeZone:s,labels:a,onOpenImage:i})=>{if("System"===e.authorKind)return _jsx(View,{style:t.system,testID:`support-message-${e.id}`,children:_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:`${e.body}, ${formatDateTime(e.createdDateTimeUtc,{zone:s})}`})});const o="Customer"===e.authorKind;return _jsx(View,{style:[t.bubbleRow,o?t.mineRow:t.theirsRow],testID:`support-message-${e.id}`,children:_jsxs(View,{style:[t.bubble,o?t.mine:t.theirs],children:[_jsx(Text,{variant:"label",color:o?"primary":"secondary",children:e.authorName??(o?a.you:a.supportTeam)}),_jsx(Text,{variant:"body",selectable:!0,children:e.body}),_jsx(AttachmentList,{attachments:e.attachments,onOpenImage:i}),_jsx(Text,{variant:"caption",color:"tertiary",children:formatDateTime(e.createdDateTimeUtc,{zone:s})})]})})},pendingReplyBody=e=>{const{body:t}=e.request;switch(t.kind){case"json":{const e=t.value;return"object"==typeof e&&null!==e&&"body"in e&&"string"==typeof e.body?e.body:""}case"multipart":{const e=t.fields.find(e=>"body"===e.name);return e&&"value"in e?e.value:""}case"resumable":return"";default:return t}},PendingReplyBubble=({entry:e,styles:t,labels:s,onSendNow:a,onDiscard:i})=>{const o="Failed"===e.state;return _jsx(View,{style:[t.bubbleRow,t.mineRow],testID:`support-pending-${e.id}`,children:_jsxs(View,{style:[t.bubble,t.mine],children:[_jsx(Text,{variant:"label",color:"primary",children:s.you}),_jsx(Text,{variant:"body",selectable:!0,children:pendingReplyBody(e)}),_jsx(Text,{variant:"caption",color:o?"danger":"tertiary",accessibilityLiveRegion:"polite",children:o?s.replyFailed:s.waitingToSend}),_jsxs(View,{style:t.ratingRow,children:[_jsx(Button,{label:s.sendNow,size:"sm",variant:"outline",onPress:()=>a(e.id),testID:`support-pending-send-${e.id}`}),_jsx(Button,{label:s.discard,size:"sm",variant:"ghost",onPress:()=>i(e.id),testID:`support-pending-discard-${e.id}`})]})]})})};export const SupportTicketDetail=({ticketId:e,onOpenTicket:t,testID:s="support-ticket-detail"})=>{const a=useSupportLabels("ticketDetail",LABELS),i=useSupportLabels("shared",SHARED_LABELS),o=useTheme(),r=useMemo(()=>buildStyles(o),[o]),{config:n}=useSupportConfig(),l=useSupportTimeZone(),{ticket:d,loading:c,error:p,actionError:u,busy:m,pendingReplies:b,reload:y,reply:g,reopen:h,cancel:x,rate:S}=useSupportTicket(e),j=useSupportOutbox(SUPPORT_REPLY_QUEUE),w=useSupportUploadProgress(SUPPORT_REPLY_QUEUE),[T,_]=useState(null),[f,v]=useState(""),[D,L]=useState([]),[R,I]=useState(!1),[C,P]=useState(null),[k,B]=useState(null),[U,A]=useState(""),[E,O]=useState(!1);if(!d)return _jsx(View,{style:r.center,testID:s,children:c?_jsx(Spinner,{accessibilityLabel:a.loading}):_jsxs(_Fragment,{children:[_jsx(Text,{variant:"body",color:"danger",align:"center",children:p?.message??a.notFound}),_jsx(Button,{label:a.retry,variant:"ghost",onPress:()=>{y()}})]})});const V={Satisfied:a.satisfied,Unsatisfied:a.unsatisfied},z=d.mergedInto,M=d.messages.filter(e=>!e.isInternal),$=d.updatedDateTimeUtc!==d.createdDateTimeUtc,F=C??u?.message??null,Y=Boolean(n)&&(R||D.length>0),N=Y||F||d.canReopen||m?_jsxs(_Fragment,{children:[m&&_jsx(SupportUploadProgress,{progress:w,testID:"support-reply-progress"}),Y&&n&&_jsx(PhotoTray,{photos:D,onChange:e=>{L(e),P(null)},remaining:n.maxAttachmentsPerMessage-D.length,maxBytes:n.maxAttachmentBytes,disabled:m}),F&&_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:F}),d.canReopen&&_jsx(Text,{variant:"caption",color:"secondary",children:a.replyReopens})]}):void 0;return _jsxs(View,{style:r.root,testID:s,children:[_jsxs(KeyboardAwareScrollView,{contentContainerStyle:r.content,safeAreaEdges:[],children:[_jsxs(View,{style:r.head,children:[_jsx(Text,{variant:"h3",accessibilityRole:"header",children:d.subject}),_jsx(Text,{variant:"bodySmall",color:"secondary",children:`${d.number}, ${d.category}`}),_jsxs(View,{style:r.headRow,children:[_jsx(StatusBadge,{label:d.statusLabel,tone:STATUS_TONES[d.status]??"neutral",accessibilityLabel:fillLabel(a.statusAccessibility,{label:d.statusLabel})}),_jsx(Text,{variant:"caption",color:"tertiary",children:fillLabel(a.opened,{date:formatDateTime(d.createdDateTimeUtc,{zone:l})})}),$&&_jsx(Text,{variant:"caption",color:"tertiary",children:fillLabel(a.updated,{date:formatDateTime(d.updatedDateTimeUtc,{zone:l})})})]})]}),z&&_jsxs(Card,{variant:"outline",bodyStyle:r.section,testID:"support-merged-into",children:[_jsx(Text,{variant:"bodySmall",accessibilityLiveRegion:"polite",children:fillLabel(a.merged,{number:z.number})}),t&&_jsx(Button,{label:fillLabel(a.openMerged,{number:z.number}),variant:"link",size:"sm",onPress:()=>t(z.id),testID:"support-merged-into-open"})]}),"WaitingOnCustomer"===d.status&&_jsx(Card,{variant:"outline",bodyStyle:r.section,testID:"support-waiting",children:_jsx(Text,{variant:"bodySmall",children:a.waitingText})}),d.canReopen&&_jsxs(Card,{variant:"outline",bodyStyle:r.section,children:[_jsx(Text,{variant:"bodySmall",children:fillLabel(a.resolvedNote,{status:d.statusLabel.toLowerCase()})}),_jsx(Button,{label:a.reopen,variant:"outline",size:"sm",loading:m,disabled:m,onPress:()=>{h()},testID:"support-reopen"})]}),d.canCancel&&_jsxs(Card,{variant:"outline",bodyStyle:r.section,children:[_jsx(Button,{label:a.withdraw,variant:"outline",size:"sm",loading:m,disabled:m,onPress:()=>O(!0),testID:"support-withdraw"}),_jsx(Dialog,{open:E,onClose:()=>O(!1),title:a.withdrawTitle,message:a.withdrawMessage,tone:"danger",actions:[{label:a.withdrawCancel,onPress:()=>O(!1),tone:"neutral"},{label:a.withdrawConfirm,onPress:()=>{x()},tone:"danger"}]})]}),d.satisfaction?_jsxs(Card,{variant:"outline",bodyStyle:r.section,testID:"support-rating",children:[_jsx(Text,{variant:"bodySmall",accessibilityLiveRegion:"polite",children:V[d.satisfaction]}),d.satisfactionComment?_jsx(Text,{variant:"bodySmall",color:"secondary",children:fillLabel(a.yourComment,{comment:d.satisfactionComment})}):null]}):d.canRate?_jsxs(Card,{variant:"outline",bodyStyle:r.section,testID:"support-rating",children:[_jsx(Text,{variant:"label",children:a.ratingQuestion}),_jsxs(View,{style:r.ratingRow,children:[_jsx(Button,{label:a.solved,size:"sm",leftIcon:"like",variant:"Satisfied"===k?"solid":"outline",tone:"success",accessibilityState:{selected:"Satisfied"===k},"aria-selected":"Satisfied"===k,onPress:()=>B("Satisfied"),testID:"support-rate-satisfied"}),_jsx(Button,{label:a.notSolved,size:"sm",leftIcon:"dislike",variant:"Unsatisfied"===k?"solid":"outline",tone:"danger",accessibilityState:{selected:"Unsatisfied"===k},"aria-selected":"Unsatisfied"===k,onPress:()=>B("Unsatisfied"),testID:"support-rate-unsatisfied"})]}),k&&_jsxs(_Fragment,{children:[_jsx(Input,{label:a.commentLabel,helperText:a.commentHelper,value:U,onChangeText:A,multiline:!0,maxLength:n?.satisfactionCommentMaxLength,testID:"support-rating-comment"}),_jsx(Button,{label:a.sendAnswer,size:"sm",loading:m,disabled:m,onPress:()=>{(async()=>{k&&await S({satisfaction:k,comment:U})&&(B(null),A(""))})()},testID:"support-rating-send"})]})]}):null,_jsxs(View,{style:r.thread,accessibilityLabel:a.conversation,children:[M.map(e=>_jsx(MessageBubble,{message:e,styles:r,timeZone:l,labels:a,onOpenImage:(e,t)=>_({uri:e,name:t})},e.id)),b.map(e=>_jsx(PendingReplyBubble,{entry:e,styles:r,labels:a,onSendNow:e=>{j.retry(e)},onDiscard:e=>{(async e=>{await confirm({title:a.discardTitle,message:a.discardMessage,confirmLabel:a.discard,tone:"danger"})&&await j.discard(e)})(e)}},e.id))]}),d.mergedTickets&&d.mergedTickets.length>0&&_jsxs(View,{style:r.section,testID:"support-merged-tickets",children:[_jsx(Text,{variant:"label",accessibilityRole:"header",children:a.mergedBadge}),d.mergedTickets.map(e=>t?_jsx(Button,{label:`${e.number}: ${e.subject}`,variant:"link",size:"sm",onPress:()=>t(e.id),testID:`support-merged-ticket-${e.id}`},e.id):_jsx(Text,{variant:"bodySmall",testID:`support-merged-ticket-${e.id}`,children:`${e.number}: ${e.subject}`},e.id))]}),_jsxs(Card,{variant:"outline",bodyStyle:r.section,testID:"support-details",accessibilityRole:"summary",children:[_jsx(Text,{variant:"label",children:a.detailsTitle}),_jsx(Descriptions,{items:[{label:a.detailStatus,value:_jsx(StatusBadge,{label:d.statusLabel,tone:STATUS_TONES[d.status]??"neutral",accessibilityLabel:fillLabel(a.statusAccessibility,{label:d.statusLabel})})},{label:a.detailCategory,value:d.category||"-"},{label:a.detailTicket,value:d.number},{label:a.detailOpened,value:formatDateTime(d.createdDateTimeUtc,{zone:l})},{label:a.detailLastUpdate,value:formatDateTime(d.updatedDateTimeUtc,{zone:l})}]})]})]}),!z&&_jsx(Composer,{value:f,onChangeText:e=>{v(e),P(null)},onSend:e=>{(async e=>{const t=e.trim(),s=n?validateBody(t,n,i)??validateFiles(D,n,i):t?void 0:a.writeMessage;if(s)return P(s),void v(e);"Failed"!==await g({body:t,files:D})?(L([]),I(!1)):v(e)})(e)},loading:m,maxLength:n?.bodyMaxLength,placeholder:a.replyPlaceholder,accessibilityLabel:a.replyLabel,labels:{send:a.sendReply,message:a.replyLabel},leading:_jsx(IconButton,{icon:"paperclip",size:"md",accessibilityLabel:a.attachPhoto,disabled:m||!n,onPress:()=>I(e=>!e),testID:"support-reply-attach"}),above:N,testID:"support-reply-composer"}),_jsx(ImageViewer,{image:T,onClose:()=>_(null)})]})};const buildStyles=e=>StyleSheet.create({root:{flex:1},content:{padding:e.space.md,gap:e.space.md},center:{flex:1,alignItems:"center",justifyContent:"center",padding:e.space.xl,gap:e.space.sm},head:{gap:e.space.xxs},headRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm,marginTop:e.space.xs},section:{gap:e.space.sm},ratingRow:{flexDirection:"row",flexWrap:"wrap",gap:e.space.sm},thread:{gap:e.space.sm},system:{paddingHorizontal:e.space.lg,paddingVertical:e.space.xxs},bubbleRow:{flexDirection:"row"},mineRow:{justifyContent:"flex-end"},theirsRow:{justifyContent:"flex-start"},bubble:{maxWidth:"85%",borderRadius:e.radius.lg,padding:e.space.sm,gap:e.space.xxs},mine:{backgroundColor:e.colors["primary-soft"]},theirs:{backgroundColor:e.colors["bg-subtle"]}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{ProgressBar}from"@webority/mobile-ui";import{fillLabel}from"../labels.js";import{useSupportLabels}from"../SupportProvider.js";import{jsx as _jsx}from"react/jsx-runtime";const LABELS={sending:"Sending",sendingPercent:"Sending, {percent} percent"};export const SupportUploadProgress=({progress:e,testID:r})=>{const s=useSupportLabels("upload",LABELS);if(!e)return null;const n=e.fraction;return _jsx(ProgressBar,{progress:n??void 0,indeterminate:null===n,showPercent:null!==n,label:s.sending,accessibilityLabel:null===n?s.sending:fillLabel(s.sendingPercent,{percent:Math.round(100*n)}),testID:r})};
|
package/lib/module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{createSupportClient,SupportApiError,toSupportApiError}from"./client.js";export{NewSupportTicket}from"./components/NewSupportTicket.js";export{SupportContact}from"./components/SupportContact.js";export{SupportTicketDetail}from"./components/SupportTicketDetail.js";export{SupportTicketList}from"./components/SupportTicketList.js";export{describeDevice}from"./device.js";export{HelpArticle}from"./helpCentre/HelpArticle.js";export{HelpCentre}from"./helpCentre/HelpCentre.js";export{useHelpCentre}from"./helpCentre/useHelpCentre.js";export{SHARED_LABELS}from"./labels.js";export{SupportProvider,useCreateSupportTicket,useSupportClient,useSupportConfig,useSupportLabels,useSupportOutbox,useSupportTicket,useSupportTickets}from"./SupportProvider.js";export{SUPPORT_REPLY_QUEUE,SUPPORT_TICKET_QUEUE}from"./types.js";
|
|
1
|
+
"use strict";export{createSupportClient,SupportApiError,toSupportApiError}from"./client.js";export{NewSupportTicket}from"./components/NewSupportTicket.js";export{SupportContact}from"./components/SupportContact.js";export{SupportTicketDetail}from"./components/SupportTicketDetail.js";export{SupportTicketList}from"./components/SupportTicketList.js";export{SupportUploadProgress}from"./components/SupportUploadProgress.js";export{describeDevice}from"./device.js";export{HelpArticle}from"./helpCentre/HelpArticle.js";export{HelpCentre}from"./helpCentre/HelpCentre.js";export{useHelpCentre}from"./helpCentre/useHelpCentre.js";export{SHARED_LABELS}from"./labels.js";export{SupportProvider,useCreateSupportTicket,useSupportClient,useSupportConfig,useSupportLabels,useSupportOutbox,useSupportTicket,useSupportTickets,useSupportUploadProgress}from"./SupportProvider.js";export{SUPPORT_REPLY_QUEUE,SUPPORT_TICKET_QUEUE}from"./types.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ZoneOption } from "@webority/mobile-core";
|
|
2
|
-
import type { Outbox, OutboxEntry } from "@webority/mobile-core/outbox";
|
|
2
|
+
import type { Outbox, OutboxEntry, OutboxProgress } from "@webority/mobile-core/outbox";
|
|
3
3
|
import type React from "react";
|
|
4
4
|
import { SupportApiError, type SupportClient } from "./client";
|
|
5
5
|
import type { SupportLabelOverrides } from "./labels";
|
|
@@ -81,6 +81,7 @@ export interface SupportTicketsState {
|
|
|
81
81
|
export declare const useSupportTickets: (options?: SupportTicketsOptions) => SupportTicketsState;
|
|
82
82
|
/** Raises a ticket and tells every mounted ticket list to refetch. */
|
|
83
83
|
export declare const useCreateSupportTicket: () => ((input: NewSupportTicketInput) => Promise<SupportSubmitResult>);
|
|
84
|
+
export declare const useSupportUploadProgress: (queue: string) => OutboxProgress | null;
|
|
84
85
|
export interface SupportTicketState {
|
|
85
86
|
ticket: SupportTicketDetail | null;
|
|
86
87
|
loading: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OutboxEntry } from "@webority/mobile-core/outbox";
|
|
2
2
|
import type React from "react";
|
|
3
|
-
import type
|
|
3
|
+
import { type SupportTicketDetail, type SupportTicketDraft } from "../types";
|
|
4
4
|
export interface NewSupportTicketProps {
|
|
5
5
|
/** Called with the created ticket; navigate to its detail from here. */
|
|
6
6
|
onCreated: (ticket: SupportTicketDetail) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OutboxProgress } from "@webority/mobile-core/outbox";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
export declare const SupportUploadProgress: React.FC<{
|
|
4
|
+
progress: OutboxProgress | null;
|
|
5
|
+
testID?: string | undefined;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=SupportUploadProgress.d.ts.map
|
|
@@ -8,6 +8,7 @@ export type { SupportTicketDetailProps } from "./components/SupportTicketDetail"
|
|
|
8
8
|
export { SupportTicketDetail } from "./components/SupportTicketDetail";
|
|
9
9
|
export type { SupportTicketListProps } from "./components/SupportTicketList";
|
|
10
10
|
export { SupportTicketList } from "./components/SupportTicketList";
|
|
11
|
+
export { SupportUploadProgress } from "./components/SupportUploadProgress";
|
|
11
12
|
export { describeDevice } from "./device";
|
|
12
13
|
export type { HelpArticleProps } from "./helpCentre/HelpArticle";
|
|
13
14
|
export { HelpArticle } from "./helpCentre/HelpArticle";
|
|
@@ -18,7 +19,7 @@ export { useHelpCentre } from "./helpCentre/useHelpCentre";
|
|
|
18
19
|
export type { SupportLabelOverrides } from "./labels";
|
|
19
20
|
export { SHARED_LABELS } from "./labels";
|
|
20
21
|
export type { SupportConfigState, SupportFileOpener, SupportFileToOpen, SupportProviderProps, SupportTicketState, SupportTicketsOptions, SupportTicketsState, } from "./SupportProvider";
|
|
21
|
-
export { SupportProvider, useCreateSupportTicket, useSupportClient, useSupportConfig, useSupportLabels, useSupportOutbox, useSupportTicket, useSupportTickets, } from "./SupportProvider";
|
|
22
|
+
export { SupportProvider, useCreateSupportTicket, useSupportClient, useSupportConfig, useSupportLabels, useSupportOutbox, useSupportTicket, useSupportTickets, useSupportUploadProgress, } from "./SupportProvider";
|
|
22
23
|
export type { HelpArticleSummary, HelpArticleView, HelpCentreSettings, NewSupportTicketInput, SupportAttachmentKind, SupportAttachmentView, SupportContactInfo, SupportCustomerStatus, SupportFilePart, SupportMessageAuthorKind, SupportMessageView, SupportPage, SupportRatingInput, SupportReplyInput, SupportSatisfaction, SupportStatusCountKey, SupportSubmitResult, SupportSuggestedArticle, SupportTicketCounts, SupportTicketDetail as SupportTicketDetailView, SupportTicketDraft, SupportTicketLink, SupportTicketPriority, SupportTicketQuery, SupportTicketStatus, SupportTicketSummary, } from "./types";
|
|
23
24
|
export { SUPPORT_REPLY_QUEUE, SUPPORT_TICKET_QUEUE } from "./types";
|
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ZoneOption } from "@webority/mobile-core";
|
|
2
|
-
import type { Outbox, OutboxEntry } from "@webority/mobile-core/outbox";
|
|
2
|
+
import type { Outbox, OutboxEntry, OutboxProgress } from "@webority/mobile-core/outbox";
|
|
3
3
|
import type React from "react";
|
|
4
4
|
import { SupportApiError, type SupportClient } from "./client.js";
|
|
5
5
|
import type { SupportLabelOverrides } from "./labels.js";
|
|
@@ -81,6 +81,7 @@ export interface SupportTicketsState {
|
|
|
81
81
|
export declare const useSupportTickets: (options?: SupportTicketsOptions) => SupportTicketsState;
|
|
82
82
|
/** Raises a ticket and tells every mounted ticket list to refetch. */
|
|
83
83
|
export declare const useCreateSupportTicket: () => ((input: NewSupportTicketInput) => Promise<SupportSubmitResult>);
|
|
84
|
+
export declare const useSupportUploadProgress: (queue: string) => OutboxProgress | null;
|
|
84
85
|
export interface SupportTicketState {
|
|
85
86
|
ticket: SupportTicketDetail | null;
|
|
86
87
|
loading: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OutboxEntry } from "@webority/mobile-core/outbox";
|
|
2
2
|
import type React from "react";
|
|
3
|
-
import type
|
|
3
|
+
import { type SupportTicketDetail, type SupportTicketDraft } from "../types.js";
|
|
4
4
|
export interface NewSupportTicketProps {
|
|
5
5
|
/** Called with the created ticket; navigate to its detail from here. */
|
|
6
6
|
onCreated: (ticket: SupportTicketDetail) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OutboxProgress } from "@webority/mobile-core/outbox";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
export declare const SupportUploadProgress: React.FC<{
|
|
4
|
+
progress: OutboxProgress | null;
|
|
5
|
+
testID?: string | undefined;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=SupportUploadProgress.d.ts.map
|
|
@@ -8,6 +8,7 @@ export type { SupportTicketDetailProps } from "./components/SupportTicketDetail.
|
|
|
8
8
|
export { SupportTicketDetail } from "./components/SupportTicketDetail.js";
|
|
9
9
|
export type { SupportTicketListProps } from "./components/SupportTicketList.js";
|
|
10
10
|
export { SupportTicketList } from "./components/SupportTicketList.js";
|
|
11
|
+
export { SupportUploadProgress } from "./components/SupportUploadProgress.js";
|
|
11
12
|
export { describeDevice } from "./device.js";
|
|
12
13
|
export type { HelpArticleProps } from "./helpCentre/HelpArticle.js";
|
|
13
14
|
export { HelpArticle } from "./helpCentre/HelpArticle.js";
|
|
@@ -18,7 +19,7 @@ export { useHelpCentre } from "./helpCentre/useHelpCentre.js";
|
|
|
18
19
|
export type { SupportLabelOverrides } from "./labels.js";
|
|
19
20
|
export { SHARED_LABELS } from "./labels.js";
|
|
20
21
|
export type { SupportConfigState, SupportFileOpener, SupportFileToOpen, SupportProviderProps, SupportTicketState, SupportTicketsOptions, SupportTicketsState, } from "./SupportProvider.js";
|
|
21
|
-
export { SupportProvider, useCreateSupportTicket, useSupportClient, useSupportConfig, useSupportLabels, useSupportOutbox, useSupportTicket, useSupportTickets, } from "./SupportProvider.js";
|
|
22
|
+
export { SupportProvider, useCreateSupportTicket, useSupportClient, useSupportConfig, useSupportLabels, useSupportOutbox, useSupportTicket, useSupportTickets, useSupportUploadProgress, } from "./SupportProvider.js";
|
|
22
23
|
export type { HelpArticleSummary, HelpArticleView, HelpCentreSettings, NewSupportTicketInput, SupportAttachmentKind, SupportAttachmentView, SupportContactInfo, SupportCustomerStatus, SupportFilePart, SupportMessageAuthorKind, SupportMessageView, SupportPage, SupportRatingInput, SupportReplyInput, SupportSatisfaction, SupportStatusCountKey, SupportSubmitResult, SupportSuggestedArticle, SupportTicketCounts, SupportTicketDetail as SupportTicketDetailView, SupportTicketDraft, SupportTicketLink, SupportTicketPriority, SupportTicketQuery, SupportTicketStatus, SupportTicketSummary, } from "./types.js";
|
|
23
24
|
export { SUPPORT_REPLY_QUEUE, SUPPORT_TICKET_QUEUE } from "./types.js";
|
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/mobile-support",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.169.0",
|
|
4
4
|
"description": "Customer support tickets for Webority React Native apps: the support API client, hooks, ticket screens, contact card and a report-an-issue button that attaches a screenshot.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"!**/*.map"
|
|
63
63
|
],
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@webority/mobile-core": "0.
|
|
66
|
-
"@webority/mobile-ui": "0.
|
|
65
|
+
"@webority/mobile-core": "0.169.0",
|
|
66
|
+
"@webority/mobile-ui": "0.169.0",
|
|
67
67
|
"expo": ">=58.0.0",
|
|
68
68
|
"expo-file-system": ">=58.0.0",
|
|
69
69
|
"expo-image-manipulator": ">=58.0.0",
|
|
@@ -123,10 +123,11 @@
|
|
|
123
123
|
"devDependencies": {
|
|
124
124
|
"@react-native/metro-config": "0.88.1",
|
|
125
125
|
"@testing-library/react-native": "14.1.0",
|
|
126
|
+
"@types/jest": "29.5.14",
|
|
126
127
|
"@types/react": "19.3.0",
|
|
127
|
-
"@webority/mobile-core": "0.
|
|
128
|
+
"@webority/mobile-core": "0.169.0",
|
|
128
129
|
"@webority/mobile-dev": "0.0.0",
|
|
129
|
-
"@webority/mobile-ui": "0.
|
|
130
|
+
"@webority/mobile-ui": "0.169.0",
|
|
130
131
|
"expo": "58.0.23",
|
|
131
132
|
"expo-file-system": "58.0.13",
|
|
132
133
|
"expo-image-manipulator": "58.0.16",
|
|
@@ -144,6 +145,7 @@
|
|
|
144
145
|
"clean": "node -e \"require('node:fs').rmSync('lib',{recursive:true,force:true})\"",
|
|
145
146
|
"lint": "biome lint ./src",
|
|
146
147
|
"lint:fix": "biome lint --write ./src",
|
|
147
|
-
"test": "jest"
|
|
148
|
+
"test": "jest",
|
|
149
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.build.json"
|
|
148
150
|
}
|
|
149
151
|
}
|