mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 23:15:36 +00:00
refactor: create types instead of using models
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import type Collection from '#models/collection';
|
||||
import { createContext } from 'react';
|
||||
import { CollectionWithLinks } from '~/types/app';
|
||||
|
||||
type ActiveCollectionContextType = {
|
||||
activeCollection: Collection | null;
|
||||
setActiveCollection: (collection: Collection) => void;
|
||||
activeCollection: CollectionWithLinks | null;
|
||||
setActiveCollection: (collection: CollectionWithLinks) => void;
|
||||
};
|
||||
|
||||
const iActiveCollectionContextState: ActiveCollectionContextType = {
|
||||
activeCollection: null,
|
||||
setActiveCollection: (_: Collection) => {},
|
||||
setActiveCollection: (_: CollectionWithLinks) => {},
|
||||
};
|
||||
|
||||
export const ActiveCollectionContext =
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import Collection from '#models/collection';
|
||||
import { createContext } from 'react';
|
||||
import { CollectionWithLinks } from '~/types/app';
|
||||
|
||||
type CollectionsContextType = {
|
||||
collections: Collection[];
|
||||
setCollections: (collections: Collection[]) => void | Collection[];
|
||||
collections: CollectionWithLinks[];
|
||||
setCollections: (
|
||||
collections: CollectionWithLinks[]
|
||||
) => void | CollectionWithLinks[];
|
||||
};
|
||||
|
||||
const iCollectionsContextState: CollectionsContextType = {
|
||||
collections: [] as Collection[],
|
||||
setCollections: (_: Collection[]) => {},
|
||||
collections: [] as CollectionWithLinks[],
|
||||
setCollections: (_: CollectionWithLinks[]) => {},
|
||||
};
|
||||
|
||||
const CollectionsContext = createContext<CollectionsContextType>(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type Link from '#models/link';
|
||||
import { createContext } from 'react';
|
||||
import { Link } from '~/types/app';
|
||||
|
||||
type FavoritesContextType = {
|
||||
favorites: Link[];
|
||||
|
||||
Reference in New Issue
Block a user