-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/feat/privCred-presentation' in…
…to feat/privCred-presentation
- Loading branch information
Showing
12 changed files
with
159 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { StoryDefault } from "@ladle/react" | ||
import { CredentialDetailsRoute } from "./routes/credential-details" | ||
import { CredentialsRoute } from "./routes/credentials" | ||
|
||
export const Credentials = () => <CredentialsRoute /> | ||
|
||
export const CredentialDetails = () => <CredentialDetailsRoute /> | ||
|
||
export default { | ||
title: "Credentials", | ||
} satisfies StoryDefault |
29 changes: 29 additions & 0 deletions
29
packages/features/src/credentials/routes/credential-details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { type CredentialId, useVault } from "@palladco/vault" | ||
import { useNavigate, useParams } from "react-router" | ||
import { CredentialDetailsView } from "../views/credential-details" | ||
|
||
export const CredentialDetailsRoute = () => { | ||
const navigate = useNavigate() | ||
const { id } = useParams() | ||
const credential = useVault((state) => | ||
JSON.stringify(state.getObject(id as CredentialId), null, "\t"), | ||
) | ||
const removeObject = useVault((state) => state.removeObject) | ||
const onCredentialDelete = () => { | ||
const result = window.confirm( | ||
"Are you sure you want to delete this credential?", | ||
) | ||
if (!result) return | ||
removeObject(id as CredentialId) | ||
return navigate("/credentials") | ||
} | ||
if (!id) return null | ||
return ( | ||
<CredentialDetailsView | ||
id={id} | ||
credential={credential} | ||
onGoBack={() => navigate("/credentials")} | ||
onDelete={onCredentialDelete} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { useVault } from "@palladco/vault" | ||
import { CredentialsView } from "../views/credentials" | ||
|
||
export const CredentialsRoute = () => { | ||
const credentials = useVault((store) => Object.entries(store.objects)) | ||
return <CredentialsView credentials={credentials} /> | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/features/src/credentials/views/credential-details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { AppLayout } from "@/components/app-layout" | ||
import { MenuBar } from "@/components/menu-bar" | ||
import { useTranslation } from "react-i18next" | ||
|
||
export type CredentialDetailsViewProps = { | ||
id: string | ||
credential: string | ||
onGoBack: () => void | ||
onDelete: () => void | ||
} | ||
|
||
export const CredentialDetailsView = ({ | ||
id, | ||
credential, | ||
onGoBack, | ||
onDelete, | ||
}: CredentialDetailsViewProps) => { | ||
const { t } = useTranslation() | ||
return ( | ||
<AppLayout> | ||
<MenuBar variant="back" onBackClicked={onGoBack} /> | ||
<section className="flex flex-col flex-1 justify-between px-8 pb-8 gap-8"> | ||
<h1 className="text-3xl w-full">{id}</h1> | ||
<div className="break-all flex-1 p-4 bg-secondary rounded-xl whitespace-pre-wrap overflow-y-scroll"> | ||
{credential} | ||
</div> | ||
<button type="button" className="btn btn-error" onClick={onDelete}> | ||
{t("credentials.delete")} | ||
</button> | ||
</section> | ||
</AppLayout> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { AppLayout } from "@/components/app-layout" | ||
import { MenuBar } from "@/components/menu-bar" | ||
import type { Json } from "@mina-js/utils" | ||
import { KeyRound } from "lucide-react" | ||
import { useTranslation } from "react-i18next" | ||
import { Link } from "react-router-dom" | ||
|
||
type CredentialsViewProps = { | ||
credentials: [string, Json][] | ||
} | ||
|
||
export const CredentialsView = ({ credentials }: CredentialsViewProps) => { | ||
const { t } = useTranslation() | ||
return ( | ||
<AppLayout> | ||
<MenuBar variant="dashboard" /> | ||
<section className="flex flex-col gap-4 px-8"> | ||
<h1 className="text-3xl w-full">{t("credentials.credentials")}</h1> | ||
<div className="flex flex-col gap-2"> | ||
{credentials.map(([id]) => ( | ||
<Link | ||
key={id} | ||
to={`/credentials/${id}`} | ||
className="p-4 flex items-center space-x-4 bg-secondary rounded-2xl" | ||
> | ||
<div className="flex items-center justify-center w-12 h-12 rounded-full bg-neutral"> | ||
<KeyRound /> | ||
</div> | ||
<div> | ||
<p>{id}</p> | ||
</div> | ||
</Link> | ||
))} | ||
</div> | ||
</section> | ||
</AppLayout> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters