Skip to content

Commit

Permalink
prettier and errro boundayris
Browse files Browse the repository at this point in the history
  • Loading branch information
dinoDanic committed Mar 2, 2024
1 parent f4004cf commit 40c2ce6
Show file tree
Hide file tree
Showing 75 changed files with 707 additions and 746 deletions.
13 changes: 13 additions & 0 deletions apps/bible/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dist
node_modules
.next
build
.contentlayer
gql
storybook-static
storybook-static2
pnpm-lock.yaml
.storybook
.unlighthouse
.turbo
gql
2 changes: 1 addition & 1 deletion apps/bible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
- [ ] How to load \_templates, \_layouts?
- [ ] Components and Types have the same name
- [ ] PageParams types
- [ ] Error boundaryes
- [ ] Error boundaryes
18 changes: 8 additions & 10 deletions apps/bible/app/_templates/basic-list.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { Stack } from "@/components/primitives/stack";
import { Text } from "@/components/typography/text";
import { FC, PropsWithChildren } from "react";
import { Stack } from '@/components/primitives/stack'
import { Text } from '@/components/typography/text'
import { FC, PropsWithChildren } from 'react'

type Props = {
title: string;
} & PropsWithChildren;
title: string
} & PropsWithChildren

export const BasicList: FC<Props> = (props) => {
return (
<Stack>
<Text>{props.title}</Text>
<Stack className="max-h-[200px] rounded-lg overflow-scroll p-md border-4">
{props.children}
</Stack>
<Stack className="max-h-[200px] rounded-lg overflow-scroll p-md border-4">{props.children}</Stack>
</Stack>
);
};
)
}
25 changes: 11 additions & 14 deletions apps/bible/app/api/todo.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { api } from "@/site/api";
import { Todo } from "../todo/types";
import { api } from '@/site/api'
import { Todo } from '../todo/types'

export type GetTodosResponse = {
todos: Todo[];
};
todos: Todo[]
}

export const getTodos = async (
consoleMessage?: string,
init?: RequestInit,
): Promise<GetTodosResponse> => {
console.log("fatching todos" + " " + consoleMessage);
const resJSON = await fetch(`${api.route}/todos`, init);
console.log("fatching todos finished" + " " + consoleMessage);
const data = (await resJSON.json()) as GetTodosResponse;
return data;
};
export const getTodos = async (consoleMessage?: string, init?: RequestInit): Promise<GetTodosResponse> => {
console.log('fatching todos' + ' ' + consoleMessage)
const resJSON = await fetch(`${api.route}/todos`, init)
console.log('fatching todos finished' + ' ' + consoleMessage)
const data = (await resJSON.json()) as GetTodosResponse
return data
}
25 changes: 11 additions & 14 deletions apps/bible/app/api/users.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { api } from "@/site/api";
import { User } from "../user/types";
import { api } from '@/site/api'
import { User } from '../user/types'

export type GetUserResponse = {
users: User[];
};
users: User[]
}

export const getUsers = async (
consoleMessage?: string,
init?: RequestInit,
): Promise<GetUserResponse> => {
console.log("fatching users" + " " + consoleMessage);
const resJSON = await fetch(`${api.route}/users`, init);
console.log("fatching users finished" + " " + consoleMessage);
const data = (await resJSON.json()) as GetUserResponse;
return data;
};
export const getUsers = async (consoleMessage?: string, init?: RequestInit): Promise<GetUserResponse> => {
console.log('fatching users' + ' ' + consoleMessage)
const resJSON = await fetch(`${api.route}/users`, init)
console.log('fatching users finished' + ' ' + consoleMessage)
const data = (await resJSON.json()) as GetUserResponse
return data
}
25 changes: 11 additions & 14 deletions apps/bible/app/bible/components/bible-child.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
"use client";
'use client'

import { cn } from "@/lib/utils";
import { BibleContentChild } from "@/site/bible-contents";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { FC } from "react";
import { cn } from '@/lib/utils'
import { BibleContentChild } from '@/site/bible-contents'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import { FC } from 'react'

