Skip to content

Commit

Permalink
refactor: Use models from cozy-client to compute storage data
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Nov 20, 2024
1 parent a29d62b commit 7778032
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 115 deletions.
10 changes: 7 additions & 3 deletions src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ContractIcon from 'cozy-ui/transpiled/react/Icons/Contract'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { useInstanceInfo } from 'cozy-client'
import JusticeIcon from 'cozy-ui/transpiled/react/Icons/Justice'
import { makeDiskInfos } from 'cozy-client/dist/models/instance'

import styles from 'components/Sidebar.styl'
import { MenuItemAnchor } from 'components/menu/MenuItemAnchor'
Expand All @@ -24,16 +25,19 @@ import { MenuItemNavLink } from 'components/menu/MenuItemNavLink'
import { MenuList } from 'components/menu/MenuList'
import { isFlagshipApp } from 'cozy-device-helper'
import { routes } from 'constants/routes'
import { useDiskPercentage } from 'hooks/useDiskPercentage'
import { useLogout } from 'hooks/useLogout'
import { SubscriptionMenuItem } from 'components/Subscription/SubscriptionMenuItem'

export const Sidebar = (): JSX.Element => {
const logout = useLogout()
const percent = useDiskPercentage()

const { t } = useI18n()

const { instance } = useInstanceInfo()
const { isLoaded, instance, diskUsage } = useInstanceInfo()

const percent = isLoaded
? makeDiskInfos(diskUsage.data.used, diskUsage.data.quota).percentUsage
: ''

return (
<nav role="navigation" className={styles.Sidebar}>
Expand Down
6 changes: 6 additions & 0 deletions src/declaration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'cozy-client/dist/models/instance' {
export function makeDiskInfos(
usage: number | string,
quota?: number | string
): import('cozy-client/types/models/instance').DiskInfos
}
38 changes: 0 additions & 38 deletions src/hooks/useDiskPercentage.ts

This file was deleted.

42 changes: 0 additions & 42 deletions src/lib/makeDiskInfos.spec.ts

This file was deleted.

32 changes: 0 additions & 32 deletions src/lib/makeDiskInfos.ts

This file was deleted.

0 comments on commit 7778032

Please sign in to comment.