feat: Mocked PinningProvider
This commit is contained in:
parent
5aa62f7d82
commit
52fc50d480
|
@ -4,10 +4,23 @@ import { SdkProvider } from "~/data/sdk-provider.js";
|
|||
export const fileProvider = {
|
||||
getList: () => {
|
||||
console.log("Not implemented");
|
||||
return Promise.resolve({
|
||||
data: [],
|
||||
total: 0,
|
||||
});
|
||||
return {
|
||||
data: [
|
||||
{
|
||||
name: "whirly-final-draft.psd",
|
||||
cid: "0xB45165ED3CD437B",
|
||||
size: "1.89 MB",
|
||||
createdOn: " 03/02/2024 at 13:29 PM",
|
||||
},
|
||||
{
|
||||
name: "whirly-final-draft.psd",
|
||||
cid: "0xB45165ED3CD437B",
|
||||
size: "1.89 MB",
|
||||
createdOn: " 03/02/2024 at 13:29 PM",
|
||||
},
|
||||
],
|
||||
total: 2
|
||||
}
|
||||
},
|
||||
getOne: () => {
|
||||
console.log("Not implemented");
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
import { SdkProvider } from "~/data/sdk-provider.js";
|
||||
import { PinningProcess } from "./pinning";
|
||||
|
||||
export const pinningProvider = {
|
||||
getList: () => {
|
||||
console.log("Not implemented");
|
||||
return {
|
||||
data: [],
|
||||
total: 0,
|
||||
};
|
||||
},
|
||||
getOne: () => {
|
||||
console.log("Not implemented");
|
||||
return Promise.resolve({
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
});
|
||||
},
|
||||
update: () => {
|
||||
console.log("Not implemented");
|
||||
return Promise.resolve({
|
||||
data: {},
|
||||
});
|
||||
},
|
||||
create: () => {
|
||||
console.log("Not implemented");
|
||||
return Promise.resolve({
|
||||
data: {},
|
||||
});
|
||||
},
|
||||
deleteOne: () => {
|
||||
console.log("Not implemented");
|
||||
return Promise.resolve({
|
||||
data: {},
|
||||
});
|
||||
},
|
||||
getApiUrl: () => "",
|
||||
custom: () => {
|
||||
|
||||
const pinCid = async (cid: string) => {
|
||||
return await PinningProcess.pin(cid);
|
||||
}
|
||||
|
||||
const unpinCid = async (cid: string) => {
|
||||
console.log("Not Implemented");
|
||||
}
|
||||
|
||||
const checkCid = async (cid: string) => {
|
||||
console.log("Not Implemented");
|
||||
}
|
||||
|
||||
const checkCidProgress = (cid: string) => {
|
||||
const progressGenerator = PinningProcess.pollProgress(cid);
|
||||
|
||||
return progressGenerator.next();
|
||||
}
|
||||
|
||||
return {
|
||||
pinCid,
|
||||
unpinCid,
|
||||
checkCid,
|
||||
checkCidProgress
|
||||
}
|
||||
},
|
||||
} satisfies SdkProvider;
|
|
@ -5,7 +5,7 @@ interface PinningStatus {
|
|||
}
|
||||
|
||||
// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
|
||||
class PinningProcess {
|
||||
export class PinningProcess {
|
||||
private static instances: Map<string, PinningStatus> = new Map();
|
||||
|
||||
static async pin(id: string): Promise<{ success: boolean; message: string }> {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import type {AuthProvider, DataProvider} from "@refinedev/core";
|
||||
import type {AuthProvider} from "@refinedev/core";
|
||||
import {fileProvider} from "~/data/file-provider.js";
|
||||
import {Sdk} from "@lumeweb/portal-sdk";
|
||||
import {accountProvider} from "~/data/account-provider.js";
|
||||
import type {SdkProvider} from "~/data/sdk-provider.js";
|
||||
import {createPortalAuthProvider} from "~/data/auth-provider.js";
|
||||
import { pinningProvider } from "./pinning-provider";
|
||||
|
||||
interface DataProviders {
|
||||
default: SdkProvider;
|
||||
auth: AuthProvider;
|
||||
|
||||
[key: string]: SdkProvider | AuthProvider;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ export function getProviders(sdk: Sdk) {
|
|||
default: accountProvider,
|
||||
auth: createPortalAuthProvider(sdk),
|
||||
files: fileProvider,
|
||||
pinning: pinningProvider
|
||||
};
|
||||
|
||||
return providers;
|
||||
|
|
|
@ -38,6 +38,7 @@ export function Layout({children}: { children: React.ReactNode }) {
|
|||
}
|
||||
|
||||
export default function App() {
|
||||
console.log(import.meta.env.VITE_PORTAL_URL);
|
||||
const sdk = Sdk.create(import.meta.env.VITE_PORTAL_URL)
|
||||
const providers = getProviders(sdk);
|
||||
return (
|
||||
|
@ -45,7 +46,10 @@ export default function App() {
|
|||
authProvider={providers.auth}
|
||||
routerProvider={routerProvider}
|
||||
notificationProvider={notificationProvider}
|
||||
dataProvider={providers.default}
|
||||
dataProvider={{
|
||||
default: providers.default,
|
||||
pinning: providers.pinning
|
||||
}}
|
||||
resources={resources}
|
||||
options={{disableTelemetry: true}}
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue