diff --git a/src/components/account_header_icon/index.tsx b/src/components/account_header_icon/index.tsx index a92bd0c7a4..6a2538eace 100644 --- a/src/components/account_header_icon/index.tsx +++ b/src/components/account_header_icon/index.tsx @@ -1,6 +1,7 @@ import { Avatar, Box } from '@mui/material'; import { IconHeaderAccount, IconNoConnection } from '@icons/index'; import { useAccountHeaderIcon } from './useAccountHeaderIcon'; +import { isDemo } from '@constants/index'; /** * Functional component for rendering the user's avatar or a default icon @@ -22,7 +23,7 @@ const AccountHeaderIcon = () => { sx={{ width: 32, height: 32, - border: isOffline ? '2px solid var(--red-main)' : 'none', + border: !isDemo && isOffline ? '2px solid var(--red-main)' : 'none', boxSizing: 'border-box', }} /> @@ -31,7 +32,8 @@ const AccountHeaderIcon = () => { <> (props: AutocompletePropsType) => { decorator ? { '.MuiOutlinedInput-root': { + borderRadius: 'var(--radius-l)', '& fieldset': { border: '1px solid var(--orange-dark)', }, diff --git a/src/features/meetings/person_selector/index.tsx b/src/features/meetings/person_selector/index.tsx index 2fcca07ae5..a0138ad051 100644 --- a/src/features/meetings/person_selector/index.tsx +++ b/src/features/meetings/person_selector/index.tsx @@ -284,7 +284,7 @@ const PersonSelector = (props: PersonSelectorType) => { )} - {props.helperNode} + {visitingSpeaker && typeof value === 'string' && props.helperNode} ); }; diff --git a/src/features/meetings/person_selector/index.types.ts b/src/features/meetings/person_selector/index.types.ts index fc759bab91..bc09713f4b 100644 --- a/src/features/meetings/person_selector/index.types.ts +++ b/src/features/meetings/person_selector/index.types.ts @@ -12,6 +12,8 @@ export type PersonSelectorType = { talk?: number; helperNode?: ReactNode; circuitOverseer?: boolean; + jwStreamRecording?: boolean; + freeSoloForce?: boolean; }; export type GenderType = 'male' | 'female'; diff --git a/src/features/meetings/person_selector/usePersonSelector.tsx b/src/features/meetings/person_selector/usePersonSelector.tsx index a5f0fad50f..4fbe0f1268 100644 --- a/src/features/meetings/person_selector/usePersonSelector.tsx +++ b/src/features/meetings/person_selector/usePersonSelector.tsx @@ -54,6 +54,8 @@ const usePersonSelector = ({ visitingSpeaker, talk, circuitOverseer, + jwStreamRecording, + freeSoloForce, }: PersonSelectorType) => { const timerSource = useRef(); @@ -89,7 +91,8 @@ const usePersonSelector = ({ const labelParticipants = t('tr_participants'); const labelVisitingSpeakers = t('tr_visitingSpeakers'); - const freeSolo = visitingSpeaker || circuitOverseer; + const freeSolo = + visitingSpeaker || circuitOverseer || jwStreamRecording || freeSoloForce; const placeHolderIcon = STUDENT_ASSIGNMENT.includes(type) ? ( @@ -283,33 +286,21 @@ const usePersonSelector = ({ const handleCloseHistory = () => setIsHistoryOpen(false); + // input reset useEffect(() => { - if (visitingSpeaker) { - setOptionHeader(labelVisitingSpeakers); - } - - if (!visitingSpeaker) { - if (BROTHER_ASSIGNMENT.includes(type)) { - setOptionHeader(labelBrothers); - } else { - setOptionHeader(labelParticipants); - } + if (circuitOverseer || jwStreamRecording) { + setOptions([]); + setFreeSoloText(''); } - }, [ - type, - labelBrothers, - labelParticipants, - visitingSpeaker, - labelVisitingSpeakers, - ]); + }, [circuitOverseer, jwStreamRecording]); - // options setter for circuit overseer useEffect(() => { - if (circuitOverseer) { - setOptions([]); - setFreeSoloText(''); + if (BROTHER_ASSIGNMENT.includes(type)) { + setOptionHeader(labelBrothers); + } else { + setOptionHeader(labelParticipants); } - }, [circuitOverseer]); + }, [type, labelBrothers, labelParticipants, labelVisitingSpeakers]); // options setter for visiting speakers useEffect(() => { @@ -358,7 +349,7 @@ const usePersonSelector = ({ // options setter for others useEffect(() => { - if (!isAssistant && !visitingSpeaker) { + if (!isAssistant && !visitingSpeaker && !jwStreamRecording) { setOptions([]); const isMale = gender === 'male'; @@ -481,6 +472,7 @@ const usePersonSelector = ({ handleFormatDate, handleSortOptions, visitingSpeaker, + jwStreamRecording, ]); // set selected option @@ -565,6 +557,7 @@ const usePersonSelector = ({ if (assigned?.solo) { setGender('male'); setValue(assigned.value); + setFreeSoloText(assigned.value); if (circuitOverseer && assigned?.value.length === 0) { setValue(coName); @@ -597,22 +590,25 @@ const usePersonSelector = ({ let assigned: AssignmentCongregation; if (assignment === 'WM_ClosingPrayer') { - const closingPrayerPath = ASSIGNMENT_PATH[assignment]; - const scheduleData = schedulesGetData( - schedule, - closingPrayerPath - ) as AssignmentCongregation[]; - const closingPrayer = - scheduleData.find((record) => record.type === dataView)?.value || ''; - - if (closingPrayer.length === 0) { - const speakerPath = ASSIGNMENT_PATH['WM_Speaker_Part1']; + if (!jwStreamRecording) { + const closingPrayerPath = ASSIGNMENT_PATH[assignment]; const scheduleData = schedulesGetData( schedule, - speakerPath + closingPrayerPath ) as AssignmentCongregation[]; - - assigned = scheduleData.find((record) => record.type === dataView); + const closingPrayer = + scheduleData.find((record) => record.type === dataView)?.value || + ''; + + if (closingPrayer.length === 0) { + const speakerPath = ASSIGNMENT_PATH['WM_Speaker_Part1']; + const scheduleData = schedulesGetData( + schedule, + speakerPath + ) as AssignmentCongregation[]; + + assigned = scheduleData.find((record) => record.type === dataView); + } } } @@ -637,7 +633,7 @@ const usePersonSelector = ({ } if (assigned) { - if (!assigned?.solo) { + if (!assigned.solo) { const person = options.find( (record) => record.person_uid === assigned?.value ); @@ -651,11 +647,13 @@ const usePersonSelector = ({ } setValue(person || null); + setFreeSoloText(''); } - if (assigned?.solo) { + if (assigned.solo) { setGender('male'); setValue(assigned.value); + setFreeSoloText(assigned.value); } } } @@ -667,6 +665,7 @@ const usePersonSelector = ({ options, WTStudyConductorDefault, personsAll, + jwStreamRecording, ]); // checking overlapping assignments diff --git a/src/features/meetings/weekend_editor/index.styles.tsx b/src/features/meetings/weekend_editor/index.styles.tsx index c62fadea3a..456bf97d91 100644 --- a/src/features/meetings/weekend_editor/index.styles.tsx +++ b/src/features/meetings/weekend_editor/index.styles.tsx @@ -14,7 +14,6 @@ export const DoubleFieldContainer = styled(Box, { shouldForwardProp: (prop) => styledRemoveProps(prop, ['laptopUp']), })<{ laptopUp: boolean }>(({ laptopUp }) => ({ display: 'flex', - alignItems: laptopUp ? 'center' : 'unset', gap: '16px', flexDirection: laptopUp ? 'row' : 'column', })); diff --git a/src/features/meetings/weekend_editor/index.tsx b/src/features/meetings/weekend_editor/index.tsx index 935be3daf9..21bbf364b2 100644 --- a/src/features/meetings/weekend_editor/index.tsx +++ b/src/features/meetings/weekend_editor/index.tsx @@ -180,57 +180,54 @@ const WeekendEditor = () => { - {talkType !== 'jwStreamRecording' && ( - <> - - ) : null - } - /> - - {showSpeaker2 && ( - - )} - + ) : null + } + /> + + {showSpeaker2 && ( + )} @@ -343,6 +340,7 @@ const WeekendEditor = () => { label={t('tr_prayer')} type={AssignmentCode.WM_Prayer} assignment="WM_ClosingPrayer" + freeSoloForce={talkType === 'visitingSpeaker'} /> diff --git a/src/services/app/schedules.ts b/src/services/app/schedules.ts index c18206ee20..ec4ac5a992 100644 --- a/src/services/app/schedules.ts +++ b/src/services/app/schedules.ts @@ -14,6 +14,7 @@ import { userDataViewState, weekendMeetingOpeningPrayerAutoAssignState, weekendMeetingWeekdayState, + weekendMeetingWTStudyConductorDefaultState, } from '@states/settings'; import { sourcesState } from '@states/sources'; import { assignmentsHistoryState, schedulesState } from '@states/schedules'; @@ -398,6 +399,7 @@ export const schedulesWeekendInfo = async (week: string) => { schedule.weekend_meeting.week_type.find( (record) => record.type === dataView )?.value || Week.NORMAL; + const hasNoMeeting = weekType === Week.ASSEMBLY || weekType == Week.CONVENTION || @@ -411,7 +413,7 @@ export const schedulesWeekendInfo = async (week: string) => { let assignment = schedule.weekend_meeting.chairman.find( (record) => record.type === dataView ); - if (assignment && assignment.value.length > 0) { + if (assignment?.value.length > 0) { assigned = assigned + 1; } @@ -422,7 +424,7 @@ export const schedulesWeekendInfo = async (week: string) => { assignment = schedule.weekend_meeting.opening_prayer.find( (record) => record.type === dataView ); - if (assignment && assignment.value.length > 0) { + if (assignment?.value.length > 0) { assigned = assigned + 1; } } @@ -435,7 +437,8 @@ export const schedulesWeekendInfo = async (week: string) => { assignment = schedule.weekend_meeting.speaker.part_1.find( (record) => record.type === dataView ); - if (assignment && assignment.value.length > 0) { + + if (assignment?.value.length > 0) { assigned = assigned + 1; } @@ -443,19 +446,29 @@ export const schedulesWeekendInfo = async (week: string) => { assignment = schedule.weekend_meeting.speaker.part_2.find( (record) => record.type === dataView ); - if (assignment && assignment.value.length > 0) { + + if (assignment?.value.length > 0) { total = total + 1; assigned = assigned + 1; } } // wt study conductor + total = total + 1; assignment = schedule.weekend_meeting.wt_study.conductor.find( (record) => record.type === dataView ); - if (assignment && assignment.value.length > 0) { - total = total + 1; + + if (assignment?.value.length > 0) { assigned = assigned + 1; + } else { + const defaultConductor: string = await promiseGetRecoil( + weekendMeetingWTStudyConductorDefaultState + ); + + if (defaultConductor.length > 0) { + assigned = assigned + 1; + } } // wt study reader @@ -471,19 +484,21 @@ export const schedulesWeekendInfo = async (week: string) => { } // closing prayer + total = total + 1; + assignment = schedule.weekend_meeting.closing_prayer.find( (record) => record.type === dataView ); - if (talkType === 'jwStreamRecording') { - total = total + 1; - } - - if (assignment && assignment.value.length > 0) { + if (assignment?.value.length > 0) { assigned = assigned + 1; + } else { + const speaker = schedule.weekend_meeting.speaker.part_1.find( + (record) => record.type === dataView + ); - if (talkType !== 'jwStreamRecording') { - total = total + 1; + if (speaker?.value.length > 0) { + assigned = assigned + 1; } } } diff --git a/src/services/dexie/visiting_speakers.ts b/src/services/dexie/visiting_speakers.ts index 81ec2c2684..181b8f317d 100644 --- a/src/services/dexie/visiting_speakers.ts +++ b/src/services/dexie/visiting_speakers.ts @@ -201,101 +201,210 @@ export const dbVisitingSpeakersDummy = async () => { record.cong_data.cong_number.value !== settings.cong_settings.cong_number ); - for (const cong of incomingCongs) { - const speaker1 = structuredClone(vistingSpeakerSchema); - speaker1.person_uid = crypto.randomUUID(); - speaker1._deleted = { value: false, updatedAt: new Date().toISOString() }; - speaker1.speaker_data = { - cong_id: cong.id, - elder: { value: true, updatedAt: new Date().toISOString() }, - ministerial_servant: { - value: false, - updatedAt: new Date().toISOString(), - }, - person_firstname: { - value: 'Ribeiro', - updatedAt: new Date().toISOString(), - }, - person_lastname: { - value: 'Gonzaga', - updatedAt: new Date().toISOString(), - }, - person_display_name: { - value: generateDisplayName('Gonzaga', 'Ribeiro'), - updatedAt: new Date().toISOString(), - }, - person_email: { - value: 'ribeiro-gonzaga@fakemail.com', + const speaker1Cong1 = structuredClone(vistingSpeakerSchema); + speaker1Cong1.person_uid = crypto.randomUUID(); + speaker1Cong1._deleted = { + value: false, + updatedAt: new Date().toISOString(), + }; + speaker1Cong1.speaker_data = { + cong_id: incomingCongs.at(0).id, + elder: { value: true, updatedAt: new Date().toISOString() }, + ministerial_servant: { + value: false, + updatedAt: new Date().toISOString(), + }, + person_firstname: { + value: 'Ribeiro', + updatedAt: new Date().toISOString(), + }, + person_lastname: { + value: 'Gonzaga', + updatedAt: new Date().toISOString(), + }, + person_display_name: { + value: generateDisplayName('Gonzaga', 'Ribeiro'), + updatedAt: new Date().toISOString(), + }, + person_email: { + value: 'ribeiro-gonzaga@fakemail.com', + updatedAt: new Date().toISOString(), + }, + person_notes: { value: '', updatedAt: new Date().toISOString() }, + person_phone: { + value: '+61 929-572-140', + updatedAt: new Date().toISOString(), + }, + talks: [ + { + _deleted: false, + talk_number: 40, + talk_songs: [8, 16], updatedAt: new Date().toISOString(), }, - person_notes: { value: '', updatedAt: new Date().toISOString() }, - person_phone: { - value: '+61 929-572-140', + { + _deleted: false, + talk_number: 77, + talk_songs: [20, 34, 99], updatedAt: new Date().toISOString(), }, - talks: [ - { - _deleted: false, - talk_number: 40, - talk_songs: [8, 16], - updatedAt: new Date().toISOString(), - }, - { - _deleted: false, - talk_number: 77, - talk_songs: [20, 34, 99], - updatedAt: new Date().toISOString(), - }, - ], - }; - - const speaker2 = structuredClone(vistingSpeakerSchema); - speaker2.person_uid = crypto.randomUUID(); - speaker2._deleted = { value: false, updatedAt: new Date().toISOString() }; - speaker2.speaker_data = { - cong_id: cong.id, - elder: { value: false, updatedAt: new Date().toISOString() }, - ministerial_servant: { value: true, updatedAt: new Date().toISOString() }, - person_firstname: { - value: 'Konsta', + ], + }; + + const speaker2Cong1 = structuredClone(vistingSpeakerSchema); + speaker2Cong1.person_uid = crypto.randomUUID(); + speaker2Cong1._deleted = { + value: false, + updatedAt: new Date().toISOString(), + }; + speaker2Cong1.speaker_data = { + cong_id: incomingCongs.at(0).id, + elder: { value: false, updatedAt: new Date().toISOString() }, + ministerial_servant: { value: true, updatedAt: new Date().toISOString() }, + person_firstname: { + value: 'Konsta', + updatedAt: new Date().toISOString(), + }, + person_lastname: { + value: 'Manninen', + updatedAt: new Date().toISOString(), + }, + person_display_name: { + value: generateDisplayName('Manninen', 'Konsta'), + updatedAt: new Date().toISOString(), + }, + person_email: { + value: 'konsta-manninen@fakemail.com', + updatedAt: new Date().toISOString(), + }, + person_notes: { + value: 'Note about speaker', + updatedAt: new Date().toISOString(), + }, + person_phone: { + value: '+92 378-326-3439', + updatedAt: new Date().toISOString(), + }, + talks: [ + { + _deleted: false, + talk_number: 52, + talk_songs: [123, 151], updatedAt: new Date().toISOString(), }, - person_lastname: { - value: 'Manninen', + { + _deleted: false, + talk_number: 85, + talk_songs: [11, 38], updatedAt: new Date().toISOString(), }, - person_display_name: { - value: generateDisplayName('Manninen', 'Konsta'), + ], + }; + + const speaker1Cong2 = structuredClone(vistingSpeakerSchema); + speaker1Cong2.person_uid = crypto.randomUUID(); + speaker1Cong2._deleted = { + value: false, + updatedAt: new Date().toISOString(), + }; + speaker1Cong2.speaker_data = { + cong_id: incomingCongs.at(1).id, + elder: { value: true, updatedAt: new Date().toISOString() }, + ministerial_servant: { + value: false, + updatedAt: new Date().toISOString(), + }, + person_firstname: { + value: 'Gary', + updatedAt: new Date().toISOString(), + }, + person_lastname: { + value: 'Simpson', + updatedAt: new Date().toISOString(), + }, + person_display_name: { + value: generateDisplayName('Simpson', 'Gary'), + updatedAt: new Date().toISOString(), + }, + person_email: { + value: 'gary-simpson@fakemail.com', + updatedAt: new Date().toISOString(), + }, + person_notes: { value: '', updatedAt: new Date().toISOString() }, + person_phone: { + value: '+61 929-572-140', + updatedAt: new Date().toISOString(), + }, + talks: [ + { + _deleted: false, + talk_number: 40, + talk_songs: [8, 16], updatedAt: new Date().toISOString(), }, - person_email: { - value: 'konsta-manninen@fakemail.com', + { + _deleted: false, + talk_number: 77, + talk_songs: [20, 34, 99], updatedAt: new Date().toISOString(), }, - person_notes: { - value: 'Note about speaker', + ], + }; + + const speaker2Cong2 = structuredClone(vistingSpeakerSchema); + speaker2Cong2.person_uid = crypto.randomUUID(); + speaker2Cong2._deleted = { + value: false, + updatedAt: new Date().toISOString(), + }; + speaker2Cong2.speaker_data = { + cong_id: incomingCongs.at(1).id, + elder: { value: false, updatedAt: new Date().toISOString() }, + ministerial_servant: { value: true, updatedAt: new Date().toISOString() }, + person_firstname: { + value: 'Sylas', + updatedAt: new Date().toISOString(), + }, + person_lastname: { + value: 'Holmes', + updatedAt: new Date().toISOString(), + }, + person_display_name: { + value: generateDisplayName('Holmes', 'Sylas'), + updatedAt: new Date().toISOString(), + }, + person_email: { + value: 'sylas-holmes@fakemail.com', + updatedAt: new Date().toISOString(), + }, + person_notes: { + value: 'Note about speaker', + updatedAt: new Date().toISOString(), + }, + person_phone: { + value: '+92 378-326-3439', + updatedAt: new Date().toISOString(), + }, + talks: [ + { + _deleted: false, + talk_number: 52, + talk_songs: [123, 151], updatedAt: new Date().toISOString(), }, - person_phone: { - value: '+92 378-326-3439', + { + _deleted: false, + talk_number: 85, + talk_songs: [11, 38], updatedAt: new Date().toISOString(), }, - talks: [ - { - _deleted: false, - talk_number: 52, - talk_songs: [123, 151], - updatedAt: new Date().toISOString(), - }, - { - _deleted: false, - talk_number: 85, - talk_songs: [11, 38], - updatedAt: new Date().toISOString(), - }, - ], - }; - - await appDb.visiting_speakers.bulkAdd([speaker1, speaker2]); - } + ], + }; + + await appDb.visiting_speakers.bulkAdd([ + speaker1Cong1, + speaker2Cong1, + speaker1Cong2, + speaker2Cong2, + ]); }; diff --git a/src/states/settings.ts b/src/states/settings.ts index 82c4b007a4..1c48c97145 100644 --- a/src/states/settings.ts +++ b/src/states/settings.ts @@ -373,9 +373,11 @@ export const weekendMeetingWTStudyConductorDefaultState = selector({ const settings = get(settingsState); const dataView = get(userDataViewState); - return settings.cong_settings.weekend_meeting.find( - (record) => record.type === dataView - ).w_study_conductor_default.value; + return ( + settings.cong_settings.weekend_meeting.find( + (record) => record.type === dataView + )?.w_study_conductor_default.value || '' + ); }, });