forked from binary-com/deriv-app
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Card component for responsive screens (binary-com#14390)
* fix: card component * fix: change moment to dayjs, address comments * fix: comments * fix: package-lock.json update * fix: formatDate type update
- Loading branch information
1 parent
0506022
commit 6029392
Showing
7 changed files
with
92 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
47 changes: 47 additions & 0 deletions
47
packages/account-v2/src/pages/ConnectedApps/ConnectedAppsResponsive.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,47 @@ | ||
import React from 'react'; | ||
import { OauthApps } from '@deriv/api-types'; | ||
import { Button } from '@deriv-com/ui'; | ||
import { formatDate, getFormattedAppScopes } from '../../utils/connectedAppsUtils'; | ||
import { ConnectedAppsResponsiveColumn } from './ConnectedAppsResponsiveColumn'; | ||
|
||
type TConnectedAppsResponsive = { | ||
connectedApps: OauthApps; | ||
handleToggleModal: (appId: number) => void; | ||
}; | ||
|
||
export const ConnectedAppsResponsive = ({ connectedApps, handleToggleModal }: TConnectedAppsResponsive) => ( | ||
<div className='flex flex-col gap-8'> | ||
{connectedApps.map(connectedApp => ( | ||
<div className='bg-solid-grey-2 rounded-default p-16' key={connectedApp.app_id}> | ||
<div className='flex justify-between gap-16'> | ||
<ConnectedAppsResponsiveColumn description={connectedApp.name} title='Name' /> | ||
<ConnectedAppsResponsiveColumn | ||
description={connectedApp.last_used && formatDate(connectedApp.last_used)} | ||
style='w-80' | ||
title='Last Login' | ||
/> | ||
</div> | ||
<div className='flex justify-between gap-16'> | ||
<ConnectedAppsResponsiveColumn | ||
description={getFormattedAppScopes(connectedApp.scopes)} | ||
title='Permission' | ||
/> | ||
<div className='flex items-end'> | ||
<Button | ||
className='whitespace-nowrap' | ||
color='black' | ||
onClick={() => handleToggleModal(connectedApp.app_id)} | ||
rounded='sm' | ||
size='sm' | ||
textSize='sm' | ||
type='button' | ||
variant='outlined' | ||
> | ||
Revoke access | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
); |
17 changes: 17 additions & 0 deletions
17
packages/account-v2/src/pages/ConnectedApps/ConnectedAppsResponsiveColumn.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,17 @@ | ||
import React from 'react'; | ||
import { Text } from '@deriv-com/ui'; | ||
|
||
type TConnectedAppsResponsiveColumn = { | ||
description?: string | null; | ||
style?: string; | ||
title: string; | ||
}; | ||
|
||
export const ConnectedAppsResponsiveColumn = ({ description, style, title }: TConnectedAppsResponsiveColumn) => ( | ||
<div className={`flex flex-col gap-4 ${style}`}> | ||
<Text size='sm' weight='bold'> | ||
{title} | ||
</Text> | ||
<Text size='sm'>{description}</Text> | ||
</div> | ||
); |
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
import dayjs from 'dayjs'; | ||
|
||
export const getFormattedAppScopes = (scopes: string[] | undefined) => | ||
scopes?.map(scope => scope[0].toUpperCase() + scope.substring(1).toLowerCase()).join(', '); | ||
|
||
export const formatDate = (date: string) => dayjs(date).format('YYYY-MM-DD HH:mm:ss'); |