Files
supabase/apps/studio/components/interfaces/Organization/PrivateApps/Apps/Apps.utils.ts
kemal.earth a9a1326b92 feat(studio): private apps ui (#43382)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

This is a prototype for private apps UI. There are no endpoints at the
minute, just wanted to see what a potential flow could look like.
2026-03-23 10:51:04 -06:00

24 lines
728 B
TypeScript

import type { PrivateApp } from '../PrivateApps.types'
import type { AppsSort } from './Apps.types'
export function handleSortChange(
currentSort: AppsSort,
column: string,
setSort: (s: AppsSort) => void
) {
const [currentCol, currentOrder] = currentSort.split(':')
if (currentCol === column) {
setSort(`${column}:${currentOrder === 'asc' ? 'desc' : 'asc'}` as AppsSort)
} else {
setSort(`${column}:asc` as AppsSort)
}
}
export function sortApps(apps: PrivateApp[], sort: AppsSort): PrivateApp[] {
const [, order] = sort.split(':')
return [...apps].sort((a, b) => {
const diff = new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
return order === 'asc' ? diff : -diff
})
}