spacedrive/interface/app/route-schemas.ts

48 lines
1.8 KiB
TypeScript
Raw Normal View History

import { z } from '@sd/ui/src/forms';
import i18n from './I18n';
export const SortOrderSchema = z.union([
z.literal('Asc').describe(i18n.t('ascending')),
z.literal('Desc').describe(i18n.t('descending'))
]);
export type SortOrder = z.infer<typeof SortOrderSchema>;
export const NodeIdParamsSchema = z.object({ id: z.string() });
export type NodeIdParams = z.infer<typeof NodeIdParamsSchema>;
export const LibraryIdParamsSchema = z.object({ libraryId: z.string().optional() });
export type LibraryIdParams = z.infer<typeof LibraryIdParamsSchema>;
export const LocationIdParamsSchema = z.object({ id: z.coerce.number() });
export type LocationIdParams = z.infer<typeof LocationIdParamsSchema>;
export const TagsSettingsParamsSchema = LocationIdParamsSchema.extend({
id: LocationIdParamsSchema.shape.id.optional()
});
export type TagsSettingsParams = z.infer<typeof TagsSettingsParamsSchema>;
export const PathParamsSchema = z.object({ path: z.string().optional() });
export type PathParams = z.infer<typeof PathParamsSchema>;
[ENG-1269] Search options (#1561) * search options start * small progress * more * bunch of stuff * semi functioning filters * cleanup setup api * progress * remove filters * hooked up to query epic moment * fix * move db stuff to specific modules * in/notIn for some fields * generate ts * big gains * working filter options for locations, tags and kind * working search query * perfect fixed filters * saved searches lol * merge error * saved searches via api * better routing * [ENG-1338] Fix fresh Spacedrive install failing to start due to attempting to query a nonexistent Library (#1649) Fix Spacedrive failing to start due to attempting to query a nonexistent Library - Rename useShoudRedirect to useRedirectToNewLocations - Improve behaviour for the immedite redirection after adding a new location * Show hidden files false by default (#1652) bool * fix remove filter in list * tweaks * fix nav buttons * unify MediaData search handling * cleanup saved search writing * Add left top bar portals for tags and search + fixed media view on tags * added search to filter dropdown * render cycle improvements * hotfix * wip * Refactor with Brendan, but this is a WIP and the search query no longer works Co-authored-by: Brendan Allan <Brendonovich@users.noreply.github.com> * progress * fix location/$id page * fix tags too Co-authored-by: Brendan Allan <Brendonovich@users.noreply.github.com> * 3rd refactor lol epic style * half-done with enum-ification of SearchFilterArgs * broken fixed filters but working inNotIn filters * search name + extension kinda working * hidden filter * fixed filters working?? * deferred search value * extensions works * filtered search items mostly working * tweaks * stacked approach working for non-search filters * move to Explorer/Search * actually use filterArgs in queries things actually work properly now * added new icons from Mint * goof * cleanup types, filters and mutation logic * actually use search value * remove overview from sidebar * don't shrink LibrariesDropdown ga * remove overview from sidebar and default to /network --------- Co-authored-by: Brendan Allan <brendonovich@outlook.com> Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com> Co-authored-by: Brendan Allan <Brendonovich@users.noreply.github.com>
2023-11-17 06:58:44 +00:00
export const SearchIdParamsSchema = z.object({ id: z.coerce.number() });
export type SearchIdParams = z.infer<typeof SearchIdParamsSchema>;
export const SearchParamsSchema = PathParamsSchema.extend({
// take: z.coerce.number().default(100),
// order: z
// .union([
// z.object({ field: z.literal('name'), value: SortOrderSchema }),
// z.object({ field: z.literal('dateCreated'), value: SortOrderSchema })
// // z.object({ field: z.literal('sizeInBytes'), value: SortOrderSchema })
// ])
// .optional(),
search: z.string().optional()
});
export type SearchParams = z.infer<typeof SearchParamsSchema>;
export const ExplorerParamsSchema = PathParamsSchema.extend({
take: z.coerce.number().default(100)
});
export type ExplorerParams = z.infer<typeof ExplorerParamsSchema>;