@tellescope/react-components 1.172.1 → 1.174.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/lib/cjs/Forms/forms.d.ts.map +1 -1
- package/lib/cjs/Forms/forms.js +1 -1
- package/lib/cjs/Forms/forms.js.map +1 -1
- package/lib/cjs/Forms/hooks.d.ts +6 -2
- package/lib/cjs/Forms/hooks.d.ts.map +1 -1
- package/lib/cjs/Forms/hooks.js +6 -1
- package/lib/cjs/Forms/hooks.js.map +1 -1
- package/lib/cjs/Forms/inputs.d.ts +1 -1
- package/lib/cjs/Forms/inputs.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.js +14 -4
- package/lib/cjs/Forms/inputs.js.map +1 -1
- package/lib/cjs/inputs_shared.d.ts +4 -1
- package/lib/cjs/inputs_shared.d.ts.map +1 -1
- package/lib/cjs/inputs_shared.js +7 -1
- package/lib/cjs/inputs_shared.js.map +1 -1
- package/lib/cjs/state.d.ts +49 -0
- package/lib/cjs/state.d.ts.map +1 -1
- package/lib/cjs/state.js +74 -17
- package/lib/cjs/state.js.map +1 -1
- package/lib/cjs/table.d.ts +5 -2
- package/lib/cjs/table.d.ts.map +1 -1
- package/lib/cjs/table.js +7 -7
- package/lib/cjs/table.js.map +1 -1
- package/lib/esm/Forms/forms.d.ts.map +1 -1
- package/lib/esm/Forms/forms.js +1 -1
- package/lib/esm/Forms/forms.js.map +1 -1
- package/lib/esm/Forms/hooks.d.ts +6 -2
- package/lib/esm/Forms/hooks.d.ts.map +1 -1
- package/lib/esm/Forms/hooks.js +6 -1
- package/lib/esm/Forms/hooks.js.map +1 -1
- package/lib/esm/Forms/inputs.d.ts +1 -1
- package/lib/esm/Forms/inputs.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.js +14 -4
- package/lib/esm/Forms/inputs.js.map +1 -1
- package/lib/esm/inputs_shared.d.ts +4 -1
- package/lib/esm/inputs_shared.d.ts.map +1 -1
- package/lib/esm/inputs_shared.js +6 -1
- package/lib/esm/inputs_shared.js.map +1 -1
- package/lib/esm/state.d.ts +49 -0
- package/lib/esm/state.d.ts.map +1 -1
- package/lib/esm/state.js +70 -14
- package/lib/esm/state.js.map +1 -1
- package/lib/esm/table.d.ts +5 -2
- package/lib/esm/table.d.ts.map +1 -1
- package/lib/esm/table.js +7 -7
- package/lib/esm/table.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/Forms/forms.tsx +4 -1
- package/src/Forms/hooks.tsx +7 -2
- package/src/Forms/inputs.tsx +25 -3
- package/src/inputs_shared.tsx +13 -2
- package/src/state.tsx +79 -14
- package/src/table.tsx +8 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/react-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.174.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"@reduxjs/toolkit": "^1.6.2",
|
|
48
48
|
"@stripe/react-stripe-js": "^2.9.0",
|
|
49
49
|
"@stripe/stripe-js": "^1.52.1",
|
|
50
|
-
"@tellescope/constants": "^1.
|
|
51
|
-
"@tellescope/sdk": "^1.
|
|
52
|
-
"@tellescope/types-client": "^1.
|
|
53
|
-
"@tellescope/types-models": "^1.
|
|
54
|
-
"@tellescope/types-utilities": "^1.
|
|
55
|
-
"@tellescope/utilities": "^1.
|
|
56
|
-
"@tellescope/validation": "^1.
|
|
50
|
+
"@tellescope/constants": "^1.174.0",
|
|
51
|
+
"@tellescope/sdk": "^1.174.0",
|
|
52
|
+
"@tellescope/types-client": "^1.174.0",
|
|
53
|
+
"@tellescope/types-models": "^1.174.0",
|
|
54
|
+
"@tellescope/types-utilities": "^1.174.0",
|
|
55
|
+
"@tellescope/utilities": "^1.174.0",
|
|
56
|
+
"@tellescope/validation": "^1.174.0",
|
|
57
57
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
58
58
|
"@typescript-eslint/parser": "^4.33.0",
|
|
59
59
|
"css-to-react-native": "^3.0.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
85
85
|
"react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "b18cb31c80f3294f01abeb2bcb2d73c19441f738",
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
}
|
package/src/Forms/forms.tsx
CHANGED
|
@@ -967,7 +967,10 @@ export const TellescopeSinglePageForm: React.JSXElementConstructor<TellescopeFor
|
|
|
967
967
|
const list = useListForFormFields(fields, responses, { form: props.form, gender: enduser?.gender })
|
|
968
968
|
|
|
969
969
|
const includedFieldIds = (
|
|
970
|
-
Array.from(new Set([
|
|
970
|
+
Array.from(new Set([
|
|
971
|
+
...list.map(f => f.id),
|
|
972
|
+
...(existingResponses ?? []).filter(e => !e.isPrepopulatedFromEnduserField).map(e => e.fieldId)
|
|
973
|
+
]))
|
|
971
974
|
)
|
|
972
975
|
|
|
973
976
|
const handleSubmit = useCallback(async () => {
|
package/src/Forms/hooks.tsx
CHANGED
|
@@ -348,7 +348,7 @@ interface UseTellescopeFormOptions {
|
|
|
348
348
|
automationStepId?: string,
|
|
349
349
|
form?: Form,
|
|
350
350
|
fields: FormField[],
|
|
351
|
-
existingResponses?:
|
|
351
|
+
existingResponses?: (FormResponseValue & { isPrepopulatedFromEnduserField?: boolean })[],
|
|
352
352
|
formResponseId?: string,
|
|
353
353
|
isInternalNote?: boolean,
|
|
354
354
|
formTitle?: string,
|
|
@@ -1213,7 +1213,12 @@ export const useTellescopeForm = ({ isPublicForm, form, urlLogicValue, customiza
|
|
|
1213
1213
|
responses: [
|
|
1214
1214
|
...responsesToSubmit,
|
|
1215
1215
|
// include existing responses in case previously saved as draft
|
|
1216
|
-
...(existingResponses ?? []).filter(r =>
|
|
1216
|
+
...(existingResponses ?? []).filter(r =>
|
|
1217
|
+
!responsesToSubmit.find(_r => r.fieldId === _r.fieldId)
|
|
1218
|
+
// but don't include responses which were populated from a patient field and not a prior response
|
|
1219
|
+
// if these are edited, they would be included in responsesToSubmit
|
|
1220
|
+
&& !r.isPrepopulatedFromEnduserField
|
|
1221
|
+
),
|
|
1217
1222
|
],
|
|
1218
1223
|
automationStepId,
|
|
1219
1224
|
customerId,
|
package/src/Forms/inputs.tsx
CHANGED
|
@@ -355,6 +355,23 @@ export const TableInput = ({ field, value=[], onChange, ...props }: FormInputPro
|
|
|
355
355
|
</Select>
|
|
356
356
|
</FormControl>
|
|
357
357
|
)
|
|
358
|
+
: (v.type === 'Database' && v.info.databaseId && v.info.databaseLabel) ? (
|
|
359
|
+
<DatabaseSelectInput responses={[]} size="small"
|
|
360
|
+
field={{
|
|
361
|
+
...field,
|
|
362
|
+
options: { databaseId: v.info.databaseId, databaseLabel: v.info.databaseLabel },
|
|
363
|
+
title: v.label,
|
|
364
|
+
}}
|
|
365
|
+
value={row.find((_, _i) => columnIndex === _i)?.entry ? [{
|
|
366
|
+
text: JSON.parse(row.find((_, _i) => columnIndex === _i)?.entry || '{}').text || '',
|
|
367
|
+
databaseId: JSON.parse(row.find((_, _i) => columnIndex === _i)?.entry || '{}').databaseId || '',
|
|
368
|
+
recordId: JSON.parse(row.find((_, _i) => columnIndex === _i)?.entry || '{}').recordId || '',
|
|
369
|
+
}] : []}
|
|
370
|
+
onChange={
|
|
371
|
+
(records) => handleChange(i, columnIndex, { label: v.label, entry: JSON.stringify(records?.[0] ?? '') })
|
|
372
|
+
}
|
|
373
|
+
/>
|
|
374
|
+
)
|
|
358
375
|
: null
|
|
359
376
|
}
|
|
360
377
|
</Grid>
|
|
@@ -1761,6 +1778,7 @@ const choicesForDatabase: {
|
|
|
1761
1778
|
lastId?: string,
|
|
1762
1779
|
}
|
|
1763
1780
|
} = {}
|
|
1781
|
+
const preventRefetch: Record<string, boolean> = {}
|
|
1764
1782
|
|
|
1765
1783
|
const LOAD_CHOICES_LIMIT = 500
|
|
1766
1784
|
const useDatabaseChoices = ({ databaseId='', field, otherAnswers } : { databaseId?: string, field: FormField, otherAnswers?: DatabaseSelectResponse[] }) => {
|
|
@@ -1774,11 +1792,14 @@ const useDatabaseChoices = ({ databaseId='', field, otherAnswers } : { databaseI
|
|
|
1774
1792
|
const choices = choicesForDatabase[databaseId]?.records ?? []
|
|
1775
1793
|
const lastId = choicesForDatabase[databaseId]?.lastId
|
|
1776
1794
|
|
|
1795
|
+
if (preventRefetch[databaseId + field.id + lastId]) return
|
|
1796
|
+
preventRefetch[databaseId + field.id + lastId] = true
|
|
1797
|
+
|
|
1777
1798
|
session.api.form_fields.load_choices_from_database({
|
|
1778
1799
|
fieldId: field.id,
|
|
1779
1800
|
lastId,
|
|
1780
1801
|
limit: LOAD_CHOICES_LIMIT,
|
|
1781
|
-
databaseId, //
|
|
1802
|
+
databaseId, // overrides fieldId, supports using Database question in Table Input
|
|
1782
1803
|
})
|
|
1783
1804
|
.then(({ choices: newChoices }) => {
|
|
1784
1805
|
choicesForDatabase[databaseId] = {
|
|
@@ -1795,6 +1816,7 @@ const useDatabaseChoices = ({ databaseId='', field, otherAnswers } : { databaseI
|
|
|
1795
1816
|
})
|
|
1796
1817
|
.catch(err => {
|
|
1797
1818
|
console.error(err)
|
|
1819
|
+
preventRefetch[databaseId + field.id + lastId] = false
|
|
1798
1820
|
})
|
|
1799
1821
|
}, [session, field, databaseId, renderCount])
|
|
1800
1822
|
|
|
@@ -1849,7 +1871,7 @@ const get_other_answers = (_value?: DatabaseSelectResponse[], typing?: string) =
|
|
|
1849
1871
|
return []
|
|
1850
1872
|
}
|
|
1851
1873
|
|
|
1852
|
-
export const DatabaseSelectInput = ({ field, value: _value, onChange, onDatabaseSelect, responses }: FormInputProps<'Database Select'> & {
|
|
1874
|
+
export const DatabaseSelectInput = ({ field, value: _value, onChange, onDatabaseSelect, responses, size }: FormInputProps<'Database Select'> & {
|
|
1853
1875
|
responses: FormResponseValue[],
|
|
1854
1876
|
}) => {
|
|
1855
1877
|
const [typing, setTyping] = useState('')
|
|
@@ -1944,7 +1966,7 @@ export const DatabaseSelectInput = ({ field, value: _value, onChange, onDatabase
|
|
|
1944
1966
|
|
|
1945
1967
|
if (!doneLoading) return <LinearProgress />
|
|
1946
1968
|
return (
|
|
1947
|
-
<Autocomplete id={field.id} freeSolo={false}
|
|
1969
|
+
<Autocomplete id={field.id} freeSolo={false} size={size}
|
|
1948
1970
|
componentsProps={{ popper: { sx: { wordBreak: "break-word" } } } }
|
|
1949
1971
|
options={filteredChoices} multiple={true}
|
|
1950
1972
|
getOptionLabel={o => (
|
package/src/inputs_shared.tsx
CHANGED
|
@@ -5,8 +5,8 @@ import { LoadFunction, LoadFunctionArguments } from "@tellescope/sdk"
|
|
|
5
5
|
import { ALL_ACCESS, UNSEARCHABLE_FIELDS } from "@tellescope/constants"
|
|
6
6
|
import { SearchAPIProps, useSearchAPI } from "./hooks"
|
|
7
7
|
import { TextFieldProps } from "./mui"
|
|
8
|
-
import { AgentRecord, AllergyCode, AppointmentBookingPage, AppointmentLocation, AutomationTrigger, CalendarEventTemplate, CallHoldQueue, ChatRoom, Database, DatabaseRecord, DiagnosisCode, Enduser, EnduserOrder, FaxLog, File, Form, FormGroup, Forum, Journey, ManagedContentRecord, MessageTemplateSnippet, Organization, PrescriptionRoute, SuggestedContact, Template, Ticket, TicketQueue, User, UserNotification } from "@tellescope/types-client"
|
|
9
|
-
import { Button, Checkbox, Flex, HoverPaper, LoadingButton, LoadingData, LoadingLinear, ScrollingList, SearchTextInput, Typography, useAgentRecords, useAllergyCodes, useAppointmentBookingPages, useAppointmentLocations, useAutomationTriggers, useCalendarEventTemplates, useCallHoldQueues, useChatRooms, useDatabaseRecords, useDatabases, useDiagnosisCodes, useEnduserOrders, useEndusers, useFaxLogs, useFiles, useFormGroups, useForms, useForums, useJourneys, useManagedContentRecords, useMessageTemplateSnippets, useNotifications, useOrganization, useOrganizations, usePrescriptionRoutes, useResolvedSession, useSession, useSuggestedContacts, useTemplates, useTicketQueues, useTickets, useUsers, value_is_loaded } from "."
|
|
8
|
+
import { AgentRecord, AllergyCode, AppointmentBookingPage, AppointmentLocation, AutomationTrigger, CalendarEventTemplate, CallHoldQueue, ChatRoom, Database, DatabaseRecord, DiagnosisCode, Enduser, EnduserOrder, FaxLog, File, Form, FormGroup, Forum, Journey, ManagedContentRecord, MessageTemplateSnippet, Organization, PrescriptionRoute, SuggestedContact, Template, Ticket, TicketQueue, User, UserNotification, Waitlist } from "@tellescope/types-client"
|
|
9
|
+
import { Button, Checkbox, Flex, HoverPaper, LoadingButton, LoadingData, LoadingLinear, ScrollingList, SearchTextInput, Typography, useAgentRecords, useAllergyCodes, useAppointmentBookingPages, useAppointmentLocations, useAutomationTriggers, useCalendarEventTemplates, useCallHoldQueues, useChatRooms, useDatabaseRecords, useDatabases, useDiagnosisCodes, useEnduserOrders, useEndusers, useFaxLogs, useFiles, useFormGroups, useForms, useForums, useJourneys, useManagedContentRecords, useMessageTemplateSnippets, useNotifications, useOrganization, useOrganizations, usePrescriptionRoutes, useResolvedSession, useSession, useSuggestedContacts, useTemplates, useTicketQueues, useTickets, useUsers, useWaitlists, value_is_loaded } from "."
|
|
10
10
|
import { SxProps } from "@mui/material"
|
|
11
11
|
import { AccessPermissions } from "@tellescope/types-models"
|
|
12
12
|
|
|
@@ -618,6 +618,17 @@ export const SuggestedContactSearch = (props: Omit<GenericSearchProps<SuggestedC
|
|
|
618
618
|
)
|
|
619
619
|
}
|
|
620
620
|
|
|
621
|
+
export const WaitlistSearch = (props: Omit<GenericSearchProps<Waitlist>, 'filterKey'> & { filterKey?: string }) => {
|
|
622
|
+
const session = useSession()
|
|
623
|
+
const [, { addLocalElements }] = useWaitlists({ dontFetch: true })
|
|
624
|
+
return (
|
|
625
|
+
<ModelSearchInput filterKey="waitlist" {...props}
|
|
626
|
+
searchAPI={session.api.waitlists.getSome}
|
|
627
|
+
onLoad={addLocalElements}
|
|
628
|
+
/>
|
|
629
|
+
)
|
|
630
|
+
}
|
|
631
|
+
|
|
621
632
|
export const AgentRecordSearch = (props: Omit<GenericSearchProps<AgentRecord>, 'filterKey'> & { filterKey?: string }) => {
|
|
622
633
|
const session = useSession()
|
|
623
634
|
const [, { addLocalElements }] = useAgentRecords({ dontFetch: true })
|
package/src/state.tsx
CHANGED
|
@@ -98,6 +98,7 @@ import {
|
|
|
98
98
|
IntegrationLog,
|
|
99
99
|
EnduserEligibilityResult,
|
|
100
100
|
AgentRecord,
|
|
101
|
+
Waitlist,
|
|
101
102
|
} from "@tellescope/types-client"
|
|
102
103
|
|
|
103
104
|
import {
|
|
@@ -363,6 +364,7 @@ const allergyCodesSlice = createSliceForList<AllergyCode, 'allergy_codes'>('alle
|
|
|
363
364
|
const integrationLogsSlice = createSliceForList<IntegrationLog, 'integration_logs'>('integration_logs')
|
|
364
365
|
const enduserEligibilityResultsSlice = createSliceForList<EnduserEligibilityResult, 'enduser_eligibility_results'>('enduser_eligibility_results')
|
|
365
366
|
const agentRecordsSlice = createSliceForList<AgentRecord, 'agent_records'>('agent_records')
|
|
367
|
+
const waitlistsSlice = createSliceForList<Waitlist, 'waitlists'>('waitlists')
|
|
366
368
|
|
|
367
369
|
const roleBasedAccessPermissionsSlice = createSliceForList<RoleBasedAccessPermission, 'role_based_access_permissions'>('role_based_access_permissions')
|
|
368
370
|
|
|
@@ -455,6 +457,7 @@ export const sharedConfig = {
|
|
|
455
457
|
suggested_contacts: suggestedContactsSlice.reducer,
|
|
456
458
|
diagnosis_codes: diagnosisCodesSlice.reducer,
|
|
457
459
|
allergy_codes: allergyCodesSlice.reducer,
|
|
460
|
+
waitlists: waitlistsSlice.reducer,
|
|
458
461
|
},
|
|
459
462
|
}
|
|
460
463
|
|
|
@@ -528,10 +531,13 @@ export interface LoadMoreFunctions<T> {
|
|
|
528
531
|
|
|
529
532
|
export const INACTIVE_SYNC_INTERVAL_IN_MS = 30000
|
|
530
533
|
export const DEFAULT_SYNC_INTERVAL_IN_MS = 15000
|
|
534
|
+
export const MEDIUM_SYNC_INTERAVL = 10000
|
|
531
535
|
export const FAST_SYNC_INTERVAL = 5000
|
|
532
536
|
|
|
533
537
|
export const lastActiveForSync = { at: new Date(0), hasFocus: true }
|
|
534
538
|
|
|
539
|
+
export const lastDataSync = { current : { numResults: 0, at: new Date(0), from: new Date(0), latency: 0, duration: 0 } }
|
|
540
|
+
|
|
535
541
|
export const useDataSync____internal = () => {
|
|
536
542
|
const session = useSession()
|
|
537
543
|
const lastFetch = React.useRef(new Date())
|
|
@@ -576,11 +582,31 @@ export const useDataSync____internal = () => {
|
|
|
576
582
|
...Object.values(loadTimings.current).filter(v => v > 999)
|
|
577
583
|
)
|
|
578
584
|
|
|
585
|
+
const handleLoadedData = () => {
|
|
586
|
+
for (const handler of Object.values(handlers.current)) {
|
|
587
|
+
try {
|
|
588
|
+
handler?.()
|
|
589
|
+
} catch(err) { console.error(err) }
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
579
593
|
if (lastFetch.current.getTime() + pollDurationInMS > Date.now()) {
|
|
580
594
|
return
|
|
581
595
|
}
|
|
582
596
|
|
|
583
|
-
|
|
597
|
+
// ensure we don't miss updates due to latency
|
|
598
|
+
const from = new Date(lastFetch.current.getTime() - 1000) // large leeway could result in same data being fetched twice, but helps ensure nothing is dropped
|
|
599
|
+
lastFetch.current = new Date() // update before syncing, not after it returns
|
|
600
|
+
|
|
601
|
+
session
|
|
602
|
+
.sync({ from })
|
|
603
|
+
.then(({ results }) => {
|
|
604
|
+
lastDataSync.current = {
|
|
605
|
+
numResults: results.length, at: lastFetch.current, from,
|
|
606
|
+
latency: Date.now() - lastFetch.current.getTime(),
|
|
607
|
+
duration: pollDurationInMS,
|
|
608
|
+
}
|
|
609
|
+
|
|
584
610
|
for (const r of results) {
|
|
585
611
|
if (r.data === 'deleted') {
|
|
586
612
|
if (!deleted.current[r.modelName]) {
|
|
@@ -599,14 +625,11 @@ export const useDataSync____internal = () => {
|
|
|
599
625
|
}
|
|
600
626
|
}
|
|
601
627
|
})
|
|
602
|
-
.then(
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
628
|
+
.then(handleLoadedData)
|
|
629
|
+
.catch(err => {
|
|
630
|
+
console.error('Sync error', err)
|
|
631
|
+
lastFetch.current = from // don't skip this interval yet
|
|
606
632
|
})
|
|
607
|
-
.catch(console.error)
|
|
608
|
-
|
|
609
|
-
lastFetch.current = new Date()
|
|
610
633
|
}, 1000)
|
|
611
634
|
|
|
612
635
|
return () => { clearInterval(i) }
|
|
@@ -631,12 +654,31 @@ export const useDataSync____internal = () => {
|
|
|
631
654
|
}, [])
|
|
632
655
|
|
|
633
656
|
const setHandler = useCallback((key: string, handler: undefined | (() => void)) => {
|
|
657
|
+
// call handler when initially set in case results were loaded when there was no handler
|
|
658
|
+
if (!handlers.current[key] && handler) {
|
|
659
|
+
try {
|
|
660
|
+
// console.log("handle on add", key)
|
|
661
|
+
handler?.()
|
|
662
|
+
}
|
|
663
|
+
catch(err) {
|
|
664
|
+
console.error(err)
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// console.log('setting handler', key)
|
|
634
669
|
handlers.current[key] = handler
|
|
635
670
|
}, [])
|
|
636
671
|
|
|
672
|
+
const removeHandler = useCallback((key: string, handler: () => void) => {
|
|
673
|
+
if (handlers.current[key] !== handler) return // if a handler was overwritten, don't remove it
|
|
674
|
+
|
|
675
|
+
// console.log('removing handler', key)
|
|
676
|
+
delete handlers.current[key]
|
|
677
|
+
}, [])
|
|
678
|
+
|
|
637
679
|
return {
|
|
638
680
|
setLoadTiming,
|
|
639
|
-
setHandler,
|
|
681
|
+
setHandler, removeHandler,
|
|
640
682
|
getLoaded, getDeleted,
|
|
641
683
|
popLoaded, popDeleted,
|
|
642
684
|
}
|
|
@@ -702,7 +744,7 @@ export const useListStateHook = <T extends { id: string | number }, ADD extends
|
|
|
702
744
|
} & HookOptions<T>
|
|
703
745
|
): ListStateReturnType<T, ADD> =>
|
|
704
746
|
{
|
|
705
|
-
const { setHandler, popDeleted, popLoaded } = useSyncContext() ?? {}
|
|
747
|
+
const { setHandler, popDeleted, popLoaded, removeHandler } = useSyncContext() ?? {}
|
|
706
748
|
const { loadQuery, findOne, findByIds, addOne, addSome, updateOne, deleteOne } = apiCalls
|
|
707
749
|
if (options?.refetchInMS !== undefined && options.refetchInMS < 5000) {
|
|
708
750
|
throw new Error("refetchInMS must be greater than 5000")
|
|
@@ -790,7 +832,7 @@ export const useListStateHook = <T extends { id: string | number }, ADD extends
|
|
|
790
832
|
// context not provided
|
|
791
833
|
if (!setHandler) return
|
|
792
834
|
|
|
793
|
-
|
|
835
|
+
const handler = () => {
|
|
794
836
|
if (state.status !== LoadingStatus.Loaded) return
|
|
795
837
|
|
|
796
838
|
const deleted = popDeleted(modelName)
|
|
@@ -802,8 +844,12 @@ export const useListStateHook = <T extends { id: string | number }, ADD extends
|
|
|
802
844
|
if (loaded?.length) {
|
|
803
845
|
addLocalElements(loaded as any, { replaceIfMatch: true })
|
|
804
846
|
}
|
|
805
|
-
}
|
|
806
|
-
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
setHandler(modelName, handler)
|
|
850
|
+
|
|
851
|
+
return () => { removeHandler(modelName, handler) }
|
|
852
|
+
}, [modelName, state.status, setHandler, removeHandler, addLocalElements, removeLocalElements, popDeleted, popLoaded])
|
|
807
853
|
|
|
808
854
|
const findById: ListUpdateMethods<T, ADD>['findById'] = useCallback((id, options) => {
|
|
809
855
|
if (!id) return undefined
|
|
@@ -980,7 +1026,7 @@ export const useListStateHook = <T extends { id: string | number }, ADD extends
|
|
|
980
1026
|
const sortBy = loadOptions?.sortBy ?? options?.sortBy
|
|
981
1027
|
|
|
982
1028
|
if (!loadQuery) return
|
|
983
|
-
if (options?.dontFetch) return
|
|
1029
|
+
if (options?.dontFetch && !force) return
|
|
984
1030
|
const fetchKey = (loadFilter || sort || sortBy) ? JSON.stringify({ ...loadFilter, sort, sortBy }) + modelName : modelName
|
|
985
1031
|
|
|
986
1032
|
if (didFetch(fetchKey, force, options?.refetchInMS)) return
|
|
@@ -2837,4 +2883,23 @@ export const useCalendarEventsForUser = (options={} as HookOptions<CalendarEvent
|
|
|
2837
2883
|
}, [session, loadedRef, fetchEvents, addLocalElements])
|
|
2838
2884
|
|
|
2839
2885
|
return [eventsLoading, { loadEvents, filtered }] as const
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
export const useWaitlists = (options={} as HookOptions<Waitlist>) => {
|
|
2889
|
+
const session = useSession()
|
|
2890
|
+
|
|
2891
|
+
return useListStateHook('waitlists', useTypedSelector(s => s.waitlists), session, waitlistsSlice,
|
|
2892
|
+
{
|
|
2893
|
+
loadQuery: session.api.waitlists.getSome,
|
|
2894
|
+
findOne: session.api.waitlists.getOne,
|
|
2895
|
+
findByIds: session.api.waitlists.getByIds,
|
|
2896
|
+
addOne: session.api.waitlists.createOne,
|
|
2897
|
+
addSome: session.api.waitlists.createSome,
|
|
2898
|
+
deleteOne: session.api.waitlists.deleteOne,
|
|
2899
|
+
updateOne: session.api.waitlists.updateOne,
|
|
2900
|
+
},
|
|
2901
|
+
{
|
|
2902
|
+
...options,
|
|
2903
|
+
},
|
|
2904
|
+
)
|
|
2840
2905
|
}
|
package/src/table.tsx
CHANGED
|
@@ -132,6 +132,7 @@ export type TableField <T> = {
|
|
|
132
132
|
filterIsActive?: boolean,
|
|
133
133
|
filterComponent?: React.ReactNode,
|
|
134
134
|
allowWidthAdjustment?: boolean,
|
|
135
|
+
columnResizeZIndex?: number,
|
|
135
136
|
}
|
|
136
137
|
export interface TableHeaderProps<T extends Item> extends Styled, HorizontalPadded, SelectionPropsOptional {
|
|
137
138
|
fields: TableField<T>[],
|
|
@@ -147,6 +148,7 @@ export interface TableHeaderProps<T extends Item> extends Styled, HorizontalPadd
|
|
|
147
148
|
setLocalFilters: React.Dispatch<React.SetStateAction<LocalFilter[]>>,
|
|
148
149
|
filterSuggestions: Record<string, string[]>,
|
|
149
150
|
minColumnWidth?: number,
|
|
151
|
+
columnResizeZIndex?: number,
|
|
150
152
|
}
|
|
151
153
|
export const TableHeader = <T extends Item>({
|
|
152
154
|
fields,
|
|
@@ -167,6 +169,7 @@ export const TableHeader = <T extends Item>({
|
|
|
167
169
|
setLocalFilters,
|
|
168
170
|
filterSuggestions,
|
|
169
171
|
minColumnWidth=75,
|
|
172
|
+
columnResizeZIndex=1000,
|
|
170
173
|
} : TableHeaderProps<T>) => {
|
|
171
174
|
const [openFilter, setOpenFilter] = useState(-1)
|
|
172
175
|
const [startX, setStartX] = useState(0)
|
|
@@ -341,7 +344,7 @@ export const TableHeader = <T extends Item>({
|
|
|
341
344
|
height: '30px',
|
|
342
345
|
backgroundColor: '#22222266',
|
|
343
346
|
cursor: 'col-resize',
|
|
344
|
-
zIndex:
|
|
347
|
+
zIndex: columnResizeZIndex,
|
|
345
348
|
position: 'relative', right: '6px',
|
|
346
349
|
}} />
|
|
347
350
|
</Draggable>
|
|
@@ -725,6 +728,7 @@ export interface TableProps<T extends Item> extends WithTitle, WithHeader<T>, Wi
|
|
|
725
728
|
loadMoreOptions?: LoadMoreOptions<T>,
|
|
726
729
|
refreshFilterSuggestionsKey?: number,
|
|
727
730
|
minColumnWidth?: number,
|
|
731
|
+
columnResizeZIndex?: number,
|
|
728
732
|
}
|
|
729
733
|
export const Table = <T extends Item>({
|
|
730
734
|
items,
|
|
@@ -775,10 +779,11 @@ export const Table = <T extends Item>({
|
|
|
775
779
|
onReorder,
|
|
776
780
|
virtualization,
|
|
777
781
|
onExport,
|
|
778
|
-
|
|
782
|
+
|
|
779
783
|
sort,
|
|
780
784
|
refreshFilterSuggestionsKey,
|
|
781
785
|
minColumnWidth,
|
|
786
|
+
columnResizeZIndex,
|
|
782
787
|
}: TableProps<T> & Styled) => {
|
|
783
788
|
const sortingStorageKey = (memoryId ?? '') + 'sorting'
|
|
784
789
|
const cachedSortString = read_local_storage(sortingStorageKey)
|
|
@@ -1045,6 +1050,7 @@ export const Table = <T extends Item>({
|
|
|
1045
1050
|
: undefined
|
|
1046
1051
|
}
|
|
1047
1052
|
minColumnWidth={minColumnWidth}
|
|
1053
|
+
columnResizeZIndex={columnResizeZIndex}
|
|
1048
1054
|
/>
|
|
1049
1055
|
)}
|
|
1050
1056
|
|