Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
SachiGoto committed Jan 8, 2024
2 parents c2b5b9b + 68596b7 commit d54e2d9
Show file tree
Hide file tree
Showing 19 changed files with 235 additions and 294 deletions.
6 changes: 3 additions & 3 deletions app/account/graphql/query/getUser.graphql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
query getUser($uuid: UUID!) {
usersCollection(filter: { uuid: { eq: $uuid } }) {
query getUser($id: UUID!) {
usersCollection(filter: { id: { eq: $id } }) {
edges {
node {
uuid
id
email
name
profile_picture_url
Expand Down
6 changes: 3 additions & 3 deletions app/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import { MdAccountCircle } from 'react-icons/md'
import { PrimaryButton, AlertButton } from '@/components/button'
import { Link } from '@/components/link'
import { Loading } from '@/components/loading'
import { useUserUuid } from '@/providers/session-provider'
import { useUserId } from '@/providers/session-provider'
import { useGetUserQuery } from '@generated/api'

export default function AccountPage() {
const bg = useColorModeValue('white', 'gray.800')
const color = useColorModeValue('black', 'gray.300')
const uuid = useUserUuid()
const userId = useUserId()
const { data, loading, error } = useGetUserQuery({
variables: { uuid }
variables: { id: userId }
})
const user = data?.usersCollection?.edges[0].node

Expand Down
5 changes: 2 additions & 3 deletions app/activity/[id]/graphql/query/activityCollection.graphql
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
query activityCollection($uuid: UUID!) {
activityCollection(filter: { uuid: { eq: $uuid } }) {
query activityCollection($id: UUID!) {
activityCollection(filter: { id: { eq: $id } }) {
edges {
node {
id
uuid
trip_id
title
time_from
Expand Down
2 changes: 1 addition & 1 deletion app/activity/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function ActivityDetails({

const { data, loading } = useActivityCollectionQuery({
variables: {
uuid: params.id
id: params.id
}
})

Expand Down
6 changes: 3 additions & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export default function RootLayout({
}: {
children: React.ReactNode
}) {
const uuid = cookies().get(USER_UUID_COOKIE_NAME)?.value ?? undefined
const userId = cookies().get(USER_UUID_COOKIE_NAME)?.value ?? undefined
return (
<html lang="en" className={roboto.className}>
<body>
<ChakraProvider>
<ApolloWrapper>
{uuid ? (
<SessionProvider uuid={uuid}>{children}</SessionProvider>
{userId ? (
<SessionProvider userId={userId}>{children}</SessionProvider>
) : (
children
)}
Expand Down
6 changes: 3 additions & 3 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useRouter } from 'next/navigation'
import { PrimaryButton } from '@/components/button'
import { Loading } from '@/components/loading'
import { Header, Footer } from '@/components/navigation'
import { useUserUuid } from '@/providers/session-provider'
import { useUserId } from '@/providers/session-provider'
import { TripSearch, TripSort, TripCard } from '@/trip/components'
import { useTripsCollectionQuery, TripsOrderBy } from '@generated/api'

Expand All @@ -23,12 +23,12 @@ export default function Top({ searchParams }: { searchParams: { q: string } }) {
const color = useColorModeValue('black', 'gray.300')

const searchWord = searchParams.q
const uuid = useUserUuid()
const userId = useUserId()

const { data, loading, fetchMore, refetch } = useTripsCollectionQuery({
variables: {
filter: {
uuid: { eq: uuid },
user_id: { eq: userId },
...(searchWord &&
searchWord.length && { title: { like: `%${searchWord}%` } })
},
Expand Down
14 changes: 7 additions & 7 deletions app/providers/session-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import { redirect } from 'next/navigation'

const SessionContext = createContext<string | undefined>(undefined)

export const useUserUuid = (): string => {
const uuid = useContext(SessionContext)
if (typeof uuid !== 'string') {
export const useUserId = (): string => {
const userId = useContext(SessionContext)
if (typeof userId !== 'string') {
redirect('/signin')
}
return uuid
return userId
}
export function SessionProvider({
children,
uuid
userId
}: {
children: ReactNode
uuid: string
userId: string
}) {
return (
<SessionContext.Provider value={uuid}>{children}</SessionContext.Provider>
<SessionContext.Provider value={userId}>{children}</SessionContext.Provider>
)
}
24 changes: 12 additions & 12 deletions app/trip/[id]/__test__/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const tripDetailsMock1 = [
request: {
query: TripDetailsDocument,
variables: {
uuid: 'trip-uuid-1'
id: 'trip-uuid-1'
}
},
result: {
Expand All @@ -15,7 +15,7 @@ export const tripDetailsMock1 = [
edges: [
{
node: {
uuid: 'trip-uuid-1',
id: 'trip-uuid-1',
image_storage_object_id: null,
title: 'Tokyo',
date_from: '2021-01-01',
Expand Down Expand Up @@ -52,7 +52,7 @@ export const tripDetailsMock1 = [
time_from: '2021-01-01T10:00:00+00:00',
time_to: '2021-01-01T11:00:00+00:00',
title: 'Activity 1',
uuid: 'abc1'
id: 'abc1'
}
},
{
Expand All @@ -61,7 +61,7 @@ export const tripDetailsMock1 = [
time_from: '2021-01-02T10:00:00+00:00',
time_to: '2021-01-02T11:00:00+00:00',
title: 'Activity 2',
uuid: 'abc2'
id: 'abc2'
}
},
{
Expand All @@ -70,7 +70,7 @@ export const tripDetailsMock1 = [
time_from: '2021-01-03T11:00:00+00:00',
time_to: '2021-01-03T12:00:00+00:00',
title: 'Activity 3',
uuid: 'abc3'
id: 'abc3'
}
},
{
Expand All @@ -79,7 +79,7 @@ export const tripDetailsMock1 = [
time_from: '2021-01-03T14:00:00+00:00',
time_to: '2021-01-03T08:00:00+00:00',
title: 'Activity 4',
uuid: 'abc4'
id: 'abc4'
}
}
]
Expand All @@ -99,7 +99,7 @@ export const tripDetailsMock2 = [
request: {
query: TripDetailsDocument,
variables: {
uuid: 'trip-uuid-2'
id: 'trip-uuid-2'
}
},
result: {
Expand All @@ -108,7 +108,7 @@ export const tripDetailsMock2 = [
edges: [
{
node: {
uuid: 'trip-uuid-2',
id: 'trip-uuid-2',
image_storage_object_id: null,
title: 'Tokyo',
date_from: '2021-01-01',
Expand Down Expand Up @@ -145,7 +145,7 @@ export const tripDetailsMock2 = [
time_from: '2021-01-01T10:00:00+00:00',
time_to: '2021-01-01T11:00:00+00:00',
title: 'Activity 1',
uuid: 'abc1'
id: 'abc1'
}
},
{
Expand All @@ -154,7 +154,7 @@ export const tripDetailsMock2 = [
time_from: '2021-01-01T12:00:00+00:00',
time_to: '2021-01-03T11:00:00+00:00',
title: 'Activity 2',
uuid: 'abc2'
id: 'abc2'
}
},
{
Expand All @@ -163,7 +163,7 @@ export const tripDetailsMock2 = [
time_from: '2021-01-03T11:00:00+00:00',
time_to: '2021-01-03T12:00:00+00:00',
title: 'Activity 3',
uuid: 'abc3'
id: 'abc3'
}
},
{
Expand All @@ -172,7 +172,7 @@ export const tripDetailsMock2 = [
time_from: '2021-01-03T14:00:00+00:00',
time_to: '2021-01-04T08:00:00+00:00',
title: 'Activity 4',
uuid: 'abc4'
id: 'abc4'
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions app/trip/[id]/__test__/trip-details-tabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('TripDetails Tabs', () => {
activities={
tripDetailsMock1[0].result.data.tripsCollection.edges[0].node.activityCollection?.edges.map(
(activity) => ({
id: activity.node.uuid,
id: activity.node.id,
timeFrom: activity.node.time_from,
timeTo: activity.node.time_to,
title: activity.node.title,
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('TripDetails Tabs', () => {
activities={
tripDetailsMock2[0].result.data.tripsCollection.edges[0].node.activityCollection?.edges.map(
(activity) => ({
id: activity.node.uuid,
id: activity.node.id,
timeFrom: activity.node.time_from,
timeTo: activity.node.time_to,
title: activity.node.title,
Expand Down
4 changes: 2 additions & 2 deletions app/trip/[id]/components/trip-details-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ type TripDetailsHeaderProps = {
dateFrom: string | null | undefined
dateTo: string | null | undefined
users: {
id: number | undefined
id: string | undefined
image: string | null | undefined
}[]

tags: { id: number | undefined; name: string | undefined }[]
tags: { id: string | undefined; name: string | undefined }[]
}

export const TripDetailsHeader = ({
Expand Down
6 changes: 3 additions & 3 deletions app/trip/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function TripDetailsPage({

const { data: tripData, loading: tripLoading } = useTripDetailsQuery({
variables: {
uuid: params.id
id: params.id
}
})

Expand All @@ -42,7 +42,7 @@ export default function TripDetailsPage({
) : (
<>
<TripDetailsHeader
id={tripDataCollection.edges[0].node.uuid}
id={tripDataCollection.edges[0].node.id}
image={tripDataCollection.edges[0].node.image_storage_object_id}
title={tripDataCollection.edges[0].node.title}
dateFrom={tripDataCollection.edges[0].node.date_from}
Expand All @@ -69,7 +69,7 @@ export default function TripDetailsPage({
activities={
tripDataCollection.edges[0].node.activityCollection?.edges.map(
(activity) => ({
id: activity.node.uuid,
id: activity.node.id,
timeFrom: activity.node.time_from,
timeTo: activity.node.time_to,
title: activity.node.title,
Expand Down
2 changes: 1 addition & 1 deletion app/trip/components/trip-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const TripCard = ({ data }: TripCardProps) => {
return (
<Card
as={NextLink}
href={`/trip/${data.node.uuid}`}
href={`/trip/${data.node.id}`}
role={'group'}
maxW={{ base: '100%', md: 'calc(100% / 2 - 10px)', lg: '360px' }}
pb={{ base: '12px', md: '0px' }}
Expand Down
3 changes: 1 addition & 2 deletions app/trip/graphql/mutation/createTrip.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mutation createTrip(
$user_id: BigInt!
$user_id: UUID!
$title: String!
$date_from: Date
$date_to: Date
Expand All @@ -17,7 +17,6 @@ mutation createTrip(
records {
__typename
id
uuid
title
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/trip/graphql/query/tripDetails.graphql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
query tripDetails($uuid: UUID!) {
tripsCollection(filter: { uuid: { eq: $uuid } }) {
query tripDetails($id: UUID!) {
tripsCollection(filter: { id: { eq: $id } }) {
edges {
node {
uuid
id
title
date_from
date_to
Expand All @@ -20,7 +20,7 @@ query tripDetails($uuid: UUID!) {
activityCollection {
edges {
node {
uuid
id
title
time_from
time_to
Expand Down
2 changes: 1 addition & 1 deletion app/trip/graphql/query/tripsCollection.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ query tripsCollection(
edges {
node {
id
uuid
id
title
date_from
date_to
Expand Down
Loading

0 comments on commit d54e2d9

Please sign in to comment.