-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add state differences for report page * Additional states for managing ai report * theme updates for hey sport message * Better weekly report validation * updating themes to make light mode better
- Loading branch information
Showing
20 changed files
with
692 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/app/src/api/platformServer/weeklyReport.platformApi.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { platformApiRequest } from '../request' | ||
|
||
import { PLATFORM_API_URL, useBetterQuery } from '..' | ||
import { weeklyReportKeys } from './keys' | ||
import { useMutation, useQueryClient } from '@tanstack/react-query' | ||
|
||
export const useGetAiWeeklyReport = (startOfWeek: string, email?: string) => { | ||
const queryFn = () => | ||
platformApiRequest({ | ||
url: `${PLATFORM_API_URL}/ai-weekly-report?email=${email}&startOfWeek=${startOfWeek}`, | ||
method: 'GET', | ||
}) | ||
return useBetterQuery<string, Error>({ | ||
queryKey: weeklyReportKeys.aiWeeklyReports(startOfWeek), | ||
queryFn, | ||
enabled: !!email, | ||
}) | ||
} | ||
|
||
export const useGenerateAiWeeklyReport = () => { | ||
const queryClient = useQueryClient() | ||
let startOfWeek: string | ||
const mutationFn = (body: { | ||
email: string | ||
startOfWeek: string | ||
weeklyReport: CodeClimbers.WeeklyScores | ||
}) => { | ||
startOfWeek = body.startOfWeek | ||
return platformApiRequest({ | ||
url: `${PLATFORM_API_URL}/ai-weekly-report`, | ||
method: 'POST', | ||
body, | ||
}) | ||
} | ||
return useMutation({ | ||
mutationFn, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ | ||
queryKey: weeklyReportKeys.aiWeeklyReports(startOfWeek), | ||
}) | ||
}, | ||
}) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
packages/app/src/components/WeeklyReports/AiReportHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import { Box, Stack, Typography } from '@mui/material' | ||
import { BossImage } from '../common/Icons/BossImage' | ||
import { CodeClimbersIconButton } from '../common/CodeClimbersIconButton' | ||
import CloseIcon from '@mui/icons-material/Close' | ||
import { WeeklyReportDialog } from '../common/WeeklyReportDialog' | ||
import { useGetCurrentUser } from '../../api/browser/user.api' | ||
import { useEffect, useState } from 'react' | ||
import { CodeClimbersButton } from '../common/CodeClimbersButton' | ||
|
||
const getLoadingTexts = (): string => { | ||
return 'Contacting your manager... Choosing excuses... Engaging passive-aggressive behavior... Attempting to sabotage your career... Synergizing with your peers... Scheduling a meeting... Reviewing vieled threats... ' | ||
} | ||
|
||
const useLoadingText = (loading?: boolean) => { | ||
const [loadingTextIndex, setLoadingTextIndex] = useState(0) | ||
|
||
const [loadingText, setLoadingText] = useState('') | ||
|
||
useEffect(() => { | ||
if (!loading) { | ||
return | ||
} | ||
const interval = setInterval(() => { | ||
const index = | ||
loadingTextIndex > getLoadingTexts().length ? 0 : loadingTextIndex | ||
setLoadingText((prevText) => prevText + getLoadingTexts()[index]) | ||
setLoadingTextIndex((prevIndex) => { | ||
const newIndex = prevIndex + 1 | ||
return newIndex >= getLoadingTexts().length ? 0 : newIndex | ||
}) | ||
}, 100) | ||
return () => clearInterval(interval) | ||
}, [loadingTextIndex, loadingText, loading]) | ||
return { | ||
loadingText, | ||
} | ||
} | ||
|
||
export const AiReportHeader = (props: { | ||
showCloseButton?: boolean | ||
aiButton: { | ||
text: string | ||
onClick?: () => void | ||
disabled?: boolean | ||
loading?: boolean | ||
} | ||
openWeeklyReportModal?: boolean | ||
}) => { | ||
const { data: user } = useGetCurrentUser() | ||
const [isWeeklyReportModalOpen, setIsWeeklyReportModalOpen] = useState(false) | ||
const { loadingText } = useLoadingText(props.aiButton.loading) | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
backgroundColor: (theme) => theme.palette.common.white, | ||
color: (theme) => theme.palette.common.black, | ||
justifyContent: 'center', | ||
p: 4, | ||
}} | ||
> | ||
<Box> | ||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2, mb: 4 }}> | ||
<BossImage variant="neutral" width={64} height={64} /> | ||
<Stack> | ||
<Typography | ||
variant="monospace" | ||
style={{ margin: 0, marginBottom: '12px' }} | ||
> | ||
From: Timothy Brother | ||
</Typography> | ||
<Typography variant="monospace" style={{ margin: 0 }}> | ||
Subject: Comments on Your Week | ||
</Typography> | ||
</Stack> | ||
</Box> | ||
{props.aiButton.loading ? ( | ||
<Typography | ||
variant="monospace" | ||
style={{ | ||
width: '265px', | ||
height: '36.5px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'flex-end', | ||
textWrap: 'nowrap', | ||
overflow: 'hidden', | ||
}} | ||
> | ||
{loadingText} | ||
</Typography> | ||
) : ( | ||
<CodeClimbersButton | ||
eventName="generate_ai_weekly_report" | ||
variant="contained" | ||
fullWidth | ||
disabled={props.aiButton.disabled} | ||
sx={{ | ||
'&.Mui-disabled': { | ||
backgroundColor: '#E0E0E0', // or any other color you prefer | ||
color: '#00000080', | ||
}, | ||
}} | ||
onClick={() => { | ||
if (props.openWeeklyReportModal) { | ||
setIsWeeklyReportModalOpen(true) | ||
} | ||
props.aiButton.onClick?.() | ||
}} | ||
> | ||
{props.aiButton.text} | ||
</CodeClimbersButton> | ||
)} | ||
</Box> | ||
{props.showCloseButton && ( | ||
<Box> | ||
<CodeClimbersIconButton | ||
eventName="close_big_brother_report" | ||
color="inherit" | ||
sx={{ p: 0, pl: 2 }} | ||
> | ||
<CloseIcon /> | ||
</CodeClimbersIconButton> | ||
</Box> | ||
)} | ||
{user && isWeeklyReportModalOpen && ( | ||
<WeeklyReportDialog | ||
user={user} | ||
open={isWeeklyReportModalOpen} | ||
onClose={() => setIsWeeklyReportModalOpen(false)} | ||
/> | ||
)} | ||
</Box> | ||
) | ||
} |
Oops, something went wrong.