mirror of
https://github.com/codex-storage/codex-marketplace-ui.git
synced 2025-02-23 21:28:26 +00:00
Clean the storage files
This commit is contained in:
parent
8ebb3c2801
commit
dc7cf3e30d
@ -9,7 +9,6 @@ import {
|
||||
} from "@codex-storage/marketplace-ui-components";
|
||||
import { Times } from "../../utils/times";
|
||||
import { CodexSdk } from "../../sdk/codex";
|
||||
import { AvailabilityStorage } from "../../utils/availabilities-storage";
|
||||
import { CodexAvailabilityCreateResponse } from "@codex-storage/sdk-js";
|
||||
|
||||
|
||||
@ -58,7 +57,7 @@ export function useAvailabilityMutation(
|
||||
WebStorage.delete("availability-step");
|
||||
|
||||
if (typeof res === "object" && body.name) {
|
||||
AvailabilityStorage.add(res.id, body.name)
|
||||
WebStorage.availabilities.add(res.id, body.name)
|
||||
}
|
||||
|
||||
setError(null);
|
||||
|
@ -5,8 +5,7 @@ import {
|
||||
WebFileIcon,
|
||||
} from "@codex-storage/marketplace-ui-components";
|
||||
import "./FileCell.css";
|
||||
import { FileMetadata, FilesStorage } from "../../utils/file-storage";
|
||||
import { PurchaseStorage } from "../../utils/purchases-storage";
|
||||
import { FileMetadata, WebStorage } from "../../utils/web-storage";
|
||||
|
||||
type Props = {
|
||||
requestId: string;
|
||||
@ -23,11 +22,11 @@ export function FileCell({ requestId, purchaseCid }: Props) {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
PurchaseStorage.get(requestId).then((cid) => {
|
||||
WebStorage.purchases.get(requestId).then((cid) => {
|
||||
if (cid) {
|
||||
setCid(cid);
|
||||
|
||||
FilesStorage.get<FileMetadata>(cid).then((data) => {
|
||||
WebStorage.files.get(cid).then((data) => {
|
||||
if (data) {
|
||||
setMetadata(data);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import { DownloadIcon, X } from "lucide-react";
|
||||
import { CodexSdk } from "../../sdk/codex";
|
||||
import { Files } from "../../utils/files";
|
||||
import { useEffect, useState } from "react";
|
||||
import { PurchaseStorage } from "../../utils/purchases-storage";
|
||||
import { WebStorage } from "../../utils/web-storage";
|
||||
|
||||
type Props = {
|
||||
details: CodexDataContent | null;
|
||||
@ -24,11 +24,15 @@ export function FileDetails({ onClose, details }: Props) {
|
||||
const [purchases, setPurchases] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
PurchaseStorage.entries().then((entries) =>
|
||||
setPurchases(
|
||||
entries.filter((e) => e[1] === details?.cid).reduce((acc) => acc + 1, 0)
|
||||
)
|
||||
);
|
||||
WebStorage.purchases
|
||||
.entries()
|
||||
.then((entries) =>
|
||||
setPurchases(
|
||||
entries
|
||||
.filter((e) => e[1] === details?.cid)
|
||||
.reduce((acc) => acc + 1, 0)
|
||||
)
|
||||
);
|
||||
}, [details?.cid]);
|
||||
|
||||
const url = CodexSdk.url() + "/api/codex/v1/data/";
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { ChangeEvent, useState } from "react";
|
||||
import "./UserInfo.css";
|
||||
import { OnBoardingUtils } from "../../utils/onboarding";
|
||||
import { Input } from "@codex-storage/marketplace-ui-components";
|
||||
import EmojiPicker, {
|
||||
EmojiClickData,
|
||||
EmojiStyle,
|
||||
Theme,
|
||||
} from "emoji-picker-react";
|
||||
import { WebStorage } from "../../utils/web-storage";
|
||||
|
||||
type Props = {
|
||||
onNameChange?: (value: string) => void;
|
||||
@ -14,14 +14,14 @@ type Props = {
|
||||
|
||||
export function UserInfo({ onNameChange }: Props) {
|
||||
const [displayName, setDisplayName] = useState(
|
||||
OnBoardingUtils.getDisplayName()
|
||||
WebStorage.onBoarding.getDisplayName()
|
||||
);
|
||||
const [emoji, setEmoji] = useState(OnBoardingUtils.getEmoji());
|
||||
const [emoji, setEmoji] = useState(WebStorage.onBoarding.getEmoji());
|
||||
const [areEmojiVisible, setAreEmojiVisible] = useState(false);
|
||||
|
||||
const onDisplayNameChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const value = e.currentTarget.value;
|
||||
OnBoardingUtils.setDisplayName(value);
|
||||
WebStorage.onBoarding.setDisplayName(value);
|
||||
setDisplayName(value);
|
||||
onNameChange?.(value);
|
||||
};
|
||||
@ -30,7 +30,7 @@ export function UserInfo({ onNameChange }: Props) {
|
||||
|
||||
const onEmojiClick = (emojiData: EmojiClickData) => {
|
||||
setEmoji(emojiData.emoji);
|
||||
OnBoardingUtils.setEmoji(emojiData.emoji);
|
||||
WebStorage.onBoarding.setEmoji(emojiData.emoji);
|
||||
setAreEmojiVisible(false);
|
||||
};
|
||||
|
||||
|
@ -7,8 +7,7 @@ import {
|
||||
UploadResponse,
|
||||
} from "@codex-storage/sdk-js";
|
||||
import { CodexSdk as Sdk } from "./sdk/codex";
|
||||
import { FilesStorage } from "./utils/file-storage";
|
||||
import { PurchaseStorage } from "./utils/purchases-storage";
|
||||
import { WebStorage } from "./utils/web-storage";
|
||||
|
||||
class CodexDataMock extends CodexData {
|
||||
override upload(
|
||||
@ -63,7 +62,7 @@ class CodexDataMock extends CodexData {
|
||||
abort,
|
||||
result: result.then((safe) => {
|
||||
if (!safe.error) {
|
||||
return FilesStorage.set(safe.data, {
|
||||
return WebStorage.files.set(safe.data, {
|
||||
mimetype: file.type,
|
||||
name: file.name,
|
||||
uploadedAt: new Date().toJSON(),
|
||||
@ -82,7 +81,7 @@ class CodexDataMock extends CodexData {
|
||||
return res;
|
||||
}
|
||||
|
||||
const metadata = await FilesStorage.list();
|
||||
const metadata = await WebStorage.files.list();
|
||||
|
||||
const content = res.data.content.map((content, index) => {
|
||||
if (content.manifest.filename) {
|
||||
@ -156,7 +155,7 @@ class CodexMarketplaceMock extends CodexMarketplace {
|
||||
return res
|
||||
}
|
||||
|
||||
await PurchaseStorage.set("0x" + res.data, input.cid)
|
||||
await WebStorage.purchases.set("0x" + res.data, input.cid)
|
||||
|
||||
// await PurchaseDatesStorage.set(res.data, new Date().toJSON())
|
||||
|
||||
|
@ -8,8 +8,6 @@
|
||||
|
||||
// This file is auto-generated by TanStack Router
|
||||
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
|
||||
// Import Routes
|
||||
|
||||
import { Route as rootRoute } from './routes/__root'
|
||||
@ -30,15 +28,10 @@ import { Route as DashboardFilesImport } from './routes/dashboard/files'
|
||||
import { Route as DashboardFavoritesImport } from './routes/dashboard/favorites'
|
||||
import { Route as DashboardDisclaimerImport } from './routes/dashboard/disclaimer'
|
||||
import { Route as DashboardDeviceImport } from './routes/dashboard/device'
|
||||
import { Route as DashboardAvailabilitiesImport } from './routes/dashboard/availabilities'
|
||||
import { Route as DashboardAnalyticsImport } from './routes/dashboard/analytics'
|
||||
import { Route as DashboardAboutImport } from './routes/dashboard/about'
|
||||
|
||||
// Create Virtual Routes
|
||||
|
||||
const DashboardAvailabilitiesLazyImport = createFileRoute(
|
||||
'/dashboard/availabilities',
|
||||
)()
|
||||
|
||||
// Create/Update Routes
|
||||
|
||||
const OnboardingNameRoute = OnboardingNameImport.update({
|
||||
@ -71,15 +64,6 @@ const DashboardIndexRoute = DashboardIndexImport.update({
|
||||
getParentRoute: () => DashboardRoute,
|
||||
} as any)
|
||||
|
||||
const DashboardAvailabilitiesLazyRoute =
|
||||
DashboardAvailabilitiesLazyImport.update({
|
||||
id: '/availabilities',
|
||||
path: '/availabilities',
|
||||
getParentRoute: () => DashboardRoute,
|
||||
} as any).lazy(() =>
|
||||
import('./routes/dashboard/availabilities.lazy').then((d) => d.Route),
|
||||
)
|
||||
|
||||
const DashboardWalletRoute = DashboardWalletImport.update({
|
||||
id: '/wallet',
|
||||
path: '/wallet',
|
||||
@ -152,6 +136,12 @@ const DashboardDeviceRoute = DashboardDeviceImport.update({
|
||||
getParentRoute: () => DashboardRoute,
|
||||
} as any)
|
||||
|
||||
const DashboardAvailabilitiesRoute = DashboardAvailabilitiesImport.update({
|
||||
id: '/availabilities',
|
||||
path: '/availabilities',
|
||||
getParentRoute: () => DashboardRoute,
|
||||
} as any)
|
||||
|
||||
const DashboardAnalyticsRoute = DashboardAnalyticsImport.update({
|
||||
id: '/analytics',
|
||||
path: '/analytics',
|
||||
@ -210,6 +200,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof DashboardAnalyticsImport
|
||||
parentRoute: typeof DashboardImport
|
||||
}
|
||||
'/dashboard/availabilities': {
|
||||
id: '/dashboard/availabilities'
|
||||
path: '/availabilities'
|
||||
fullPath: '/dashboard/availabilities'
|
||||
preLoaderRoute: typeof DashboardAvailabilitiesImport
|
||||
parentRoute: typeof DashboardImport
|
||||
}
|
||||
'/dashboard/device': {
|
||||
id: '/dashboard/device'
|
||||
path: '/device'
|
||||
@ -294,13 +291,6 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof DashboardWalletImport
|
||||
parentRoute: typeof DashboardImport
|
||||
}
|
||||
'/dashboard/availabilities': {
|
||||
id: '/dashboard/availabilities'
|
||||
path: '/availabilities'
|
||||
fullPath: '/dashboard/availabilities'
|
||||
preLoaderRoute: typeof DashboardAvailabilitiesLazyImport
|
||||
parentRoute: typeof DashboardImport
|
||||
}
|
||||
'/dashboard/': {
|
||||
id: '/dashboard/'
|
||||
path: '/'
|
||||
@ -316,6 +306,7 @@ declare module '@tanstack/react-router' {
|
||||
interface DashboardRouteChildren {
|
||||
DashboardAboutRoute: typeof DashboardAboutRoute
|
||||
DashboardAnalyticsRoute: typeof DashboardAnalyticsRoute
|
||||
DashboardAvailabilitiesRoute: typeof DashboardAvailabilitiesRoute
|
||||
DashboardDeviceRoute: typeof DashboardDeviceRoute
|
||||
DashboardDisclaimerRoute: typeof DashboardDisclaimerRoute
|
||||
DashboardFavoritesRoute: typeof DashboardFavoritesRoute
|
||||
@ -328,13 +319,13 @@ interface DashboardRouteChildren {
|
||||
DashboardRequestsRoute: typeof DashboardRequestsRoute
|
||||
DashboardSettingsRoute: typeof DashboardSettingsRoute
|
||||
DashboardWalletRoute: typeof DashboardWalletRoute
|
||||
DashboardAvailabilitiesLazyRoute: typeof DashboardAvailabilitiesLazyRoute
|
||||
DashboardIndexRoute: typeof DashboardIndexRoute
|
||||
}
|
||||
|
||||
const DashboardRouteChildren: DashboardRouteChildren = {
|
||||
DashboardAboutRoute: DashboardAboutRoute,
|
||||
DashboardAnalyticsRoute: DashboardAnalyticsRoute,
|
||||
DashboardAvailabilitiesRoute: DashboardAvailabilitiesRoute,
|
||||
DashboardDeviceRoute: DashboardDeviceRoute,
|
||||
DashboardDisclaimerRoute: DashboardDisclaimerRoute,
|
||||
DashboardFavoritesRoute: DashboardFavoritesRoute,
|
||||
@ -347,7 +338,6 @@ const DashboardRouteChildren: DashboardRouteChildren = {
|
||||
DashboardRequestsRoute: DashboardRequestsRoute,
|
||||
DashboardSettingsRoute: DashboardSettingsRoute,
|
||||
DashboardWalletRoute: DashboardWalletRoute,
|
||||
DashboardAvailabilitiesLazyRoute: DashboardAvailabilitiesLazyRoute,
|
||||
DashboardIndexRoute: DashboardIndexRoute,
|
||||
}
|
||||
|
||||
@ -362,6 +352,7 @@ export interface FileRoutesByFullPath {
|
||||
'/onboarding-name': typeof OnboardingNameRoute
|
||||
'/dashboard/about': typeof DashboardAboutRoute
|
||||
'/dashboard/analytics': typeof DashboardAnalyticsRoute
|
||||
'/dashboard/availabilities': typeof DashboardAvailabilitiesRoute
|
||||
'/dashboard/device': typeof DashboardDeviceRoute
|
||||
'/dashboard/disclaimer': typeof DashboardDisclaimerRoute
|
||||
'/dashboard/favorites': typeof DashboardFavoritesRoute
|
||||
@ -374,7 +365,6 @@ export interface FileRoutesByFullPath {
|
||||
'/dashboard/requests': typeof DashboardRequestsRoute
|
||||
'/dashboard/settings': typeof DashboardSettingsRoute
|
||||
'/dashboard/wallet': typeof DashboardWalletRoute
|
||||
'/dashboard/availabilities': typeof DashboardAvailabilitiesLazyRoute
|
||||
'/dashboard/': typeof DashboardIndexRoute
|
||||
}
|
||||
|
||||
@ -384,6 +374,7 @@ export interface FileRoutesByTo {
|
||||
'/onboarding-name': typeof OnboardingNameRoute
|
||||
'/dashboard/about': typeof DashboardAboutRoute
|
||||
'/dashboard/analytics': typeof DashboardAnalyticsRoute
|
||||
'/dashboard/availabilities': typeof DashboardAvailabilitiesRoute
|
||||
'/dashboard/device': typeof DashboardDeviceRoute
|
||||
'/dashboard/disclaimer': typeof DashboardDisclaimerRoute
|
||||
'/dashboard/favorites': typeof DashboardFavoritesRoute
|
||||
@ -396,7 +387,6 @@ export interface FileRoutesByTo {
|
||||
'/dashboard/requests': typeof DashboardRequestsRoute
|
||||
'/dashboard/settings': typeof DashboardSettingsRoute
|
||||
'/dashboard/wallet': typeof DashboardWalletRoute
|
||||
'/dashboard/availabilities': typeof DashboardAvailabilitiesLazyRoute
|
||||
'/dashboard': typeof DashboardIndexRoute
|
||||
}
|
||||
|
||||
@ -408,6 +398,7 @@ export interface FileRoutesById {
|
||||
'/onboarding-name': typeof OnboardingNameRoute
|
||||
'/dashboard/about': typeof DashboardAboutRoute
|
||||
'/dashboard/analytics': typeof DashboardAnalyticsRoute
|
||||
'/dashboard/availabilities': typeof DashboardAvailabilitiesRoute
|
||||
'/dashboard/device': typeof DashboardDeviceRoute
|
||||
'/dashboard/disclaimer': typeof DashboardDisclaimerRoute
|
||||
'/dashboard/favorites': typeof DashboardFavoritesRoute
|
||||
@ -420,7 +411,6 @@ export interface FileRoutesById {
|
||||
'/dashboard/requests': typeof DashboardRequestsRoute
|
||||
'/dashboard/settings': typeof DashboardSettingsRoute
|
||||
'/dashboard/wallet': typeof DashboardWalletRoute
|
||||
'/dashboard/availabilities': typeof DashboardAvailabilitiesLazyRoute
|
||||
'/dashboard/': typeof DashboardIndexRoute
|
||||
}
|
||||
|
||||
@ -433,6 +423,7 @@ export interface FileRouteTypes {
|
||||
| '/onboarding-name'
|
||||
| '/dashboard/about'
|
||||
| '/dashboard/analytics'
|
||||
| '/dashboard/availabilities'
|
||||
| '/dashboard/device'
|
||||
| '/dashboard/disclaimer'
|
||||
| '/dashboard/favorites'
|
||||
@ -445,7 +436,6 @@ export interface FileRouteTypes {
|
||||
| '/dashboard/requests'
|
||||
| '/dashboard/settings'
|
||||
| '/dashboard/wallet'
|
||||
| '/dashboard/availabilities'
|
||||
| '/dashboard/'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to:
|
||||
@ -454,6 +444,7 @@ export interface FileRouteTypes {
|
||||
| '/onboarding-name'
|
||||
| '/dashboard/about'
|
||||
| '/dashboard/analytics'
|
||||
| '/dashboard/availabilities'
|
||||
| '/dashboard/device'
|
||||
| '/dashboard/disclaimer'
|
||||
| '/dashboard/favorites'
|
||||
@ -466,7 +457,6 @@ export interface FileRouteTypes {
|
||||
| '/dashboard/requests'
|
||||
| '/dashboard/settings'
|
||||
| '/dashboard/wallet'
|
||||
| '/dashboard/availabilities'
|
||||
| '/dashboard'
|
||||
id:
|
||||
| '__root__'
|
||||
@ -476,6 +466,7 @@ export interface FileRouteTypes {
|
||||
| '/onboarding-name'
|
||||
| '/dashboard/about'
|
||||
| '/dashboard/analytics'
|
||||
| '/dashboard/availabilities'
|
||||
| '/dashboard/device'
|
||||
| '/dashboard/disclaimer'
|
||||
| '/dashboard/favorites'
|
||||
@ -488,7 +479,6 @@ export interface FileRouteTypes {
|
||||
| '/dashboard/requests'
|
||||
| '/dashboard/settings'
|
||||
| '/dashboard/wallet'
|
||||
| '/dashboard/availabilities'
|
||||
| '/dashboard/'
|
||||
fileRoutesById: FileRoutesById
|
||||
}
|
||||
@ -533,6 +523,7 @@ export const routeTree = rootRoute
|
||||
"children": [
|
||||
"/dashboard/about",
|
||||
"/dashboard/analytics",
|
||||
"/dashboard/availabilities",
|
||||
"/dashboard/device",
|
||||
"/dashboard/disclaimer",
|
||||
"/dashboard/favorites",
|
||||
@ -545,7 +536,6 @@ export const routeTree = rootRoute
|
||||
"/dashboard/requests",
|
||||
"/dashboard/settings",
|
||||
"/dashboard/wallet",
|
||||
"/dashboard/availabilities",
|
||||
"/dashboard/"
|
||||
]
|
||||
},
|
||||
@ -563,6 +553,10 @@ export const routeTree = rootRoute
|
||||
"filePath": "dashboard/analytics.tsx",
|
||||
"parent": "/dashboard"
|
||||
},
|
||||
"/dashboard/availabilities": {
|
||||
"filePath": "dashboard/availabilities.tsx",
|
||||
"parent": "/dashboard"
|
||||
},
|
||||
"/dashboard/device": {
|
||||
"filePath": "dashboard/device.tsx",
|
||||
"parent": "/dashboard"
|
||||
@ -611,10 +605,6 @@ export const routeTree = rootRoute
|
||||
"filePath": "dashboard/wallet.tsx",
|
||||
"parent": "/dashboard"
|
||||
},
|
||||
"/dashboard/availabilities": {
|
||||
"filePath": "dashboard/availabilities.lazy.tsx",
|
||||
"parent": "/dashboard"
|
||||
},
|
||||
"/dashboard/": {
|
||||
"filePath": "dashboard/index.tsx",
|
||||
"parent": "/dashboard"
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { createLazyFileRoute } from '@tanstack/react-router'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { ErrorBoundary } from '@sentry/react'
|
||||
import { ErrorPlaceholder } from '../../components/ErrorPlaceholder/ErrorPlaceholder'
|
||||
import {
|
||||
@ -16,8 +16,8 @@ import { PrettyBytes } from '../../utils/bytes'
|
||||
import { AvailabilitySunburst } from '../../components/Availability/AvailabilitySunburst'
|
||||
import { Errors } from '../../utils/errors'
|
||||
import { availabilityColors } from '../../components/Availability/availability.colors'
|
||||
import { AvailabilityStorage } from '../../utils/availabilities-storage'
|
||||
import { AvailabilityWithSlots } from '../../components/Availability/types'
|
||||
import { WebStorage } from '../../utils/web-storage'
|
||||
|
||||
const defaultSpace = {
|
||||
quotaMaxBytes: 0,
|
||||
@ -51,7 +51,7 @@ export function Availabilities() {
|
||||
return { ...a, slots: res.data }
|
||||
})
|
||||
.then((data) =>
|
||||
AvailabilityStorage.get(data.id).then((n) => ({
|
||||
WebStorage.availabilities.get(data.id).then((n) => ({
|
||||
...data,
|
||||
name: n || '',
|
||||
})),
|
||||
@ -160,7 +160,7 @@ export function Availabilities() {
|
||||
}
|
||||
}
|
||||
|
||||
export const Route = createLazyFileRoute('/dashboard/availabilities')({
|
||||
export const Route = createFileRoute('/dashboard/availabilities')({
|
||||
component: () => (
|
||||
<ErrorBoundary
|
||||
fallback={({ error }) => (
|
@ -8,9 +8,9 @@ import { ErrorBoundary } from "@sentry/react";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { Download } from "../../components/Download/Download.tsx";
|
||||
import { ManifestFetch } from "../../components/ManifestFetch/ManifestFetch.tsx";
|
||||
import { OnBoardingUtils } from "../../utils/onboarding.ts";
|
||||
import "./index.css";
|
||||
import { Versions } from "../../components/Versions/Versions.tsx";
|
||||
import { WebStorage } from "../../utils/web-storage.ts";
|
||||
|
||||
export const Route = createFileRoute("/dashboard/")({
|
||||
component: Dashboard,
|
||||
@ -23,9 +23,9 @@ function Dashboard() {
|
||||
queryClient.invalidateQueries({ queryKey: ["cids"] });
|
||||
};
|
||||
|
||||
const username = OnBoardingUtils.getDisplayName();
|
||||
const username = WebStorage.onBoarding.getDisplayName();
|
||||
|
||||
const emoji = OnBoardingUtils.getEmoji();
|
||||
const emoji = WebStorage.onBoarding.getEmoji();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { useState } from "react";
|
||||
import { AlphaIcon } from "../components/OnBoarding/AlphaIcon";
|
||||
import { OnBoardingUtils } from "../utils/onboarding";
|
||||
import { attributes } from "../utils/attributes";
|
||||
import { ArrowRightCircle } from "../components/ArrowRightCircle/ArrowRightCircle";
|
||||
import { OnBoardingLayout } from "../components/OnBoarding/OnBoardingLayout";
|
||||
import { HealthChecks } from "../components/HealthChecks/HealthChecks";
|
||||
import { useNetwork } from "../network/useNetwork";
|
||||
import { WebStorage } from "../utils/web-storage";
|
||||
|
||||
const OnBoardingChecks = () => {
|
||||
const online = useNetwork();
|
||||
const displayName = OnBoardingUtils.getDisplayName();
|
||||
const displayName = WebStorage.onBoarding.getDisplayName();
|
||||
const [isStepValid, setIsStepValid] = useState(false);
|
||||
const navigate = useNavigate({ from: "/onboarding-checks" });
|
||||
|
||||
|
@ -2,14 +2,14 @@ import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { useState } from "react";
|
||||
import { AlphaIcon } from "../components/OnBoarding/AlphaIcon";
|
||||
import { OnBoardingLayout } from "../components/OnBoarding/OnBoardingLayout";
|
||||
import { OnBoardingUtils } from "../utils/onboarding";
|
||||
import { attributes } from "../utils/attributes";
|
||||
import { ArrowRightCircle } from "../components/ArrowRightCircle/ArrowRightCircle";
|
||||
import { UserInfo } from "../components/UserInfo/UserInfo";
|
||||
import { WebStorage } from "../utils/web-storage";
|
||||
|
||||
const OnBoardingName = () => {
|
||||
const [isStepValid, setIsStepValid] = useState(
|
||||
!!OnBoardingUtils.getDisplayName()
|
||||
!!WebStorage.onBoarding.getDisplayName()
|
||||
);
|
||||
const navigate = useNavigate({ from: "/onboarding-name" });
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
import { createStore, del, get, set } from "idb-keyval";
|
||||
|
||||
const store = createStore("availabilities", "availabilities");
|
||||
|
||||
export const AvailabilityStorage = {
|
||||
get(key: string) {
|
||||
return get<string>(key, store);
|
||||
},
|
||||
|
||||
delete(key: string) {
|
||||
return del(key, store);
|
||||
},
|
||||
|
||||
async add(key: string, value: string) {
|
||||
return set(key, value, store);
|
||||
},
|
||||
};
|
@ -1,17 +0,0 @@
|
||||
import { createStore, del, keys, set } from "idb-keyval";
|
||||
|
||||
const store = createStore("favorites", "favorites");
|
||||
|
||||
export const FavoriteStorage = {
|
||||
list() {
|
||||
return keys<string>(store);
|
||||
},
|
||||
|
||||
delete(key: string) {
|
||||
return del(key, store);
|
||||
},
|
||||
|
||||
async add(key: string) {
|
||||
return set(key, "1", store);
|
||||
},
|
||||
};
|
@ -1,23 +0,0 @@
|
||||
import { createStore, entries, get, set } from "idb-keyval";
|
||||
|
||||
const store = createStore("files", "files");
|
||||
|
||||
export type FileMetadata = {
|
||||
mimetype: string;
|
||||
uploadedAt: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export const FilesStorage = {
|
||||
list() {
|
||||
return entries<string, FileMetadata>(store);
|
||||
},
|
||||
|
||||
async get<T>(cid: string) {
|
||||
return get<T>(cid, store);
|
||||
},
|
||||
|
||||
async set(cid: string, metadata: FileMetadata) {
|
||||
return set(cid, metadata, store);
|
||||
},
|
||||
};
|
@ -1,26 +0,0 @@
|
||||
|
||||
export const OnBoardingUtils = {
|
||||
getStep() {
|
||||
return parseInt(localStorage.getItem("onboarding-step") || "0", 10)
|
||||
},
|
||||
|
||||
setStep(step: number) {
|
||||
localStorage.setItem("onboarding-step", step.toString())
|
||||
},
|
||||
|
||||
setDisplayName(displayName: string) {
|
||||
localStorage.setItem("display-name", displayName)
|
||||
},
|
||||
|
||||
getDisplayName() {
|
||||
return localStorage.getItem("display-name") || ""
|
||||
},
|
||||
|
||||
setEmoji(emoji: string) {
|
||||
localStorage.setItem("emoji", emoji)
|
||||
},
|
||||
|
||||
getEmoji() {
|
||||
return localStorage.getItem("emoji") || "🤖"
|
||||
},
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
import { createStore, entries, get, set } from "idb-keyval";
|
||||
|
||||
const store = createStore("purchases", "purchases");
|
||||
const storeDates = createStore("purchases", "dates");
|
||||
|
||||
export const PurchaseStorage = {
|
||||
async get(key: string) {
|
||||
return get<string>(key, store);
|
||||
},
|
||||
|
||||
async set(key: string, cid: string) {
|
||||
return set(key, cid, store);
|
||||
},
|
||||
|
||||
async entries() {
|
||||
return entries(store);
|
||||
},
|
||||
};
|
||||
|
||||
export const PurchaseDatesStorage = {
|
||||
async get(key: string) {
|
||||
return get<string>(key, storeDates);
|
||||
},
|
||||
|
||||
async set(key: string, date: string) {
|
||||
return set(key, date, storeDates);
|
||||
},
|
||||
};
|
@ -1,6 +1,12 @@
|
||||
import { createStore, del, entries, get, set } from "idb-keyval";
|
||||
|
||||
const folders = createStore("folders", "folders");
|
||||
|
||||
export type FileMetadata = {
|
||||
mimetype: string;
|
||||
uploadedAt: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
|
||||
export const WebStorage = {
|
||||
set(key: string, value: unknown) {
|
||||
@ -15,13 +21,41 @@ export const WebStorage = {
|
||||
return del(key);
|
||||
},
|
||||
|
||||
onBoarding: {
|
||||
getStep() {
|
||||
return parseInt(localStorage.getItem("onboarding-step") || "0", 10)
|
||||
},
|
||||
|
||||
setStep(step: number) {
|
||||
localStorage.setItem("onboarding-step", step.toString())
|
||||
},
|
||||
|
||||
setDisplayName(displayName: string) {
|
||||
localStorage.setItem("display-name", displayName)
|
||||
},
|
||||
|
||||
getDisplayName() {
|
||||
return localStorage.getItem("display-name") || ""
|
||||
},
|
||||
|
||||
setEmoji(emoji: string) {
|
||||
localStorage.setItem("emoji", emoji)
|
||||
},
|
||||
|
||||
getEmoji() {
|
||||
return localStorage.getItem("emoji") || "🤖"
|
||||
},
|
||||
},
|
||||
|
||||
folders: {
|
||||
store: createStore("folders", "folders"),
|
||||
|
||||
create(folder: string) {
|
||||
return set(folder, [], folders);
|
||||
return set(folder, [], this.store);
|
||||
},
|
||||
|
||||
async list(): Promise<[string, string[]][]> {
|
||||
const items = await entries<string, string[]>(folders) || []
|
||||
const items = await entries<string, string[]>(this.store) || []
|
||||
|
||||
if (items.length == 0) {
|
||||
return [["Favorites", []]]
|
||||
@ -33,25 +67,82 @@ export const WebStorage = {
|
||||
|
||||
|
||||
return items
|
||||
|
||||
},
|
||||
|
||||
delete(key: string) {
|
||||
return del(key, folders);
|
||||
return del(key, this.store);
|
||||
},
|
||||
|
||||
|
||||
async addFile(folder: string, cid: string) {
|
||||
const files = await get<string[]>(folder, folders) || []
|
||||
const files = await get<string[]>(folder, this.store) || []
|
||||
|
||||
return set(folder, [...files, cid], folders)
|
||||
return set(folder, [...files, cid], this.store)
|
||||
},
|
||||
|
||||
async deleteFile(folder: string, cid: string) {
|
||||
const files = await get<string[]>(folder, folders) || []
|
||||
const files = await get<string[]>(folder, this.store) || []
|
||||
|
||||
return set(folder, files.filter(item => item !== cid), folders)
|
||||
return set(folder, files.filter(item => item !== cid), this.store)
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
availabilities: {
|
||||
store: createStore("availabilities", "availabilities"),
|
||||
|
||||
get(key: string) {
|
||||
return get<string>(key, this.store);
|
||||
},
|
||||
|
||||
delete(key: string) {
|
||||
return del(key, this.store);
|
||||
},
|
||||
|
||||
async add(key: string, value: string) {
|
||||
return set(key, value, this.store);
|
||||
},
|
||||
},
|
||||
|
||||
files: {
|
||||
store: createStore("files", "files"),
|
||||
|
||||
list() {
|
||||
return entries<string, FileMetadata>(this.store);
|
||||
},
|
||||
|
||||
async get(cid: string) {
|
||||
return get<FileMetadata>(cid, this.store);
|
||||
},
|
||||
|
||||
async set(cid: string, metadata: FileMetadata) {
|
||||
return set(cid, metadata, this.store);
|
||||
},
|
||||
},
|
||||
|
||||
purchases: {
|
||||
store: createStore("purchases", "purchases"),
|
||||
|
||||
|
||||
async get(key: string) {
|
||||
return get<string>(key, this.store);
|
||||
},
|
||||
|
||||
async set(key: string, cid: string) {
|
||||
return set(key, cid, this.store);
|
||||
},
|
||||
|
||||
async entries() {
|
||||
return entries(this.store);
|
||||
},
|
||||
|
||||
dates: {
|
||||
store: createStore("purchases", "dates"),
|
||||
|
||||
async get(key: string) {
|
||||
return get<string>(key, this.store);
|
||||
},
|
||||
|
||||
async set(key: string, date: string) {
|
||||
return set(key, date, this.store);
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -17,6 +17,7 @@ export default defineConfig({
|
||||
"@sentry/react": ["@sentry/react"],
|
||||
"emoji-picker-react": ["emoji-picker-react"],
|
||||
"dotted-map": ["dotted-map"],
|
||||
"echarts": ["echarts"],
|
||||
}
|
||||
},
|
||||
onwarn(warning, defaultHandler) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user