Skip to content

Commit

Permalink
refactor(app-router): fix layout, types
Browse files Browse the repository at this point in the history
  • Loading branch information
divyenduz committed Apr 19, 2024
1 parent 3d29f96 commit e2e7ed5
Show file tree
Hide file tree
Showing 29 changed files with 375 additions and 659 deletions.
155 changes: 0 additions & 155 deletions packages/next-js-app/app/BaseLayout.tsx

This file was deleted.

12 changes: 10 additions & 2 deletions packages/next-js-app/app/actions/getFeed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
'use server'

import { sql } from '@trackfootball/database'
import { FeedItemType } from 'app/dashboard/page'
import { Field, Post, User, sql } from '@trackfootball/database'
import { FeatureCollection, LineString } from '@turf/helpers'

export type FeedItemType = Post & {
geoJson: FeatureCollection<LineString>
sprints: Array<FeatureCollection<LineString>>
runs: Array<FeatureCollection<LineString>>
Field: Field
User: User
}

export async function getFeed(cursor: number = 0, limit: number = 3) {
const maxPostId = (
Expand Down
19 changes: 0 additions & 19 deletions packages/next-js-app/app/activity/layout.tsx

This file was deleted.

48 changes: 22 additions & 26 deletions packages/next-js-app/app/admin/add-field/AddField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,16 @@ export default function AddField({ posts }: Props) {
width: 140,
renderCell: (params) => {
return (
<Link legacyBehavior href={``}>
<a
onClick={() => {
const post = posts.find(
(post) => params.row.id === post.id
)
setPost(post!)
}}
>
{params.row.id}
</a>
</Link>
<Button
onClick={() => {
const post = posts.find(
(post) => params.row.id === post.id
)
setPost(post!)
}}
>
{params.row.id}
</Button>
)
},
},
Expand All @@ -192,18 +190,16 @@ export default function AddField({ posts }: Props) {
width: 140,
renderCell: (params) => {
return (
<Link legacyBehavior href={``}>
<a
onClick={() => {
const post = posts.find(
(post) => params.row.id === post.id
)
setPost(post!)
}}
>
{params.row.text}
</a>
</Link>
<Button
onClick={() => {
const post = posts.find(
(post) => params.row.id === post.id
)
setPost(post!)
}}
>
{params.row.text}
</Button>
)
},
},
Expand All @@ -228,10 +224,10 @@ export default function AddField({ posts }: Props) {
<div style={{ marginBottom: 30 }}></div>

<Link
legacyBehavior
href={`http://maps.google.com?q=${latitude},${longitude}&ll=${latitude},${longitude}&z=15`}
target="_blank"
>
<a target="_blank">Open in Google maps</a>
Open in Google maps
</Link>

<span
Expand Down
6 changes: 3 additions & 3 deletions packages/next-js-app/app/admin/add-field/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UserType, sql } from '@trackfootball/database'
import { Metadata, ResolvingMetadata } from 'next'
import { Metadata } from 'next'
import { MESSAGE_UNAUTHORIZED } from 'packages/auth/utils'
import { auth } from 'utils/auth'

Expand Down Expand Up @@ -34,8 +34,8 @@ export default async function Activity() {
const posts = await getPostsWithoutFields()

return (
<>
<div className="w-full max-w-4xl">
<AddField posts={posts}></AddField>
</>
</div>
)
}
50 changes: 24 additions & 26 deletions packages/next-js-app/app/admin/edit-field/EditField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,17 @@ export default async function EditField({ fields }: Props) {
width: 140,
renderCell: (params) => {
return (
<Link legacyBehavior href={``}>
<a
onClick={() => {
const field = fields.find(
(field) => params.row.id === field.id
)
setField(field!)
setImmutableField(field!)
}}
>
{params.row.id}
</a>
<Link
href=""
onClick={() => {
const field = fields.find(
(field) => params.row.id === field.id
)
setField(field!)
setImmutableField(field!)
}}
>
{params.row.id}
</Link>
)
},
Expand All @@ -151,18 +150,17 @@ export default async function EditField({ fields }: Props) {
width: 140,
renderCell: (params) => {
return (
<Link legacyBehavior href={``}>
<a
onClick={() => {
const field = fields.find(
(field) => params.row.id === field.id
)
setField(field!)
setImmutableField(field!)
}}
>
{params.row.name}
</a>
<Link
href=""
onClick={() => {
const field = fields.find(
(field) => params.row.id === field.id
)
setField(field!)
setImmutableField(field!)
}}
>
{params.row.name}
</Link>
)
},
Expand Down Expand Up @@ -240,10 +238,10 @@ export default async function EditField({ fields }: Props) {
<div style={{ marginBottom: 30 }}></div>

<Link
legacyBehavior
href={`http://maps.google.com?q=${latitude},${longitude}&ll=${latitude},${longitude}&z=15`}
target="_blank"
>
<a target="_blank">Open in Google maps</a>
Open in Google maps
</Link>

<span
Expand Down
6 changes: 2 additions & 4 deletions packages/next-js-app/app/admin/edit-field/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client'

import { UserType, sql } from '@trackfootball/database'
import { MESSAGE_UNAUTHORIZED } from 'packages/auth/utils'
import { auth } from 'utils/auth'
Expand Down Expand Up @@ -33,8 +31,8 @@ export default async function Activity() {
const fields = await getFields()

return (
<>
<div className="w-full max-w-4xl">
<EditField fields={fields}></EditField>
</>
</div>
)
}
19 changes: 0 additions & 19 deletions packages/next-js-app/app/admin/layout.tsx

This file was deleted.

Loading

0 comments on commit e2e7ed5

Please sign in to comment.