diff --git a/src/app/features/meetings/constants/index.ts b/src/app/features/meetings/constants/index.ts index 667e4e510..8042264ba 100644 --- a/src/app/features/meetings/constants/index.ts +++ b/src/app/features/meetings/constants/index.ts @@ -1,2 +1,3 @@ export * from './meeting-submissions-table.constants'; +export * from './meetings-fields.constants'; export * from './meetings-table.constants'; diff --git a/src/app/features/meetings/constants/meetings-fields.constants.ts b/src/app/features/meetings/constants/meetings-fields.constants.ts new file mode 100644 index 000000000..549d3ea05 --- /dev/null +++ b/src/app/features/meetings/constants/meetings-fields.constants.ts @@ -0,0 +1,14 @@ +export const meetingSubmissionSortFieldMap: Record = { + title: 'title', + authorName: 'author_name', + meetingCategory: 'meeting_category', + dateCreated: 'date_created', + downloadCount: 'download_count', +}; + +export const meetingSortFieldMap: Record = { + name: 'name', + submissionsCount: 'submissions_count', + location: 'location', + startDate: 'start_date', +}; diff --git a/src/app/features/meetings/pages/meeting-details/meeting-details.component.ts b/src/app/features/meetings/pages/meeting-details/meeting-details.component.ts index b68aa8072..29465b0d9 100644 --- a/src/app/features/meetings/pages/meeting-details/meeting-details.component.ts +++ b/src/app/features/meetings/pages/meeting-details/meeting-details.component.ts @@ -29,8 +29,7 @@ import { parseQueryFilterParams } from '@core/helpers/http.helper'; import { MEETING_SUBMISSIONS_TABLE_PARAMS } from '@osf/features/meetings/constants'; import { MeetingSubmission } from '@osf/features/meetings/models'; import { GetMeetingById, GetMeetingSubmissions, MeetingsSelectors } from '@osf/features/meetings/store'; -import { SearchInputComponent } from '@shared/components/search-input/search-input.component'; -import { SubHeaderComponent } from '@shared/components/sub-header/sub-header.component'; +import { SearchInputComponent, SubHeaderComponent } from '@shared/components'; import { SortOrder } from '@shared/enums'; import { QueryParams, TableParameters } from '@shared/models'; import { SearchFilters } from '@shared/models/filters'; @@ -54,6 +53,7 @@ import { SearchFilters } from '@shared/models/filters'; }) export class MeetingDetailsComponent { @HostBinding('class') classes = 'flex-1 flex flex-column w-full h-full'; + private readonly datePipe = inject(DatePipe); private readonly store = inject(Store); private readonly route = inject(ActivatedRoute); diff --git a/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.ts b/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.ts index 0a111944c..998d8d6dd 100644 --- a/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.ts +++ b/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.ts @@ -29,8 +29,7 @@ import { MEETINGS_TABLE_PARAMS } from '@osf/features/meetings/constants'; import { Meeting } from '@osf/features/meetings/models'; import { GetAllMeetings, MeetingsSelectors } from '@osf/features/meetings/store'; import { IS_XSMALL } from '@osf/shared/utils'; -import { SearchInputComponent } from '@shared/components/search-input/search-input.component'; -import { SubHeaderComponent } from '@shared/components/sub-header/sub-header.component'; +import { SearchInputComponent, SubHeaderComponent } from '@shared/components'; import { SortOrder } from '@shared/enums'; import { QueryParams, TableParameters } from '@shared/models'; import { SearchFilters } from '@shared/models/filters'; diff --git a/src/app/features/meetings/services/meetings.service.ts b/src/app/features/meetings/services/meetings.service.ts index 5b1068f0f..f6c1cf640 100644 --- a/src/app/features/meetings/services/meetings.service.ts +++ b/src/app/features/meetings/services/meetings.service.ts @@ -14,38 +14,29 @@ import { import { searchPreferencesToJsonApiQueryParams } from '@osf/shared/utils'; import { SearchFilters } from '@shared/models/filters'; +import { meetingSortFieldMap, meetingSubmissionSortFieldMap } from '../constants'; + import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root', }) export class MeetingsService { - jsonApiService = inject(JsonApiService); - baseUrl = `${environment.apiDomainUrl}/_/meetings/`; - - #meetingSubmissionSortFieldMap: Record = { - title: 'title', - authorName: 'author_name', - meetingCategory: 'meeting_category', - dateCreated: 'date_created', - downloadCount: 'download_count', - }; - #meetingSortFieldMap: Record = { - name: 'name', - submissionsCount: 'submissions_count', - location: 'location', - startDate: 'start_date', - }; + private readonly jsonApiService = inject(JsonApiService); + private readonly baseUrl = `${environment.apiDomainUrl}/_/meetings/`; getAllMeetings(pageNumber: number, pageSize: number, filters: SearchFilters): Observable { - const params: Record = {}; - searchPreferencesToJsonApiQueryParams(params, pageNumber, pageSize, filters, this.#meetingSortFieldMap); - - return this.jsonApiService.get>(this.baseUrl, params).pipe( - map((response) => { - return MeetingsMapper.fromMeetingsGetResponse(response); - }) + const params: Record = searchPreferencesToJsonApiQueryParams( + {}, + pageNumber, + pageSize, + filters, + meetingSortFieldMap ); + + return this.jsonApiService + .get>(this.baseUrl, params) + .pipe(map((response) => MeetingsMapper.fromMeetingsGetResponse(response))); } getMeetingSubmissions( @@ -54,25 +45,24 @@ export class MeetingsService { pageSize: number, filters: SearchFilters ): Observable { - const params: Record = {}; - searchPreferencesToJsonApiQueryParams(params, pageNumber, pageSize, filters, this.#meetingSubmissionSortFieldMap); + const params: Record = searchPreferencesToJsonApiQueryParams( + {}, + pageNumber, + pageSize, + filters, + meetingSubmissionSortFieldMap + ); return this.jsonApiService .get< JsonApiResponseWithPaging >(`${this.baseUrl}${meetingId}/submissions/`, params) - .pipe( - map((response) => { - return MeetingsMapper.fromMeetingSubmissionGetResponse(response); - }) - ); + .pipe(map((response) => MeetingsMapper.fromMeetingSubmissionGetResponse(response))); } getMeetingById(meetingId: string) { - return this.jsonApiService.get>(this.baseUrl + meetingId).pipe( - map((response) => { - return MeetingsMapper.fromMeetingGetResponse(response.data); - }) - ); + return this.jsonApiService + .get>(this.baseUrl + meetingId) + .pipe(map((response) => MeetingsMapper.fromMeetingGetResponse(response.data))); } } diff --git a/src/app/features/meetings/store/meetings.model.ts b/src/app/features/meetings/store/meetings.model.ts index 5254f09c0..0e8b6b92d 100644 --- a/src/app/features/meetings/store/meetings.model.ts +++ b/src/app/features/meetings/store/meetings.model.ts @@ -1,5 +1,5 @@ import { Meeting, MeetingSubmission } from '@osf/features/meetings/models'; -import { AsyncStateWithTotalCount } from '@shared/models/store/async-state-with-total-count.model'; +import { AsyncStateWithTotalCount } from '@shared/models/store'; export interface MeetingsStateModel { meetings: AsyncStateWithTotalCount; diff --git a/src/app/shared/models/store/index.ts b/src/app/shared/models/store/index.ts index e4655a6af..3b5469b1b 100644 --- a/src/app/shared/models/store/index.ts +++ b/src/app/shared/models/store/index.ts @@ -1 +1,2 @@ export type { AsyncStateModel } from './async-state.model'; +export type { AsyncStateWithTotalCount } from './async-state-with-total-count.model'; diff --git a/src/assets/styles/styles.scss b/src/assets/styles/styles.scss index afddfd4ff..800306d1f 100644 --- a/src/assets/styles/styles.scss +++ b/src/assets/styles/styles.scss @@ -42,4 +42,3 @@ @use "./overrides/breadcrumbs"; @use "./components/md-editor"; @use "./components/preprints"; -@use "./components/preprints";