Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/apps/accounts/src/lib/userflow-survey.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { TcUniNavFn } from 'universal-navigation'
import { getTcUniNav } from '~/apps/platform/src/utils'

import { CES_SURVEY_ID } from '../config'

declare let tcUniNav: TcUniNavFn

export function triggerSurvey(): void {
tcUniNav('triggerFlow', CES_SURVEY_ID, {})
getTcUniNav()?.('triggerFlow', CES_SURVEY_ID, {})
}
5 changes: 2 additions & 3 deletions src/apps/platform/src/components/app-footer/AppFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { FC, MutableRefObject, useEffect, useRef } from 'react'
import type { TcUniNavFn } from 'universal-navigation'

declare let tcUniNav: TcUniNavFn
import { getTcUniNav } from '../../utils'

const APP_FOOTER_EL_ID: string = 'footer-nav-el'

Expand All @@ -22,7 +21,7 @@ const AppFooter: FC<{}> = () => {
return
}

tcUniNav(
getTcUniNav()?.(
'init',
APP_FOOTER_EL_ID,
{
Expand Down
11 changes: 6 additions & 5 deletions src/apps/platform/src/components/app-header/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useState,
} from 'react'
import { NavigateFunction, useNavigate } from 'react-router-dom'
import type { AuthUser as NavAuthUser, TcUniNavFn } from 'universal-navigation'
import type { AuthUser as NavAuthUser } from 'universal-navigation'
import classNames from 'classnames'

import { EnvironmentConfig, PageSubheaderPortalId } from '~/config'
Expand All @@ -25,9 +25,10 @@ import {
} from '~/libs/core'
import { ConfigContextValue, useConfigContext } from '~/libs/shared'

import { getTcUniNav } from '../../utils'

import UniNavSnippet from './universal-nav-snippet'

declare let tcUniNav: TcUniNavFn
UniNavSnippet(EnvironmentConfig.URLS.UNIVERSAL_NAV)

interface NavigationRequest {
Expand Down Expand Up @@ -86,7 +87,7 @@ const AppHeader: FC<{}> = () => {

headerInit.current = true

tcUniNav(
getTcUniNav()?.(
'init',
navElementId,
{
Expand Down Expand Up @@ -116,7 +117,7 @@ const AppHeader: FC<{}> = () => {
// update uni-nav's tool details
useEffect(() => {

tcUniNav(
getTcUniNav()?.(
'update',
navElementId,
{
Expand All @@ -139,7 +140,7 @@ const AppHeader: FC<{}> = () => {
return
}

tcUniNav(
getTcUniNav()?.(
'update',
navElementId,
{
Expand Down
1 change: 1 addition & 0 deletions src/apps/platform/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './other'
15 changes: 15 additions & 0 deletions src/apps/platform/src/utils/other.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TcUniNavFn } from 'universal-navigation'

declare let tcUniNav: TcUniNavFn

/**
* Get tcUniNav
* @returns tcUniNav
*/
export function getTcUniNav(): TcUniNavFn | undefined {
if (typeof tcUniNav === 'undefined') {
return undefined
}

return tcUniNav
}
6 changes: 2 additions & 4 deletions src/apps/profiles/src/lib/userflow-survey.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { TcUniNavFn } from 'universal-navigation'
import { getTcUniNav } from '~/apps/platform/src/utils'

import { CES_SURVEY_ID } from '../config'

declare let tcUniNav: TcUniNavFn

export function triggerSurvey(): void {
tcUniNav('triggerFlow', CES_SURVEY_ID, {})
getTcUniNav()?.('triggerFlow', CES_SURVEY_ID, {})
}
2 changes: 2 additions & 0 deletions src/apps/review/src/config/index.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,5 @@ export const WINNERS = 'Winners'
export const TAB = 'tab'
export const FINISHTAB = [WINNERS]
export const WITHOUT_APPEAL = [DESIGN, FIRST2FINISH]

export const NO_RESOURCE_ID = 'noResource'
95 changes: 72 additions & 23 deletions src/apps/review/src/lib/components/Appeal/Appeal.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
/**
* AppealComment.
*/
import { FC, useCallback, useState } from 'react'
import { FC, useCallback, useContext, useEffect, useMemo, useState } from 'react'
import {
Controller,
ControllerRenderProps,
useForm,
UseFormReturn,
} from 'react-hook-form'
import _, { bind, includes } from 'lodash'
import { get } from 'lodash'
import classNames from 'classnames'

import { yupResolver } from '@hookform/resolvers/yup'

import { MarkdownReview } from '../MarkdownReview'
import { FieldMarkdownEditor } from '../FieldMarkdownEditor'
import { FormAppealResponse } from '../../models'
import { formAppealResponseSchema } from '../../utils'
import { ADMIN, COPILOT, FINISHTAB, ITERATIVE_REVIEW, TAB } from '../../../config/index.config'
import { AppealInfo, ChallengeDetailContextModel, FormAppealResponse } from '../../models'
import { formAppealResponseSchema, isAppealsPhase } from '../../utils'
import { ReviewItemComment } from '../../models/ReviewItemComment.model'
import { ChallengeDetailContext } from '../../contexts'

import styles from './Appeal.module.scss'

interface Props {
className?: string
role?: string
appealInfo?: AppealInfo
commentItem: ReviewItemComment
isSavingAppeal: boolean
addAppeal: (
content: string,
commentItem: ReviewItemComment,
success: () => void,
) => void
doDeleteAppeal: (
appealInfo: AppealInfo | undefined,
success: () => void,
) => void
}

export const AppealComment: FC<Props> = (props: Props) => {
const [appealResponse, setAppealResponse] = useState('')
const [showResponseForm, setShowResponseForm] = useState(false)
const [showAppealResponse, setShowAppealResponse] = useState(false)

const { challengeInfo }: ChallengeDetailContextModel = useContext(
ChallengeDetailContext,
)
const canAddAppeal = useMemo(() => isAppealsPhase(challengeInfo), [challengeInfo])

const {
handleSubmit,
Expand All @@ -44,29 +60,54 @@ export const AppealComment: FC<Props> = (props: Props) => {
})

const onSubmit = useCallback((data: FormAppealResponse) => {
setAppealResponse(data.response)
setShowResponseForm(false)
setShowAppealResponse(true)
}, [])
props.addAppeal(data.response, props.commentItem, () => {
setAppealResponse(data.response)
setShowResponseForm(false)
})
}, [props.commentItem])

if (includes(FINISHTAB, sessionStorage.getItem(TAB))) {
return <></>
}
useEffect(() => {
if (props.appealInfo) {
setAppealResponse(props.appealInfo.content)
}
}, [props.appealInfo])

return (
<div className={classNames(styles.container, props.className)}>
{showAppealResponse && (
{appealResponse && !showResponseForm && (
<div className={styles.blockAppealComment}>
<span className={styles.textTitle}>Appeal Comment</span>
<MarkdownReview value={appealResponse} />
{canAddAppeal && (
<div className={styles.blockBtns}>
<button
onClick={function onClick() {
setShowResponseForm(true)
}}
className='filledButton'
type='button'
disabled={props.isSavingAppeal}
>
Edit Appeal
</button>
<button
onClick={function onClick() {
props.doDeleteAppeal(props.appealInfo, () => {
setAppealResponse('')
})
}}
type='button'
className='cancelButton'
disabled={props.isSavingAppeal}
>
Delete
</button>
</div>
)}
</div>
)}

{!showResponseForm
&& !showAppealResponse
&& !includes(FINISHTAB, sessionStorage.getItem(TAB))
&& !includes(sessionStorage.getItem(TAB), ITERATIVE_REVIEW)
&& !includes([COPILOT, ADMIN], props.role) && (
{!appealResponse && !showResponseForm && canAddAppeal && (
<button
type='button'
className='borderButton'
Expand Down Expand Up @@ -95,23 +136,31 @@ export const AppealComment: FC<Props> = (props: Props) => {
}) {
return (
<FieldMarkdownEditor
initialValue={appealResponse}
className={styles.markdownEditor}
onChange={controlProps.field.onChange}
showBorder
onBlur={controlProps.field.onBlur}
error={_.get(errors, 'response.message')}
error={get(errors, 'response.message')}
disabled={props.isSavingAppeal}
/>
)
}}
/>
<div className={styles.blockBtns}>
<button className='filledButton' type='submit'>
<button
disabled={props.isSavingAppeal}
className='filledButton'
type='submit'
>
Submit Appeal
</button>
<button
type='button'
className='borderButton'
onClick={bind(setShowResponseForm, undefined, false)}
onClick={function onClick() {
setShowResponseForm(false)
}}
>
Cancel
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@
line-height: 20px;
}
}

.blockReaponseAppealHeader {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
Loading