Skip to content

Commit

Permalink
Use remainingDaysToStart for upcoming events
Browse files Browse the repository at this point in the history
  • Loading branch information
tnagorra committed Sep 6, 2024
1 parent e882d5b commit 6b825e9
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 77 deletions.
1 change: 0 additions & 1 deletion src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export interface GeneralEvent {
typeDisplay: string;
icon: React.ReactNode;
name: string;
date: string;
remainingDays: number;
}

Expand Down
2 changes: 1 addition & 1 deletion src/views/DailyJournal/DayView/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
.joined-heading {
display: flex;
align-items: center;
gap: var(--spacing-md);
gap: var(--spacing-sm);
color: var(--color-text-light);
font-weight: var(--font-weight-semibold);

Expand Down
36 changes: 16 additions & 20 deletions src/views/DailyJournal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,22 @@ export function Component() {
>
<IoCalendarOutline />
</CalendarInput>
{entriesWithoutTask > 0 && (
<div className={styles.warningBadge}>
<FcHighPriority />
<span>
{`${entriesWithoutTask} uncategorized`}
</span>
</div>
)}
{entriesWithoutHours > 0 && (
<div className={styles.warningBadge}>
<FcHighPriority />
<span>
{`${entriesWithoutHours} untracked`}
</span>
</div>
)}
<div className={styles.spacer} />
<Button
name={undefined}
Expand Down Expand Up @@ -708,26 +724,6 @@ export function Component() {
selectedDate={selectedDate}
/>
</FocusContext.Provider>
{entriesWithoutTask + entriesWithoutHours > 0 && (
<div className={styles.warning}>
{entriesWithoutTask > 0 && (
<div className={styles.warningBadge}>
<FcHighPriority />
<span>
{`${entriesWithoutTask} uncategorized entries`}
</span>
</div>
)}
{entriesWithoutHours > 0 && (
<div className={styles.warningBadge}>
<FcHighPriority />
<span>
{`${entriesWithoutHours} untracked entries`}
</span>
</div>
)}
</div>
)}
<div className={styles.bottomActions}>
<Button
name={undefined}
Expand Down
24 changes: 9 additions & 15 deletions src/views/DailyJournal/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@
}
}

.warning {
display: flex;
flex-wrap: wrap;
gap: var(--spacing-sm);

.warning-badge {
display: flex;
flex-shrink: 0;
border: 1px solid var(--color-separator);
border-radius: var(--border-radius-lg);
padding: var(--spacing-xs) var(--spacing-sm);
gap: var(--spacing-xs);
}
}

.bottom-actions {
display: flex;
gap: var(--spacing-sm);
Expand All @@ -60,6 +45,15 @@
width: 100%;
gap: var(--spacing-xs);

.warning-badge {
display: flex;
flex-shrink: 0;
border: 1px solid var(--color-separator);
border-radius: var(--border-radius-lg);
padding: var(--spacing-2xs) var(--spacing-sm);
gap: var(--spacing-xs);
}

.spacer {
flex-grow: 1;
}
Expand Down
26 changes: 6 additions & 20 deletions src/views/DailyStandup/DeadlineSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import {
FcNightLandscape,
FcSportsMode,
} from 'react-icons/fc';
import {
compareDate,
getDifferenceInDays,
} from '@togglecorp/fujs';
import { compareNumber } from '@togglecorp/fujs';
import {
gql,
useQuery,
Expand All @@ -24,8 +21,8 @@ import {
} from '#generated/types/graphql';
import { type GeneralEvent } from '#utils/types';

import GeneralEventOutput from '../GeneralEvent';
import Slide from '../Slide';
import GeneralEventOutput from './GeneralEvent';

import styles from './styles.module.css';

Expand All @@ -50,19 +47,13 @@ const DEADLINES_AND_EVENTS = gql`
id
name
remainingDays
endDate
totalDays
usedDays
projectId
}
}
relativeEvents {
id
name
startDate
remainingDaysToStart
typeDisplay
dates
endDate
type
}
}
Expand Down Expand Up @@ -112,7 +103,6 @@ function DeadlineSection(props: Props) {
typeDisplay: 'Deadline',
icon: iconsMap.DEADLINE,
name: deadline.name,
date: deadline.endDate,
remainingDays: deadline.remainingDays,
})) ?? []),
...(events?.map((otherEvent) => ({
Expand All @@ -121,14 +111,10 @@ function DeadlineSection(props: Props) {
icon: iconsMap[otherEvent.type],
typeDisplay: otherEvent.typeDisplay,
name: otherEvent.name,
date: otherEvent.startDate,
remainingDays: getDifferenceInDays(
otherEvent.startDate,
date,
),
remainingDays: otherEvent.remainingDaysToStart,
})) ?? []),
].sort((a, b) => compareDate(a.date, b.date));
}, [events, projects, date]);
].sort((a, b) => compareNumber(a.remainingDays, b.remainingDays));
}, [events, projects]);

return (
<Slide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ const DAILY_STANDUP_QUERY = gql`
project {
id
name
description
deadlines {
id
name
startDate
totalDays
usedDays
remainingDays
}
logoHd {
url
}
Expand All @@ -73,17 +64,12 @@ const DAILY_STANDUP_QUERY = gql`
}
}
}
quote {
id
text
author
}
}
}
}
`;

function ProjectStandup(props: Props) {
function ProjectSection(props: Props) {
const {
projectId,
date,
Expand All @@ -110,7 +96,7 @@ function ProjectStandup(props: Props) {
return (
<Slide
variant="split"
className={_cs(styles.projectStandup, className)}
className={_cs(styles.projectSection, className)}
primaryPreText={isDefined(stats?.project.logoHd) && (
<img
className={styles.projectIcon}
Expand Down Expand Up @@ -145,4 +131,4 @@ function ProjectStandup(props: Props) {
);
}

export default ProjectStandup;
export default ProjectSection;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.project-standup {
.project-section {
.project-icon {
width: 10rem;
height: 10rem;
Expand Down
4 changes: 2 additions & 2 deletions src/views/DailyStandup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import useUrlQueryState from '#hooks/useUrlQueryState';

import DeadlineSection from './DeadlineSection';
import EndSection from './EndSection';
import ProjectStandup from './ProjectStandup';
import ProjectSection from './ProjectSection';
import StartSection from './StartSection';

import styles from './styles.module.css';
Expand Down Expand Up @@ -281,7 +281,7 @@ export function Component() {
/>
)}
{mapId !== 'start' && mapId !== 'end' && mapId !== 'deadlines' && (
<ProjectStandup
<ProjectSection
date={selectedDate}
projectId={mapId}
/>
Expand Down

0 comments on commit 6b825e9

Please sign in to comment.