Skip to content

Commit

Permalink
fix(schedules): support custom middle song for midweek meeting
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao authored Feb 16, 2024
1 parent be22ed5 commit 67aad23
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
16 changes: 14 additions & 2 deletions src/current/pages/SourceWeekDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const SourceWeekDetails = () => {
obj.mwb_ayf_part4_type = Ass4Type === '' ? undefined : +Ass4Type;
obj.mwb_ayf_part4_time = Ass4Time === '' ? undefined : +Ass4Time;
obj.mwb_ayf_part4 = Ass4Src;
obj.mwb_song_middle = +SongMiddle;
obj.mwb_song_middle = isNaN(SongMiddle) ? SongMiddle : +SongMiddle;
obj.mwb_lc_cbs = CBSSrc;
obj.mwb_song_conclude = isNaN(SongConclude) ? SongConclude : +SongConclude;
obj.mwb_song_conclude_override = isNaN(SongConcludeOverride) ? SongConcludeOverride : +SongConcludeOverride;
Expand Down Expand Up @@ -508,7 +508,19 @@ const SourceWeekDetails = () => {
<Typography variant="h6">{t('livingPart')}</Typography>
</Box>
<Box sx={{ marginTop: '20px' }}>
<SongsList song={SongMiddle} setSong={setSongMiddle} readOnly={!lmmoRole} />
{!isNaN(SongMiddle) && <SongsList song={SongMiddle} setSong={setSongMiddle} readOnly={!lmmoRole} />}
{isNaN(SongMiddle) && (
<TextField
id="outlined-song-middle"
label={t('song')}
variant="outlined"
size="small"
InputProps={{ readOnly: !lmmoRole }}
value={SongMiddle}
sx={{ width: '100%' }}
onChange={(value) => setSongMiddle(value)}
/>
)}
</Box>
<Box sx={{ margin: '20px 0' }}>
<Box sx={sharedStyles.ayfStuPart}>
Expand Down
14 changes: 10 additions & 4 deletions src/current/views/S140.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,15 @@ const S140 = ({ data, currentSchedule }) => {
return src;
};

const getMiddleSong = (weekItem) => {
let src = t('song', { lng: source_lang });

if (isNaN(weekItem.sourceData.mwb_song_middle)) return weekItem.sourceData.mwb_song_middle;

src += ` ${weekItem.sourceData.mwb_song_middle}`;
return src;
};

const getConcludingSong = (weekItem) => {
let src = t('song', { lng: source_lang });

Expand Down Expand Up @@ -585,10 +594,7 @@ const S140 = ({ data, currentSchedule }) => {
{/* Middle Song */}
<View style={styles.rowBase}>
<S140Time time={weekItem.sourceData.middleSong} />
<S140SourceSimple
source={`${t('song', { lng: source_lang })} ${weekItem.sourceData.mwb_song_middle}`}
bulletColor="#942926"
/>
<S140SourceSimple source={getMiddleSong(weekItem)} bulletColor="#942926" />
<S140PartMiniLabel part="" />
<S140Person person="" />
</View>
Expand Down

0 comments on commit 67aad23

Please sign in to comment.