-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into A1_sign_in_UI
- Loading branch information
Showing
31 changed files
with
1,419 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/activity/create/graphql/mutation/createActivity.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
mutation createActivity( | ||
$trip_id: UUID! | ||
$title: String! | ||
$time_from: Datetime | ||
$time_to: Datetime | ||
$address: String | ||
$url: String | ||
$memo: String | ||
$cost: BigFloat | ||
$cost_unit: String | ||
$image_url: String | ||
) { | ||
insertIntoactivityCollection( | ||
objects: [ | ||
{ | ||
trip_id: $trip_id | ||
title: $title | ||
time_from: $time_from | ||
time_to: $time_to | ||
address: $address | ||
url: $url | ||
memo: $memo | ||
cost: $cost | ||
cost_unit: $cost_unit | ||
image_url: $image_url | ||
} | ||
] | ||
) { | ||
records { | ||
__typename | ||
id | ||
title | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use server' | ||
import { createServerActionClient } from '@supabase/auth-helpers-nextjs' | ||
import { cookies } from 'next/headers' | ||
|
||
export const updateImageMetadataAction = async ( | ||
id: string, | ||
filePath: string | ||
): Promise< | ||
| { status: 'success'; data: { publicUrl: string } } | ||
| { status: 'error'; data: { publicUrl: string }; error: { message: string } } | ||
> => { | ||
try { | ||
const cookieStore = cookies() | ||
// NOTE: Use createServerActionClient instead of createClient in with-cookie.ts | ||
// https://supabase.com/docs/guides/auth/auth-helpers/nextjs?language=ts#server-actions | ||
const supabase = createServerActionClient({ cookies: () => cookieStore }) | ||
|
||
// Supabase Storage API is not available in the server action. | ||
// const { data: uploadData, error: uploadError } = await supabase.storage | ||
// .from('tabi-memo-uploads') | ||
// .upload(`trips/${id}/${file.name}`, file, { upsert: true }) | ||
|
||
// if (uploadError) throw uploadError | ||
|
||
const { | ||
data: { publicUrl } | ||
} = await supabase.storage | ||
.from(process.env.NEXT_PUBLIC_BUCKET_NAME!) | ||
.getPublicUrl(filePath) | ||
|
||
const updateResponse = await supabase | ||
.from('trips') | ||
.update({ image_url: publicUrl }) | ||
.match({ id }) | ||
|
||
if (updateResponse.error) { | ||
return { | ||
status: 'error', | ||
data: { publicUrl }, | ||
error: { message: updateResponse.error.message } | ||
} | ||
} | ||
|
||
return { status: 'success', data: { publicUrl } } | ||
} catch (error) { | ||
console.error({ error }) | ||
return { | ||
status: 'error', | ||
data: { publicUrl: '' }, | ||
error: { message: 'Failed to upload image' } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.