11import { Activity , Assignment , Competition , Person } from '@wca/helpers' ;
22import { getWorldAssignmentsExtension } from '@/extensions/com.competitiongroups.worldsassignments' ;
3- import { isUnofficialEvent } from '@/extensions/com.delegatedashboard.unofficialEvents ' ;
3+ import i18n from '@/i18n ' ;
44import { getAllActivities , getRooms } from '@/lib/activities' ;
55import { isUnofficialParsedActivityCode , parseActivityCodeFlexible } from '@/lib/activityCodes' ;
6- import {
7- eventById ,
8- events ,
9- getEventShortName ,
10- isOfficialEventId ,
11- shortEventNameById ,
12- } from '@/lib/events' ;
6+ import { eventById , isOfficialEventId } from '@/lib/events' ;
137import { formatNumericDate , getNumericDateFormatter } from '@/lib/time' ;
148import { byDate } from '@/lib/utils' ;
159
@@ -23,6 +17,13 @@ export const getNormalAssignments = (wcif: Competition, person: Person) => {
2317 ...assignment ,
2418 activity : allActivities . find ( ( { id } ) => id === assignment . activityId ) ,
2519 } ) )
20+ . filter (
21+ ( assignment ) =>
22+ ! (
23+ assignment . activity ?. activityCode === 'other-multi' &&
24+ assignment . assignmentCode === 'competitor'
25+ ) ,
26+ )
2627 . sort ( ( a , b ) => byDate ( a . activity , b . activity ) )
2728 : [ ] ;
2829
@@ -57,13 +58,43 @@ const getExtraAssignments = (person: Person) => {
5758 ) ;
5859} ;
5960
61+ const getCubeSubmissionAssignments = ( wcif : Competition , person : Person ) => {
62+ const allActivities = getAllActivities ( wcif ) ;
63+
64+ if ( ! person . registration ?. eventIds . includes ( '333mbf' ) ) {
65+ return [ ] ;
66+ }
67+
68+ const cubeSubmissionAssignments = allActivities . filter (
69+ ( activity ) => activity . activityCode === 'other-multi' ,
70+ ) ;
71+
72+ return cubeSubmissionAssignments . map (
73+ (
74+ activity ,
75+ ) : Assignment & {
76+ type : 'extra' ;
77+ activity : Activity ;
78+ } => ( {
79+ type : 'extra' ,
80+ assignmentCode : i18n . t ( 'competition.personalSchedule.submitMultiCubes' ) ,
81+ activityId : activity . id ,
82+ stationNumber : null ,
83+ activity,
84+ } ) ,
85+ ) ;
86+ } ;
87+
6088export const getAllAssignments = ( wcif : Competition , person : Person ) => {
6189 const normalAssignments = getNormalAssignments ( wcif , person ) ;
6290 const extraAssignments = getExtraAssignments ( person ) ;
91+ const mbldCubeSubmissionAssignments = getCubeSubmissionAssignments ( wcif , person ) ;
6392
64- const allAssignments = [ ...normalAssignments , ...extraAssignments ] . sort ( ( a , b ) =>
65- byDate ( a . activity , b . activity ) ,
66- ) ;
93+ const allAssignments = [
94+ ...normalAssignments ,
95+ ...extraAssignments ,
96+ ...mbldCubeSubmissionAssignments ,
97+ ] . sort ( ( a , b ) => byDate ( a . activity , b . activity ) ) ;
6798
6899 return allAssignments ;
69100} ;
@@ -173,6 +204,9 @@ export const formatBriefActivityName = (activity: Activity) => {
173204 const parsed = parseActivityCodeFlexible ( activity . activityCode ) ;
174205 const { eventId, roundNumber, attemptNumber } = parsed ;
175206
207+ if ( activity . activityCode === 'other-multi' ) {
208+ return i18n . t ( 'common.wca.events.other-mbld' ) ;
209+ }
176210 if ( isOfficialEventId ( eventId ) ) {
177211 const event = eventById ( eventId ) ;
178212 return _formatBriefActivityName ( event . shortName , roundNumber , attemptNumber ) ;
0 commit comments