Skip to content

Commit

Permalink
Merge pull request #33 from Shinsina/jankity-jank
Browse files Browse the repository at this point in the history
Shared subsessions page and underline links
  • Loading branch information
Shinsina authored Feb 24, 2024
2 parents 322f444 + c2b77d9 commit b7f11f0
Show file tree
Hide file tree
Showing 22 changed files with 531 additions and 283 deletions.
32 changes: 1 addition & 31 deletions src/lib/components/session-results/race.astro
Original file line number Diff line number Diff line change
@@ -1,41 +1,11 @@
---
import SessionResults from "$lib/components/subsession/session-results.astro";
import keysToDisplay from "$lib/utils/race-session-keys-to-display";
import type { Session } from "$lib/types";
interface Props {
session: Session;
}
const { session } = Astro.props;
const keysToDisplay = new Set([
"cust_id",
"display_name",
"finish_position",
"finish_position_in_class",
"laps_lead",
"laps_complete",
"interval",
"class_interval",
"average_lap",
"best_lap_num",
"best_lap_time",
"reason_out",
"champ_points",
"drop_race",
"club_points",
"starting_position",
"starting_position_in_class",
"car_class_short_name",
"club_shortname",
"division_name",
"old_license_level",
"old_cpi",
"oldi_rating",
"new_license_level",
"new_cpi",
"newi_rating",
"incidents",
"car_name",
"aggregate_champ_points",
]);
---

<SessionResults {session} {keysToDisplay} />
3 changes: 2 additions & 1 deletion src/lib/components/session-results/tables.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const practice: Session = sessions.find((session: Session) =>
const qualifying: Session = sessions.find((session: Session) =>
session.simsession_type_name.match(/QUALIFY/i)
);
const heat: Session = sessions.length === 4 ? { ...sessions[2], simsession_name: "HEAT" }: null;
const heat: Session =
sessions.length === 4 ? { ...sessions[2], simsession_name: "HEAT" } : null;
const race: Session =
sessions.length === 4
? { ...sessions[3], simsession_name: "RACE" }
Expand Down
14 changes: 7 additions & 7 deletions src/lib/components/subsession/licenseInfo.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ const allowedLicenses = [allowedLicenseOne, allowLicenseTwo];
Allowed Licenses:
{
allowedLicenses.map((license: License, index: number) => (
<p>
{license.group_name}{" "}
{!index
? `${license.min_license_level / license.license_group}.00`
: "and above"}
</p>
))
<p>
{license.group_name}{" "}
{!index
? `${license.min_license_level / license.license_group}.00`
: "and above"}
</p>
))
}
</div>
</div>
9 changes: 7 additions & 2 deletions src/lib/components/subsession/session-results.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ const { keysArray, handledResults } = handleResults({
keysToDisplay: keysToDisplay || new Set([]),
results: results || [],
});
const showHeader =
simsession_name &&
simsession_type_name &&
simsession_type &&
simsession_number;
---

<div class="grid grid-cols-1">
{showHeader ? <div class="grid grid-cols-1">
<table class="text-center col-span-1">
<tr class="bg-gray-500">
<th class="border-2">Name</th>
Expand All @@ -37,7 +42,7 @@ const { keysArray, handledResults } = handleResults({
<td class="border-2">{simsession_number}</td>
</tr>
</table>
</div>
</div> : <></>}
<div class="grid grid-cols-1 pt-6 overflow-x-scroll">
<table x-ref="Table" x-data={simsession_name} class="text-center col-span-1">
<tr x-ref="Headings"
Expand Down
4 changes: 2 additions & 2 deletions src/lib/layouts/default.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const seoDescription =
description || "An iRacing planner and statistics analyzer";
---

<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand All @@ -30,7 +30,7 @@ const seoDescription =
<div
class="block lg:text-3xl md:text-lg sm:text-md break-words text-center py-2"
>
<a href="/Stat-N-Track/" rel="prefetch">Home</a>
<a class="underline" href="/Stat-N-Track/" rel="prefetch">Home</a>
</div>
</div>
<slot />
Expand Down
6 changes: 5 additions & 1 deletion src/lib/layouts/standings.astro
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ const generateLinkForKey = (key: string, resultAtKey: unknown) => {
class="border-2"
>
{generateLinkForKey(key, result[key]) ? (
<a rel="prefetch" href={generateLinkForKey(key, result[key])}>
<a
class="underline"
rel="prefetch"
href={generateLinkForKey(key, result[key])}
>
{result[key]}
</a>
) : (
Expand Down
1 change: 1 addition & 0 deletions src/lib/layouts/subsessions.astro
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const { keysArray, handledResults } = handleResults({ keysToDisplay, results });
>
{key === "0" ? (
<a
class="underline"
rel="prefetch"
href={`/Stat-N-Track/subsession/${result[key]}`}
>
Expand Down
9 changes: 8 additions & 1 deletion src/lib/utils/field-id-to-label-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default new Map<string, string>([
["division_rank", "Rank (Division)"],
["overall_rank", "Rank (Overall)"],
["season_id", "Season ID"],
["season_name", "Name"],
["season_name", "Season Name"],
["weeks_counted", "Participation Weeks"],
["starts", "Starts"],
["wins", "Wins"],
Expand All @@ -52,4 +52,11 @@ export default new Map<string, string>([
["safety_rating", "Safety Rating"],
["irating", "iRating"],
["group_name", "License Group Name"],
["race_week_num", "Race Week Number"],
["num_lead_changes", "Number of Lead Changes"],
["num_cautions", "Number of Cautions"],
["num_caution_laps", "Number of Caution Laps"],
["event_strength_of_field", "Strength of Field"],
["event_laps_complete", "Total Laps"],
["event_average_lap", "Average Lap Time"],
]);
31 changes: 31 additions & 0 deletions src/lib/utils/race-session-keys-to-display.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export default new Set([
"cust_id",
"display_name",
"finish_position",
"finish_position_in_class",
"laps_lead",
"laps_complete",
"interval",
"class_interval",
"average_lap",
"best_lap_num",
"best_lap_time",
"reason_out",
"champ_points",
"drop_race",
"club_points",
"starting_position",
"starting_position_in_class",
"car_class_short_name",
"club_shortname",
"division_name",
"old_license_level",
"old_cpi",
"oldi_rating",
"new_license_level",
"new_cpi",
"newi_rating",
"incidents",
"car_name",
"aggregate_champ_points",
]);
2 changes: 1 addition & 1 deletion src/lib/utils/user-ids.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default [300752, 815162]
export default [300752, 815162];
15 changes: 13 additions & 2 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ import DefaultLayout from "$lib/layouts/default.astro";
<DefaultLayout>
<div class="text-center text-3xl">
<div>
<a rel="prefetch" href="/Stat-N-Track/user/300752">Jacob Collins</a>
<a class="underline" rel="prefetch" href="/Stat-N-Track/user/300752"
>Jacob Collins</a
>
</div>
<div>
<a rel="prefetch" href="/Stat-N-Track/user/815162">Jack Glenzinski</a>
<a class="underline" rel="prefetch" href="/Stat-N-Track/user/815162"
>Jack Glenzinski</a
>
</div>
<div>
<a
class="underline"
rel="prefetch"
href="/Stat-N-Track/shared-subsessions">Shared Subsessions</a
>
</div>
</div>
</DefaultLayout>
Loading

0 comments on commit b7f11f0

Please sign in to comment.