1
1
'use client' ;
2
2
3
- < < << << < HEAD
4
3
import supabase from '../client' ;
5
4
import { ExhibitRow } from '../../types/types' ;
6
5
@@ -12,25 +11,10 @@ export async function fetchAllExhibits(): Promise<ExhibitRow[]> {
12
11
const { data, error } = await supabase . from ( 'exhibits' ) . select ( '*' ) ;
13
12
if ( error ) {
14
13
throw new Error ( error . message ) ;
15
- = === ===
16
- import { ExhibitRow } from '../../types/types' ;
17
-
18
- /**
19
- * Fetches all tours from the database.
20
- * @returns A promise that resolves to an array of ExhibitRow objects.
21
- */
22
- export async function fetchAllExhibits ( ) : Promise < ExhibitRow [ ] > {
23
- const { data, error } = await supabase . from ( 'exhibits' ) . select ( '*' ) ;
24
- if ( error ) {
25
- throw new Error ( `An error occurred trying to read exhibits: ${ error } ` ) ;
26
- > >>> >>> b191485 ( added database and page )
27
14
}
28
15
return data ;
29
16
}
30
17
31
- < < << << < HEAD
32
-
33
-
34
18
/**
35
19
* Fetches a single exhibit from the database.
36
20
* @param exhibitId - The id of the exhibit to fetch.
@@ -52,29 +36,35 @@ export async function fetchExhibit(exhibitId: string): Promise<ExhibitRow> {
52
36
* @param exhibitId - The id of the exhibit to fetch.
53
37
* @returns A promise that resolves to a ExhibitRow object.
54
38
*/
55
- export async function fetchExhibitImage ( exhibitId : string ) : Promise < { image : string } > {
56
- const { data, error } = await supabase
57
- . from ( 'exhibits' )
58
- . select ( 'image' )
59
- . eq ( 'id' , exhibitId )
60
- . single ( ) ;
39
+ export async function fetchExhibitImage (
40
+ exhibitId : string ,
41
+ ) : Promise < { image : string } > {
42
+ const { data, error } = await supabase
43
+ . from ( 'exhibits' )
44
+ . select ( 'image' )
45
+ . eq ( 'id' , exhibitId )
46
+ . single ( ) ;
61
47
62
- if ( error ) {
63
- throw new Error ( error . message ) ;
64
- }
48
+ if ( error ) {
49
+ throw new Error ( error . message ) ;
50
+ }
65
51
66
- // Provide a default image URL if the image is null
67
- const imageUrl = data ?. image ?? "https://buffer.com/cdn-cgi/image/w=1000,fit=contain,q=90,f=auto/library/content/images/size/w1200/2023/10/free-images.jpg" ; // Adjust the default image path as needed
52
+ // Provide a default image URL if the image is null
53
+ const imageUrl =
54
+ data ?. image ??
55
+ 'https://buffer.com/cdn-cgi/image/w=1000,fit=contain,q=90,f=auto/library/content/images/size/w1200/2023/10/free-images.jpg' ; // Adjust the default image path as needed
68
56
69
- return { image : imageUrl } ;
57
+ return { image : imageUrl } ;
70
58
}
71
59
72
60
/**
73
61
* Inserts a single exhibit into the database.
74
62
* @param exhibitData - The exhibit to insert.
75
63
* @returns A promise that resolves to a ExhibitRow object.
76
64
*/
77
- export async function insertExhibit ( exhibitData : ExhibitRow ) : Promise < ExhibitRow | null > {
65
+ export async function insertExhibit (
66
+ exhibitData : ExhibitRow ,
67
+ ) : Promise < ExhibitRow | null > {
78
68
const { data, error } = await supabase . from ( 'exhibits' ) . insert ( exhibitData ) ;
79
69
if ( error ) {
80
70
throw new Error ( error . message ) ;
@@ -88,7 +78,7 @@ export async function insertExhibit(exhibitData: ExhibitRow): Promise<ExhibitRow
88
78
* @returns A promise that resolves to a ExhibitRow object.
89
79
*/
90
80
export async function updateExhibit (
91
- newExhibitData : ExhibitRow ,
81
+ newExhibitData : ExhibitRow ,
92
82
) : Promise < ExhibitRow | null > {
93
83
const { data, error } = await supabase
94
84
. from ( 'exhibits' )
@@ -105,54 +95,9 @@ export async function updateExhibit(
105
95
* @param exhibitData - The exhibit to upsert.
106
96
* @returns A promise that resolves to a ExhibitRow object.
107
97
*/
108
- export async function upsertTour ( exhibitData : ExhibitRow ) : Promise < ExhibitRow | null > {
109
- const { data, error } = await supabase . from ( 'exhibits' ) . upsert ( exhibitData ) ;
110
- if ( error ) {
111
- throw new Error ( error . message ) ;
112
- }
113
- return data ;
114
- }
115
-
116
- /**
117
- * Deletes a single exhibit from the database.
118
- * @param exhibitId - The id of the exhibit to delete.
119
- * @returns A promise that resolves to a ExhibitRow object.
120
- */
121
- export async function deleteExhibit ( exhibitId : string ) : Promise < ExhibitRow | null > {
122
- const { data, error } = await supabase
123
- . from ( 'exhibits' )
124
- . delete ( )
125
- . eq ( 'id' , exhibitId ) ;
126
- if ( error ) {
127
- throw new Error ( error . message ) ;
128
- }
129
- return data ;
130
- }
131
- = === ===
132
- /**
133
- * Updates a single exhibit in the database.
134
- * @param newExhibitData - The updated exhibit data.
135
- * @returns A promise that resolves to a ExhibitRow object.
136
- */
137
- export async function updateExhibit (
138
- newExhibitData : ExhibitRow ,
98
+ export async function upsertTour (
99
+ exhibitData : ExhibitRow ,
139
100
) : Promise < ExhibitRow | null > {
140
- const { data, error } = await supabase
141
- . from ( 'exhibits' )
142
- . update ( newExhibitData )
143
- . eq ( 'id' , newExhibitData . id ) ;
144
- if ( error ) {
145
- throw new Error ( error . message ) ;
146
- }
147
- return data ;
148
- }
149
-
150
- /**
151
- * Upserts a single exhibit into the database.
152
- * @param exhibitData - The exhibit to upsert.
153
- * @returns A promise that resolves to a ExhibitRow object.
154
- */
155
- export async function upsertTour ( exhibitData : ExhibitRow ) : Promise < ExhibitRow | null > {
156
101
const { data, error } = await supabase . from ( 'exhibits' ) . upsert ( exhibitData ) ;
157
102
if ( error ) {
158
103
throw new Error ( error . message ) ;
@@ -165,7 +110,9 @@ export async function upsertTour(exhibitData: ExhibitRow): Promise<ExhibitRow |
165
110
* @param exhibitId - The id of the exhibit to delete.
166
111
* @returns A promise that resolves to a ExhibitRow object.
167
112
*/
168
- export async function deleteExhibit ( exhibitId : string ) : Promise < ExhibitRow | null > {
113
+ export async function deleteExhibit (
114
+ exhibitId : string ,
115
+ ) : Promise < ExhibitRow | null > {
169
116
const { data, error } = await supabase
170
117
. from ( 'exhibits' )
171
118
. delete ( )
@@ -175,5 +122,3 @@ export async function deleteExhibit(exhibitId: string): Promise<ExhibitRow | nul
175
122
}
176
123
return data ;
177
124
}
178
-
179
- > >>> >>> b191485 ( added database and page )
0 commit comments