5 Commits

Author SHA1 Message Date
primakov 05c291120d 1.4.3
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
2025-12-15 21:30:57 +03:00
primakov 4fd2e5660c Enhance LearningMaterialViewer and TaskWorkspace components to open links in a new tab with appropriate security attributes. This improves user experience by ensuring external links are handled safely.
platform/bro-js/challenge-pl/pipeline/head Build queued...
2025-12-15 21:30:50 +03:00
primakov 842bb959ab 1.4.2
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
2025-12-15 21:22:34 +03:00
primakov eb5bc8a10a Update authUser mutation to accept optional workplaceNumber parameter and adjust login function accordingly. Enhance API logging for authentication requests to include workplaceNumber for better debugging.
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
2025-12-15 18:03:10 +03:00
primakov a0ac758049 Add refreshChains function to ChallengeContext and integrate it into ChainsPage for improved data management. This allows for manual refreshing of chain data when the component mounts, enhancing user experience.
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
2025-12-15 17:43:21 +03:00
8 changed files with 55 additions and 10 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "challenge", "name": "challenge",
"version": "1.4.1", "version": "1.4.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "challenge", "name": "challenge",
"version": "1.4.1", "version": "1.4.3",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@brojs/cli": "^1.9.4", "@brojs/cli": "^1.9.4",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "challenge", "name": "challenge",
"version": "1.4.1", "version": "1.4.3",
"description": "", "description": "",
"main": "./src/index.tsx", "main": "./src/index.tsx",
"scripts": { "scripts": {
+1 -1
View File
@@ -33,7 +33,7 @@ export const api = createApi({
}), }),
tagTypes: ['Chains', 'Chain', 'UserStats', 'SystemStats', 'Submissions', 'Queue'], tagTypes: ['Chains', 'Chain', 'UserStats', 'SystemStats', 'Submissions', 'Queue'],
endpoints: (builder) => ({ endpoints: (builder) => ({
authUser: builder.mutation<ChallengeAuthResponse, { nickname: string }>({ authUser: builder.mutation<ChallengeAuthResponse, { nickname: string; workplaceNumber?: string }>({
query: (body) => ({ query: (body) => ({
url: '/auth', url: '/auth',
method: 'POST', method: 'POST',
@@ -234,7 +234,14 @@ export const LearningMaterialViewer = ({
} }
}} }}
> >
<ReactMarkdown remarkPlugins={[remarkGfm]}> <ReactMarkdown
remarkPlugins={[remarkGfm]}
components={{
a: ({ node: _node, ...props }) => (
<a {...props} target="_blank" rel="noopener noreferrer" />
)
}}
>
{pages[currentPage]} {pages[currentPage]}
</ReactMarkdown> </ReactMarkdown>
</Box> </Box>
+10 -1
View File
@@ -274,7 +274,16 @@ export const TaskWorkspace = ({ task, onTaskComplete, onTaskSkip }: TaskWorkspac
} }
}} }}
> >
<ReactMarkdown remarkPlugins={[remarkGfm]}>{task.description}</ReactMarkdown> <ReactMarkdown
remarkPlugins={[remarkGfm]}
components={{
a: ({ node: _node, ...props }) => (
<a {...props} target="_blank" rel="noopener noreferrer" />
)
}}
>
{task.description}
</ReactMarkdown>
</Box> </Box>
</Box> </Box>
+21 -2
View File
@@ -65,6 +65,7 @@ interface ChallengeContextValue {
login: (nickname: string, workplaceNumber: string) => Promise<void> login: (nickname: string, workplaceNumber: string) => Promise<void>
logout: () => void logout: () => void
refreshStats: () => Promise<void> refreshStats: () => Promise<void>
refreshChains: () => Promise<void>
eventEmitter: ChallengeEventEmitter eventEmitter: ChallengeEventEmitter
pollingManager: PollingManager pollingManager: PollingManager
metricsCollector: MetricsCollector metricsCollector: MetricsCollector
@@ -96,10 +97,23 @@ export const ChallengeProvider = ({ children }: PropsWithChildren) => {
const [authUser, { isLoading: isAuthLoading }] = useAuthUserMutation() const [authUser, { isLoading: isAuthLoading }] = useAuthUserMutation()
const [triggerStats, statsResult] = useLazyGetUserStatsQuery() const [triggerStats, statsResult] = useLazyGetUserStatsQuery()
const { data: chainsData, isLoading: isChainsLoading } = useGetChainsQuery(undefined, { const {
data: chainsData,
isLoading: isChainsLoading,
refetch: refetchChains,
} = useGetChainsQuery(undefined, {
skip: !userId, skip: !userId,
}) })
const refreshChains = useCallback(async () => {
if (!userId) {
return
}
cacheRef.current.clear('chains')
await refetchChains()
}, [refetchChains, userId])
useEffect(() => { useEffect(() => {
if (chainsData) { if (chainsData) {
setChains(chainsData) setChains(chainsData)
@@ -146,7 +160,10 @@ export const ChallengeProvider = ({ children }: PropsWithChildren) => {
const login = useCallback( const login = useCallback(
async (nicknameValue: string, workplaceNumberValue: string) => { async (nicknameValue: string, workplaceNumberValue: string) => {
const response = await authUser({ nickname: nicknameValue }).unwrap() const response = await authUser({
nickname: nicknameValue,
workplaceNumber: workplaceNumberValue || undefined
}).unwrap()
setUserId(response.userId) setUserId(response.userId)
setNickname(nicknameValue) setNickname(nicknameValue)
setWorkplaceNumber(workplaceNumberValue) setWorkplaceNumber(workplaceNumberValue)
@@ -189,6 +206,7 @@ export const ChallengeProvider = ({ children }: PropsWithChildren) => {
login, login,
logout, logout,
refreshStats, refreshStats,
refreshChains,
eventEmitter, eventEmitter,
pollingManager, pollingManager,
metricsCollector, metricsCollector,
@@ -213,6 +231,7 @@ export const ChallengeProvider = ({ children }: PropsWithChildren) => {
personalDashboard, personalDashboard,
pollingManager, pollingManager,
refreshStats, refreshStats,
refreshChains,
saveDraft, saveDraft,
stats, stats,
userId, userId,
+5 -1
View File
@@ -10,7 +10,7 @@ import type { ChallengeChain } from '../../__data__/types'
export const ChainsPage = () => { export const ChainsPage = () => {
const navigate = useNavigate() const navigate = useNavigate()
const { nickname } = useChallenge() const { nickname, refreshChains } = useChallenge()
// Проверяем авторизацию // Проверяем авторизацию
useEffect(() => { useEffect(() => {
@@ -24,6 +24,10 @@ export const ChainsPage = () => {
} }
}, [navigate, nickname]) }, [navigate, nickname])
useEffect(() => {
refreshChains()
}, [refreshChains])
const handleSelectChain = (chain: ChallengeChain) => { const handleSelectChain = (chain: ChallengeChain) => {
storage.setSelectedChainId(chain.id) storage.setSelectedChainId(chain.id)
+7 -1
View File
@@ -24,7 +24,13 @@ router.use((req, res, next) => {
// Challenge API endpoints // Challenge API endpoints
router.post('/challenge/auth', (req, res) => { router.post('/challenge/auth', (req, res) => {
res.json(readJson('auth.json')) const { nickname, workplaceNumber } = req.body
const response = readJson('auth.json')
// Логируем для отладки
console.log('Auth request:', { nickname, workplaceNumber })
res.json(response)
}) })
router.get('/challenge/chains', (req, res) => { router.get('/challenge/chains', (req, res) => {