export const BibleChild: FC<BibleContentChild> = (child) => {
const segment = usePathname();
const isActive = segment?.includes(child.href);
const segment = usePathname()
const isActive = segment?.includes(child.href)
return (
<Link
href={child.href}
className={cn("text-muted-foreground", isActive && "text-primary")}
>
<Link href={child.href} className={cn('text-muted-foreground', isActive && 'text-primary')}>
{child.title}
</Link>
);
};
)
}
22 changes: 11 additions & 11 deletions apps/bible/app/bible/components/bible-side.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Stack } from "@/components/primitives/stack";
import { Text } from "@/components/typography/text";
import { BibleContent, bibleContents } from "@/site/bible-contents";
import { FC } from "react";
import { BibleChild } from "./bible-child";
import { Stack } from '@/components/primitives/stack'
import { Text } from '@/components/typography/text'
import { BibleContent, bibleContents } from '@/site/bible-contents'
import { FC } from 'react'
import { BibleChild } from './bible-child'

export const BibleSide = () => {
return (
Expand All @@ -11,8 +11,8 @@ export const BibleSide = () => {
<BibleContent key={bibleContent.title} {...bibleContent} />
))}
</Stack>
);
};
)
}

const BibleContent: FC<BibleContent> = (content) => {
const bibleChilds = (
Expand All @@ -21,14 +21,14 @@ const BibleContent: FC<BibleContent> = (content) => {
<BibleChild key={bibleChild.title} {...bibleChild} />
))}
</Stack>
);
)

const title = <Text>{content.title}</Text>;
const title = <Text>{content.title}</Text>

return (
<Stack gap="xs">
{title}
{bibleChilds}
</Stack>
);
};
)
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { getTodos } from "@/app/api/todo";
import { getUsers } from "@/app/api/users";
import { DisplayTodos } from "@/app/todos/components/display-todos";
import { DisplayUsers } from "@/app/user/components/display-users";
import { Stack } from "@/components/primitives/stack";
import { getTodos } from '@/app/api/todo'
import { getUsers } from '@/app/api/users'
import { DisplayTodos } from '@/app/todos/components/display-todos'
import { DisplayUsers } from '@/app/user/components/display-users'
import { Stack } from '@/components/primitives/stack'

export const ParrallelFetching = async () => {
const todosPromise = getTodos("parallel example");
const usersPromise = getUsers("parrallel example");
const [todos, users] = await Promise.all([todosPromise, usersPromise]);
const todosPromise = getTodos('parallel example')
const usersPromise = getUsers('parrallel example')
const [todos, users] = await Promise.all([todosPromise, usersPromise])

// One more sequential example
// const todos = await getTodos("good example");
Expand All @@ -18,5 +18,5 @@ export const ParrallelFetching = async () => {
<DisplayTodos todos={todos.todos} />
<DisplayUsers users={users.users} />
</Stack>
);
};
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ShowTodosWithUsers } from "@/app/todos/components/show-todos-with-users";
import { ShowTodosWithUsers } from '@/app/todos/components/show-todos-with-users'

export const SequentialFetching = () => {
return <ShowTodosWithUsers />;
};
return <ShowTodosWithUsers />
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Suspense } from "react";
import { ParrallelFetching } from "./components/parallel-fetching";
import { SequentialFetching } from "./components/sequential-fetching";
import { Suspense } from 'react'
import { ParrallelFetching } from './components/parallel-fetching'
import { SequentialFetching } from './components/sequential-fetching'

const ParrallelAndSequentialPage = () => {
return (
Expand All @@ -16,7 +16,7 @@ const ParrallelAndSequentialPage = () => {
</Suspense>
</div>
</div>
);
};
)
}

export default ParrallelAndSequentialPage;
export default ParrallelAndSequentialPage
15 changes: 6 additions & 9 deletions apps/bible/app/bible/layouts/basic-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { Stack } from "@/components/primitives/stack";
import { Text } from "@/components/typography/text";
import { FC, PropsWithChildren } from "react";
import { Stack } from '@/components/primitives/stack'
import { Text } from '@/components/typography/text'
import { FC, PropsWithChildren } from 'react'

