Skip to content

Commit

Permalink
fix: fix match rating in client after server-side additions (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
revam authored Nov 5, 2024
1 parent 0fc2cbc commit d3b462e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/components/Collection/Tmdb/MatchRating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ const getAbbreviation = (rating?: MatchRatingType) => {
switch (rating) {
case MatchRatingType.DateAndTitleMatches:
return 'DT';
case MatchRatingType.DateAndTitleKindaMatches:
return '~DT';
case MatchRatingType.DateMatches:
return 'D';
case MatchRatingType.TitleMatches:
return 'T';
case MatchRatingType.TitleKindaMatches:
return '~T';
case MatchRatingType.UserVerified:
return 'UO';
case MatchRatingType.FirstAvailable:
Expand All @@ -31,8 +35,10 @@ const MatchRating = React.memo(({ isDisabled, isOdd, rating }: Props) => (
className={cx(
'flex justify-center items-center rounded-md border border-panel-border w-16 text-button-primary-text',
{
'bg-panel-text-important': rating === MatchRatingType.DateAndTitleMatches,
'bg-panel-text-warning': rating === MatchRatingType.DateMatches || rating === MatchRatingType.TitleMatches,
'bg-panel-text-important': rating === MatchRatingType.DateAndTitleMatches
|| rating === MatchRatingType.TitleMatches,
'bg-panel-text-warning': rating === MatchRatingType.DateMatches || rating === MatchRatingType.TitleKindaMatches
|| rating === MatchRatingType.DateAndTitleKindaMatches,
'bg-panel-text-primary': rating === MatchRatingType.UserVerified,
'bg-panel-text-danger': rating === MatchRatingType.FirstAvailable,
'bg-panel-background': (!rating || rating === MatchRatingType.None) && !isOdd,
Expand Down
11 changes: 9 additions & 2 deletions src/components/Collection/Tmdb/TopPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,18 @@ const TopPanel = (props: Props) => {
</div>
Dates and Title Match (DT)
</div>
<div className="flex items-center gap-x-2">
<div className="rounded-md bg-panel-text-important px-2 text-button-primary-text">
{matchRatingCounts.TitleMatches ?? 0}
</div>
Title Match (T)
</div>
<div className="flex items-center gap-x-2">
<div className="rounded-md bg-panel-text-warning px-2 text-button-primary-text">
{(matchRatingCounts.DateMatches ?? 0) + (matchRatingCounts.TitleMatches ?? 0)}
{(matchRatingCounts.DateAndTitleKindaMatches ?? 0) + (matchRatingCounts.DateMatches ?? 0)
+ (matchRatingCounts.TitleKindaMatches ?? 0)}
</div>
Dates or Title Match (D/T)
Dates and/or Title Kinda Match (~DT/D/~T)
</div>
<div className="flex items-center gap-x-2">
<div className="rounded-md bg-panel-text-primary px-2 text-button-primary-text">
Expand Down
2 changes: 2 additions & 0 deletions src/core/types/api/episode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ export type EpisodeFilesQueryType = {

export enum MatchRatingType {
UserVerified = 'UserVerified',
DateAndTitleKindaMatches = 'DateAndTitleKindaMatches',
DateAndTitleMatches = 'DateAndTitleMatches',
DateMatches = 'DateMatches',
TitleKindaMatches = 'TitleKindaMatches',
TitleMatches = 'TitleMatches',
FirstAvailable = 'FirstAvailable',
None = 'None',
Expand Down

0 comments on commit d3b462e

Please sign in to comment.