mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-09 15:45:12 +00:00
# Which Problems Are Solved Invalid formatting in the login codebase due to invalid prettier configuration # How the Problems Are Solved Fxed .prettierignore wildcards for login source files # Additional Changes Removed .prettierrc file because there is already a prettier.config.mjs file # Additional Context
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { timestampDate } from "@zitadel/client";
|
|
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
|
|
import { useState } from "react";
|
|
import { Alert } from "./alert";
|
|
import { SessionItem } from "./session-item";
|
|
import { Translated } from "./translated";
|
|
|
|
type Props = {
|
|
sessions: Session[];
|
|
requestId?: string;
|
|
};
|
|
|
|
export function SessionsList({ sessions, requestId }: Props) {
|
|
const [list, setList] = useState<Session[]>(sessions);
|
|
return sessions ? (
|
|
<div className="flex flex-col space-y-2">
|
|
{list
|
|
.filter((session) => session?.factors?.user?.loginName)
|
|
// sort by change date descending
|
|
.sort((a, b) => {
|
|
const dateA = a.changeDate ? timestampDate(a.changeDate).getTime() : 0;
|
|
const dateB = b.changeDate ? timestampDate(b.changeDate).getTime() : 0;
|
|
return dateB - dateA;
|
|
})
|
|
// TODO: add sorting to move invalid sessions to the bottom
|
|
.map((session, index) => {
|
|
return (
|
|
<SessionItem
|
|
session={session}
|
|
requestId={requestId}
|
|
reload={() => {
|
|
setList(list.filter((s) => s.id !== session.id));
|
|
}}
|
|
key={"session-" + index}
|
|
/>
|
|
);
|
|
})}
|
|
</div>
|
|
) : (
|
|
<Alert>
|
|
<Translated i18nKey="noResults" namespace="accounts" />
|
|
</Alert>
|
|
);
|
|
}
|