-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updated FAQ texts, added timestamp on request items in claim page
- Loading branch information
Showing
12 changed files
with
153 additions
and
41 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
45 changes: 25 additions & 20 deletions
45
features/withdrawals/claim/form/requests-list/request-item-status.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 |
---|---|---|
@@ -1,39 +1,44 @@ | ||
import { Tooltip } from '@lidofinance/lido-ui'; | ||
import { useWaitingTime } from 'features/withdrawals/hooks/useWaitingTime'; | ||
import { | ||
RequestsStatusStyled, | ||
DesktopStatus, | ||
MobileStatusIcon, | ||
RequestInfoIcon, | ||
StatusIcon, | ||
MobileStatus, | ||
} from './styles'; | ||
import { forwardRef } from 'react'; | ||
import { formatTimestamp } from '../../../utils/format-timestamp'; | ||
|
||
type RequestItemStatusProps = { status: 'ready' | 'pending' }; | ||
|
||
export const RequestStatus: React.FC<RequestItemStatusProps> = ({ status }) => { | ||
if (status === 'pending') return <RequestStatusPending />; | ||
return <RequestStatusBody status="ready" />; | ||
type RequestItemStatusProps = { | ||
status: 'ready' | 'pending'; | ||
finalizationAt: string | null; | ||
}; | ||
|
||
const RequestStatusPending: React.FC = () => { | ||
const waitingTime = useWaitingTime(''); | ||
return ( | ||
<Tooltip title={`Current withdrawal period is ${waitingTime.value}.`}> | ||
<RequestStatusBody status="pending" /> | ||
</Tooltip> | ||
); | ||
export const RequestStatus: React.FC<RequestItemStatusProps> = (props) => { | ||
return <RequestStatusBody {...props} />; | ||
}; | ||
|
||
const RequestStatusBody = forwardRef< | ||
HTMLDivElement, | ||
RequestItemStatusProps & React.ComponentProps<'div'> | ||
>(({ status, ...props }, ref) => { | ||
const statusText = status === 'ready' ? 'Ready to claim' : 'Pending'; | ||
>(({ status, finalizationAt, ...props }, ref) => { | ||
let statusText; | ||
let statusTextMobile; | ||
|
||
if (status === 'ready') { | ||
statusText = 'Ready'; | ||
statusTextMobile = 'Ready'; | ||
} else if (finalizationAt) { | ||
statusText = formatTimestamp(finalizationAt); | ||
statusTextMobile = formatTimestamp(finalizationAt, true); | ||
} else { | ||
statusText = 'Pending'; | ||
statusTextMobile = 'Pending'; | ||
} | ||
|
||
return ( | ||
<RequestsStatusStyled {...props} ref={ref} $variant={status}> | ||
<StatusIcon $variant={status} /> | ||
<DesktopStatus>{statusText}</DesktopStatus> | ||
<MobileStatusIcon $variant={status} /> | ||
{status === 'pending' && <RequestInfoIcon />} | ||
<MobileStatus>{statusTextMobile}</MobileStatus> | ||
</RequestsStatusStyled> | ||
); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const formatTimestamp = (timestamp: string, short = false): string => { | ||
const diff = new Date(timestamp).getTime() - Date.now(); | ||
const hours = Math.ceil(diff / (1000 * 60 * 60)); | ||
const h = short ? 'h' : 'hour'; | ||
|
||
if (hours < 24) { | ||
const plural = hours === 1 || short ? '' : 's'; | ||
return `~${hours} ${h}${plural}`; | ||
} | ||
|
||
const days = Math.ceil(hours / 24); | ||
const d = short ? 'd' : 'day'; | ||
const plural = days === 1 || short ? '' : 's'; | ||
return `~${days} ${d}${plural}`; | ||
}; |
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
18 changes: 18 additions & 0 deletions
18
features/withdrawals/withdrawals-faq/list/why-waiting-time-changed.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,18 @@ | ||
import { Accordion } from '@lidofinance/lido-ui'; | ||
import { WITHDRAWAL_PERIOD_PATH } from '../../withdrawals-constants'; | ||
import { LocalLink } from '../../../../shared/components/local-link'; | ||
|
||
export const WhyWaitingTimeChanged: React.FC = () => { | ||
return ( | ||
<Accordion summary="Why my waiting time changed after I submitted the withdrawal request?"> | ||
<p> | ||
The waiting time could be changed due to{' '} | ||
<LocalLink href={WITHDRAWAL_PERIOD_PATH}> | ||
several factors | ||
</LocalLink> | ||
affecting waiting time. That's why it may either increase or | ||
decrease. | ||
</p> | ||
</Accordion> | ||
); | ||
}; |
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