Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schedules): update assignments stats for weekend meeting #2258

Merged
merged 5 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/account_header_icon/index.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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',
}}
/>
Expand All @@ -31,7 +32,8 @@ const AccountHeaderIcon = () => {
<>
<Box
sx={{
border: isOffline ? '3px solid var(--red-main)' : 'none',
border:
!isDemo && isOffline ? '3px solid var(--red-main)' : 'none',
borderRadius: '20px',
boxSizing: 'border-box',
height: '37px',
Expand Down
1 change: 1 addition & 0 deletions src/components/autocomplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const Autocomplete = <T,>(props: AutocompletePropsType<T>) => {
decorator
? {
'.MuiOutlinedInput-root': {
borderRadius: 'var(--radius-l)',
'& fieldset': {
border: '1px solid var(--orange-dark)',
},
Expand Down
2 changes: 1 addition & 1 deletion src/features/meetings/person_selector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ const PersonSelector = (props: PersonSelectorType) => {
</Typography>
)}

{props.helperNode}
{visitingSpeaker && typeof value === 'string' && props.helperNode}
</Box>
);
};
Expand Down
2 changes: 2 additions & 0 deletions src/features/meetings/person_selector/index.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export type PersonSelectorType = {
talk?: number;
helperNode?: ReactNode;
circuitOverseer?: boolean;
jwStreamRecording?: boolean;
freeSoloForce?: boolean;
};

export type GenderType = 'male' | 'female';
Expand Down
77 changes: 38 additions & 39 deletions src/features/meetings/person_selector/usePersonSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const usePersonSelector = ({
visitingSpeaker,
talk,
circuitOverseer,
jwStreamRecording,
freeSoloForce,
}: PersonSelectorType) => {
const timerSource = useRef<NodeJS.Timeout>();

Expand Down Expand Up @@ -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) ? (
<IconPersonPlaceholder />
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -358,7 +349,7 @@ const usePersonSelector = ({

// options setter for others
useEffect(() => {
if (!isAssistant && !visitingSpeaker) {
if (!isAssistant && !visitingSpeaker && !jwStreamRecording) {
setOptions([]);

const isMale = gender === 'male';
Expand Down Expand Up @@ -481,6 +472,7 @@ const usePersonSelector = ({
handleFormatDate,
handleSortOptions,
visitingSpeaker,
jwStreamRecording,
]);

// set selected option
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}

Expand All @@ -637,7 +633,7 @@ const usePersonSelector = ({
}

if (assigned) {
if (!assigned?.solo) {
if (!assigned.solo) {
const person = options.find(
(record) => record.person_uid === assigned?.value
);
Expand All @@ -651,11 +647,13 @@ const usePersonSelector = ({
}

setValue(person || null);
setFreeSoloText('');
}

if (assigned?.solo) {
if (assigned.solo) {
setGender('male');
setValue(assigned.value);
setFreeSoloText(assigned.value);
}
}
}
Expand All @@ -667,6 +665,7 @@ const usePersonSelector = ({
options,
WTStudyConductorDefault,
personsAll,
jwStreamRecording,
]);

// checking overlapping assignments
Expand Down
1 change: 0 additions & 1 deletion src/features/meetings/weekend_editor/index.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}));
Expand Down
98 changes: 48 additions & 50 deletions src/features/meetings/weekend_editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,57 +180,54 @@ const WeekendEditor = () => {
</PrimaryFieldContainer>

<SecondaryFieldContainer laptopUp={laptopUp}>
{talkType !== 'jwStreamRecording' && (
<>
<PersonSelector
week={selectedWeek}
label={
showSpeaker2
? t('tr_firstSpeaker')
: weekType === Week.CO_VISIT
? t('tr_circuitOverseer')
: t('tr_speaker')
}
type={
weekType === Week.CO_VISIT
? null
: AssignmentCode.WM_SpeakerSymposium
}
assignment={
weekType === Week.CO_VISIT
? 'WM_CircuitOverseer'
: 'WM_Speaker_Part1'
}
visitingSpeaker={
weekType === Week.NORMAL &&
talkType === 'visitingSpeaker'
}
circuitOverseer={weekType === Week.CO_VISIT}
talk={selectedTalk?.talk_number}
helperNode={
weekType === Week.NORMAL &&
talkType === 'visitingSpeaker' ? (
<Markup
content={t('tr_visitinSpeakerHelpText')}
className="label-small-regular"
color="var(--grey-350)"
anchorClassName="label-small-medium"
anchorClick={handleOpenVisitingSpeakers}
style={{ padding: '4px 16px 0 16px' }}
/>
) : null
}
/>

{showSpeaker2 && (
<PersonSelector
week={selectedWeek}
label={t('tr_secondSpeaker')}
type={AssignmentCode.WM_Speaker}
assignment="WM_Speaker_Part2"
<PersonSelector
week={selectedWeek}
label={
showSpeaker2
? t('tr_firstSpeaker')
: weekType === Week.CO_VISIT
? t('tr_circuitOverseer')
: t('tr_speaker')
}
type={
weekType === Week.CO_VISIT
? null
: AssignmentCode.WM_SpeakerSymposium
}
assignment={
weekType === Week.CO_VISIT
? 'WM_CircuitOverseer'
: 'WM_Speaker_Part1'
}
jwStreamRecording={talkType === 'jwStreamRecording'}
visitingSpeaker={
weekType === Week.NORMAL &&
talkType === 'visitingSpeaker'
}
circuitOverseer={weekType === Week.CO_VISIT}
talk={selectedTalk?.talk_number}
helperNode={
weekType === Week.NORMAL &&
talkType === 'visitingSpeaker' ? (
<Markup
content={t('tr_visitinSpeakerHelpText')}
className="label-small-regular"
color="var(--grey-350)"
anchorClassName="label-small-medium"
anchorClick={handleOpenVisitingSpeakers}
style={{ padding: '4px 16px 0 16px' }}
/>
)}
</>
) : null
}
/>

{showSpeaker2 && (
<PersonSelector
week={selectedWeek}
label={t('tr_secondSpeaker')}
type={AssignmentCode.WM_Speaker}
assignment="WM_Speaker_Part2"
/>
)}
</SecondaryFieldContainer>
</DoubleFieldContainer>
Expand Down Expand Up @@ -343,6 +340,7 @@ const WeekendEditor = () => {
label={t('tr_prayer')}
type={AssignmentCode.WM_Prayer}
assignment="WM_ClosingPrayer"
freeSoloForce={talkType === 'visitingSpeaker'}
/>
</SecondaryFieldContainer>
</DoubleFieldContainer>
Expand Down
Loading
Loading