Skip to content

Commit

Permalink
fix: test credential path (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleythedeveloper authored Dec 3, 2024
1 parent 4080c27 commit 82a586d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ services:
- /app/node_modules

untp-playground:
build: packages/untp-playground
build:
context: packages/untp-playground
ports:
- '4000:3000'
volumes:
Expand Down
26 changes: 16 additions & 10 deletions packages/untp-playground/src/components/DownloadCredential.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
"use client";
'use client';

import { Button } from "@/components/ui/button";
import { Download } from "lucide-react";
import { Button } from '@/components/ui/button';
import { Download } from 'lucide-react';

export function DownloadCredential() {
const assetPrefix = process.env.NEXT_PUBLIC_ASSET_PREFIX;

const testCredentialPath = `${assetPrefix ?? ''}/credentials/dpp.json`;
const fileName = 'untp-test-dpp-credential.json';
const fileMimeType = 'application/json';

const handleDownload = async () => {
try {
const response = await fetch("/credentials/dpp.json");
const response = await fetch(testCredentialPath);
const data = await response.json();

// Create and download file
const blob = new Blob([JSON.stringify(data, null, 2)], {
type: "application/json",
type: fileMimeType,
});
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
const a = document.createElement('a');
a.href = url;
a.download = "untp-test-dpp-credential.json";
a.download = fileName;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
} catch (error) {
console.log("Error downloading credential:", error);
console.log('Error downloading credential:', error);
}
};

return (
<Button onClick={handleDownload} variant="outline">
<Download className="mr-2 h-4 w-4" />
<Button onClick={handleDownload} variant='outline'>
<Download className='mr-2 h-4 w-4' />
Download Test Credential
</Button>
);
Expand Down

0 comments on commit 82a586d

Please sign in to comment.