hezarfen_frontend
Clone
https://git.tahinli.com/Hezarfen/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import type { SchoolSettings } from "@/api/client"; |
| 2 | |
| 3 | export const DEFAULT_MAX_FILE_BYTES = 5 * 1024 * 1024; |
| 4 | |
| 5 | export function maxUploadBytes(settings: SchoolSettings | null | undefined): number { |
| 6 | return settings?.max_file_bytes ?? DEFAULT_MAX_FILE_BYTES; |
| 7 | } |
| 8 | |
| 9 | export function formatBytes(bytes: number): string { |
| 10 | if (bytes < 1024) return `${bytes} B`; |
| 11 | if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`; |
| 12 | return `${(bytes / 1024 / 1024).toFixed(1)} MB`; |
| 13 | } |