@@ -7,21 +7,21 @@ import type { QueryKey } from "@tanstack/react-query";
77import { useMutation , useQuery , useQueryClient } from "@tanstack/react-query" ;
88import { orpc } from "@/lib/orpc" ;
99
10- type Website = InferSelectModel < typeof websites > ;
11- type WebsitesListData = {
10+ export type Website = InferSelectModel < typeof websites > ;
11+ export type WebsitesListData = {
1212 websites : Website [ ] ;
1313 chartData : Record < string , ProcessedMiniChartData > ;
1414} ;
1515
16- const getWebsiteByIdKey = ( id : string ) : QueryKey =>
16+ export const getWebsiteByIdKey = ( id : string ) : QueryKey =>
1717 orpc . websites . getById . queryOptions ( { input : { id } } ) . queryKey ;
1818
19- const getWebsitesListKey = ( organizationId ?: string ) : QueryKey =>
19+ export const getWebsitesListKey = ( organizationId ?: string ) : QueryKey =>
2020 orpc . websites . listWithCharts . queryOptions ( {
2121 input : { organizationId } ,
2222 } ) . queryKey ;
2323
24- const updateWebsiteInList = (
24+ export const updateWebsiteInList = (
2525 old : WebsitesListData | undefined ,
2626 updatedWebsite : Website
2727) : WebsitesListData | undefined => {
@@ -118,7 +118,7 @@ export function useCreateWebsite() {
118118 } ) ;
119119}
120120
121- const updateWebsiteCache = (
121+ export const updateWebsiteCache = (
122122 queryClient : ReturnType < typeof useQueryClient > ,
123123 updatedWebsite : Website
124124) => {
@@ -129,9 +129,6 @@ const updateWebsiteCache = (
129129 updateWebsiteInList ( old , updatedWebsite )
130130 ) ;
131131 queryClient . setQueryData ( getByIdKey , updatedWebsite ) ;
132-
133- queryClient . invalidateQueries ( { queryKey : getByIdKey } ) ;
134- queryClient . invalidateQueries ( { queryKey : listKey } ) ;
135132} ;
136133
137134export function useUpdateWebsite ( ) {
@@ -147,19 +144,6 @@ export function useUpdateWebsite() {
147144 } ) ;
148145}
149146
150- export function useTogglePublicWebsite ( ) {
151- const queryClient = useQueryClient ( ) ;
152- return useMutation ( {
153- ...orpc . websites . togglePublic . mutationOptions ( ) ,
154- onSuccess : ( updatedWebsite : Website ) => {
155- updateWebsiteCache ( queryClient , updatedWebsite ) ;
156- } ,
157- onError : ( error ) => {
158- console . error ( "Failed to toggle website privacy:" , error ) ;
159- } ,
160- } ) ;
161- }
162-
163147export function useDeleteWebsite ( ) {
164148 const queryClient = useQueryClient ( ) ;
165149
0 commit comments