Skip to content

Commit

Permalink
use dateRange function in my competitions and competition overview
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnIckler committed Jan 10, 2025
1 parent 6bfbd85 commit 4c06b25
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v0/competitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def competition_index

competitions = competitions_scope.search(params[:q], params: params)

serial_methods = ["short_display_name", "city", "country_iso2", "event_ids", "date_range", "latitude_degrees", "longitude_degrees"]
serial_methods = ["short_display_name", "city", "country_iso2", "event_ids", "latitude_degrees", "longitude_degrees"]
serial_includes = {}

serial_includes["delegates"] = { only: ["id", "name"], methods: [], include: ["avatar"] } if admin_mode
Expand Down
4 changes: 2 additions & 2 deletions app/views/competitions/my_competitions.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<% provide(:title, t('.title')) %>

<% options = {
only: %w[id name website start_date end_date, registration_open],
methods: %w[url city country_iso2 registration_status results_posted? visible? confirmed? cancelled? report_posted? date_range short_display_name],
only: %w[id name website start_date end_date registration_open],
methods: %w[url city country_iso2 registration_status results_posted? visible? confirmed? cancelled? report_posted? short_display_name],
include: %w[championships],
} %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '../../lib/utils/competition-table';
import { countries } from '../../lib/wca-data.js.erb';
import { adminCompetitionUrl, competitionUrl } from '../../lib/requests/routes.js.erb';
import { dateRange } from '../../lib/utils/dates';

function ListViewSection({
competitions,
Expand Down Expand Up @@ -154,7 +155,7 @@ export function CompetitionsTable({
/>
</Table.Cell>
<Table.Cell textAlign="right" width={2}>
{comp.date_range}
{dateRange(comp.start_date, comp.end_date)}
</Table.Cell>
<Table.Cell width={5}>
<Flag name={comp.country_iso2?.toLowerCase()} />
Expand Down Expand Up @@ -210,7 +211,7 @@ export function CompetitionsTabletTable({
/>
</Table.Cell>
<Table.Cell textAlign="right" width={3}>
{comp.date_range}
{dateRange(comp.start_date, comp.end_date)}
</Table.Cell>
<Table.Cell width={6}>
<Flag name={comp.country_iso2?.toLowerCase()} />
Expand Down Expand Up @@ -257,7 +258,7 @@ export function CompetitionsMobileTable({
isSortedByAnnouncement={isSortedByAnnouncement}
regStatusLoading={regStatusLoading}
/>
{comp.date_range}
{dateRange(comp.start_date, comp.end_date)}
</Label>
<Flag name={comp.country_iso2?.toLowerCase()} />
<a href={competitionUrl(comp.id)}>{comp.short_display_name}</a>
Expand Down Expand Up @@ -360,7 +361,7 @@ function AdminCompetitionsTable({
</List>
</Table.Cell>
<Table.Cell textAlign="center" width={3}>
{comp.date_range}
{dateRange(comp.start_date, comp.end_date)}
</Table.Cell>
<Table.Cell
textAlign="center"
Expand Down
3 changes: 2 additions & 1 deletion app/webpacker/components/CompetitionsOverview/MapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ResizeMapIFrame from '../../lib/utils/leaflet-iframe';
import 'leaflet/dist/leaflet.css';
import { isProbablyOver } from '../../lib/utils/competition-table';
import { competitionUrl } from '../../lib/requests/routes.js.erb';
import { dateRange } from '../../lib/utils/dates';

// Limit number of markers on map, especially for "All Past Competitions"
const MAP_DISPLAY_LIMIT = 500;
Expand Down Expand Up @@ -53,7 +54,7 @@ function MapView({
<Popup>
<a href={competitionUrl(comp.id)}>{comp.name}</a>
<br />
{`${comp.date_range} - ${comp.city}`}
{`${dateRange(comp.start_date, comp.end_date)} - ${comp.city}`}
</Popup>
</Marker>
))}
Expand Down
4 changes: 3 additions & 1 deletion app/webpacker/components/MyCompetitions/TableCells.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import I18n from '../../lib/i18n';
import { competitionReportUrl, competitionReportEditUrl } from '../../lib/requests/routes.js.erb';
import { countries } from '../../lib/wca-data.js.erb';
import { dateRange } from '../../lib/utils/dates';

export function NameTableCell({ competition }) {
return (
Expand All @@ -26,9 +27,10 @@ export function LocationTableCell({ competition }) {
}

export function DateTableCell({ competition }) {
console.log(competition);
return (
<Table.Cell>
{competition.date_range}
{dateRange(competition.start_date, competition.end_date, { separator: '-' })}
</Table.Cell>
);
}
Expand Down

0 comments on commit 4c06b25

Please sign in to comment.