-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(appwrite): update appwrite examples with cloud (#6168)
- Loading branch information
Showing
30 changed files
with
726 additions
and
240 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,20 @@ import routerProvider, { | |
NavigateToResource, | ||
UnsavedChangesNotifier, | ||
} from "@refinedev/react-router-v6"; | ||
import { BrowserRouter, Outlet, Route, Routes } from "react-router-dom"; | ||
|
||
import "@refinedev/antd/dist/reset.css"; | ||
import { App as AntdApp, ConfigProvider } from "antd"; | ||
import { BrowserRouter, Outlet, Route, Routes } from "react-router-dom"; | ||
|
||
import { appwriteClient, authProvider } from "./utility"; | ||
|
||
import { PostCreate, PostEdit, PostList, PostShow } from "./pages/posts"; | ||
import { | ||
CategoryCreate, | ||
CategoryList, | ||
CategoryShow, | ||
CategoryEdit, | ||
} from "./pages/categories"; | ||
|
||
const App: React.FC = () => { | ||
return ( | ||
|
@@ -28,22 +36,32 @@ const App: React.FC = () => { | |
<AntdApp> | ||
<Refine | ||
dataProvider={dataProvider(appwriteClient, { | ||
databaseId: "6537bfaa2f54cd235e51", | ||
databaseId: "default", | ||
})} | ||
liveProvider={liveProvider(appwriteClient, { | ||
databaseId: "6537bfaa2f54cd235e51", | ||
databaseId: "default", | ||
})} | ||
authProvider={authProvider} | ||
routerProvider={routerProvider} | ||
resources={[ | ||
{ | ||
name: "6537bff1acea7f73acbf", | ||
name: "blog_posts", | ||
list: "/posts", | ||
create: "/posts/create", | ||
edit: "/posts/edit/:id", | ||
show: "/posts/show/:id", | ||
meta: { | ||
label: "Posts", | ||
label: "Blog Posts", | ||
}, | ||
}, | ||
{ | ||
name: "categories", | ||
list: "/categories", | ||
create: "/categories/create", | ||
show: "/categories/show/:id", | ||
edit: "/categories/edit/:id", | ||
meta: { | ||
label: "Categories", | ||
}, | ||
}, | ||
]} | ||
|
@@ -69,9 +87,7 @@ const App: React.FC = () => { | |
> | ||
<Route | ||
index | ||
element={ | ||
<NavigateToResource resource="6537bff1acea7f73acbf" /> | ||
} | ||
element={<NavigateToResource resource="blog_posts" />} | ||
/> | ||
|
||
<Route path="/posts"> | ||
|
@@ -80,22 +96,34 @@ const App: React.FC = () => { | |
<Route path="edit/:id" element={<PostEdit />} /> | ||
<Route path="show/:id" element={<PostShow />} /> | ||
</Route> | ||
<Route path="/categories"> | ||
<Route index element={<CategoryList />} /> | ||
<Route path="create" element={<CategoryCreate />} /> | ||
<Route path="edit/:id" element={<CategoryEdit />} /> | ||
<Route path="show/:id" element={<CategoryShow />} /> | ||
</Route> | ||
</Route> | ||
|
||
<Route | ||
element={ | ||
<Authenticated key="auth-pages" fallback={<Outlet />}> | ||
<NavigateToResource resource="6537bff1acea7f73acbf" /> | ||
<NavigateToResource resource="blog_posts" /> | ||
</Authenticated> | ||
} | ||
> | ||
<Route | ||
path="/login" | ||
element={<AuthPage forgotPasswordLink={false} />} | ||
/> | ||
<Route | ||
path="/register" | ||
element={<AuthPage type="register" />} | ||
element={ | ||
<AuthPage | ||
formProps={{ | ||
initialValues: { | ||
remember: false, | ||
email: "[email protected]", | ||
password: "demodemo", | ||
}, | ||
}} | ||
/> | ||
} | ||
/> | ||
</Route> | ||
|
||
|
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
31 changes: 31 additions & 0 deletions
31
examples/data-provider-appwrite-tutorial-docs/src/pages/categories/create.tsx
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,31 @@ | ||
import { Create, useForm } from "@refinedev/antd"; | ||
import { Form, Input } from "antd"; | ||
|
||
import type { HttpError } from "@refinedev/core"; | ||
import type { ICategory } from "../../interfaces"; | ||
|
||
export const CategoryCreate = () => { | ||
const { formProps, saveButtonProps } = useForm< | ||
ICategory, | ||
HttpError, | ||
ICategory | ||
>(); | ||
|
||
return ( | ||
<Create saveButtonProps={saveButtonProps}> | ||
<Form {...formProps} layout="vertical"> | ||
<Form.Item | ||
label="Title" | ||
name="title" | ||
rules={[ | ||
{ | ||
required: true, | ||
}, | ||
]} | ||
> | ||
<Input /> | ||
</Form.Item> | ||
</Form> | ||
</Create> | ||
); | ||
}; |
31 changes: 31 additions & 0 deletions
31
examples/data-provider-appwrite-tutorial-docs/src/pages/categories/edit.tsx
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,31 @@ | ||
import { Edit, useForm } from "@refinedev/antd"; | ||
import { Form, Input } from "antd"; | ||
|
||
import type { HttpError } from "@refinedev/core"; | ||
import type { ICategory } from "../../interfaces"; | ||
|
||
export const CategoryEdit = () => { | ||
const { formProps, saveButtonProps } = useForm< | ||
ICategory, | ||
HttpError, | ||
ICategory | ||
>({}); | ||
|
||
return ( | ||
<Edit saveButtonProps={saveButtonProps}> | ||
<Form {...formProps} layout="vertical"> | ||
<Form.Item | ||
label="Title" | ||
name="title" | ||
rules={[ | ||
{ | ||
required: true, | ||
}, | ||
]} | ||
> | ||
<Input /> | ||
</Form.Item> | ||
</Form> | ||
</Edit> | ||
); | ||
}; |
4 changes: 4 additions & 0 deletions
4
examples/data-provider-appwrite-tutorial-docs/src/pages/categories/index.tsx
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,4 @@ | ||
export * from "./list"; | ||
export * from "./show"; | ||
export * from "./create"; | ||
export * from "./edit"; |
22 changes: 22 additions & 0 deletions
22
examples/data-provider-appwrite-tutorial-docs/src/pages/categories/list.tsx
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,22 @@ | ||
import { List, useTable, getDefaultSortOrder } from "@refinedev/antd"; | ||
import { Table } from "antd"; | ||
|
||
import type { ICategory } from "../../interfaces"; | ||
|
||
export const CategoryList = () => { | ||
const { tableProps, sorters } = useTable<ICategory>(); | ||
|
||
return ( | ||
<List> | ||
<Table {...tableProps} rowKey="id"> | ||
<Table.Column<ICategory> | ||
dataIndex="id" | ||
title="ID" | ||
sorter | ||
defaultSortOrder={getDefaultSortOrder("id", sorters)} | ||
/> | ||
<Table.Column<ICategory> dataIndex="title" title="Title" sorter /> | ||
</Table> | ||
</List> | ||
); | ||
}; |
26 changes: 26 additions & 0 deletions
26
examples/data-provider-appwrite-tutorial-docs/src/pages/categories/show.tsx
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,26 @@ | ||
import { useShow } from "@refinedev/core"; | ||
|
||
import { Show } from "@refinedev/antd"; | ||
|
||
import { Typography } from "antd"; | ||
|
||
import type { ICategory } from "../../interfaces"; | ||
|
||
const { Title, Text } = Typography; | ||
|
||
export const CategoryShow = () => { | ||
const { queryResult } = useShow<ICategory>(); | ||
|
||
const { data, isLoading } = queryResult; | ||
const record = data?.data; | ||
|
||
return ( | ||
<Show isLoading={isLoading}> | ||
<Title level={5}>Id</Title> | ||
<Text>{record?.id}</Text> | ||
|
||
<Title level={5}>Title</Title> | ||
<Text>{record?.title}</Text> | ||
</Show> | ||
); | ||
}; |
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.