Skip to content

Commit

Permalink
custom utils function to display human-readable filesizes
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaramakrishna99 committed Dec 10, 2024
1 parent 27ce2b0 commit 85086bc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drc-portals/app/data/c2m2/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Metadata } from "next";
import CryptoJS from 'crypto-js';
import SQL from '@/lib/prisma/raw';
import { z } from 'zod';
import {filesize} from 'filesize';


export interface MetadataItem {
Expand Down Expand Up @@ -560,9 +561,6 @@ export function getNameFromFileProjTable(iconKey: string): string {






export function addCategoryColumns(
columns: Record<string, ReactNode | string | bigint>,
getNameFunction: (key: string) => string,
Expand Down Expand Up @@ -656,3 +654,8 @@ export function sanitizeFilename(filename: string, repchar: string): string {
// repchar can be '__'
return filename.replace(invalidCharacters, repchar);
}

export function formatFileSize(bytes: number, locale = 'en-US') {
return filesize(bytes, { locale });
}

0 comments on commit 85086bc

Please sign in to comment.