export const BasicLayout: FC<{ title: string } & PropsWithChildren> = ({
title,
children,
}) => (
export const BasicLayout: FC<{ title: string } & PropsWithChildren> = ({ title, children }) => (
<Stack gap="xs" className="border-b py-sm">
<Text weight='medium'>{title}</Text>
<Text weight="medium">{title}</Text>
{children}
</Stack>
);
)
1 change: 1 addition & 0 deletions apps/bible/app/bible/project-structure/module/exmaple.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- everything should be exported from index.tsx

# bad

<todo. ... /> no cmp

# module/todo/index.tsx
Expand Down
14 changes: 7 additions & 7 deletions apps/bible/app/bible/project-structure/module/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Stack } from "@/components/primitives/stack";
import { Todo, todo } from "@/module/todo";
import { Stack } from '@/components/primitives/stack'
import { Todo, todo } from '@/module/todo'

const ProjectStructureModulePage = () => {
const todoProps: Todo = {
todo: "todo 1",
todo: 'todo 1',
id: 0,
userId: 0,
completed: false,
};
}
return (
<Stack>
<todo.components.TodoCard {...todoProps} />
<todo.components.FetchTodos />
{/* <todo.components.LargeImage /> */}
</Stack>
);
};
)
}

export default ProjectStructureModulePage;
export default ProjectStructureModulePage
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const TodoModalPage = () => {
<div>task by id page modal</div>;
};
;<div>task by id page modal</div>
}

export default TodoModalPage;
export default TodoModalPage
6 changes: 3 additions & 3 deletions apps/bible/app/bible/routing/intercepting-routes/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const InterceptingRoutes = () => {
return <div>hi</div>;
};
return <div>hi</div>
}

export default InterceptingRoutes;
export default InterceptingRoutes
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BasicLayout } from "@/app/bible/layouts/basic-layout"
import { Bridge } from "@/components/system/bridge"
import { ErrorBoundary } from "react-error-boundary"
import { BasicLayout } from '@/app/bible/layouts/basic-layout'
import { Bridge } from '@/components/system/bridge'
import { ErrorBoundary } from 'react-error-boundary'

const BridgePage = () => {
return (
<BasicLayout title="bridge">
<Bridge href="userById">user by id</Bridge>
</BasicLayout >
</BasicLayout>
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client"
'use client'

import { useEffect } from "react"
import { useEffect } from 'react'

export default function Error({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) {
useEffect(() => {
Expand Down
14 changes: 7 additions & 7 deletions apps/bible/app/bible/routing/nested-dynamic-routes/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Stack } from "@/components/primitives/stack"
import { resloveTodoIdRoute, routes, routesResolvers } from "@/site/routes"
import Link from "next/link"
import { BasicLayout } from "../../layouts/basic-layout"
import { Stack } from '@/components/primitives/stack'
import { resloveTodoIdRoute, routes, routesResolvers } from '@/site/routes'
import Link from 'next/link'
import { BasicLayout } from '../../layouts/basic-layout'

const NestedDynamicRoutesPage = () => {
return (
Expand All @@ -14,13 +14,13 @@ const NestedDynamicRoutesPage = () => {
<Link href="nested-dynamic-routes/todo/1">Todo #1</Link>
</BasicLayout>
<BasicLayout title="function / typesafe">
<Link href={routes.bible.routing.nestedDynamicRoutes.todo[":todo-id"]("2").index}>Todo #1</Link>
<Link href={routes.bible.routing.nestedDynamicRoutes.todo[':todo-id']('2').index}>Todo #1</Link>
</BasicLayout>
<BasicLayout title="resolver fn">
<Link href={resloveTodoIdRoute("2")}>Todo #1</Link>
<Link href={resloveTodoIdRoute('2')}>Todo #1</Link>
</BasicLayout>
<BasicLayout title="resolver object fn">
<Link href={routesResolvers.resloveTodoIdRoute("2")}>Todo #1</Link>
<Link href={routesResolvers.resloveTodoIdRoute('2')}>Todo #1</Link>
</BasicLayout>
</Stack>
)
Expand Down
Loading

0 comments on commit 40c2ce6

Please sign in to comment.