diff --git a/refine-nextjs/plugins/_base/extend.js b/refine-nextjs/plugins/_base/extend.js index 1c6282bda..19ceda266 100644 --- a/refine-nextjs/plugins/_base/extend.js +++ b/refine-nextjs/plugins/_base/extend.js @@ -182,6 +182,8 @@ module.exports = { base.blogPostCategoryIdFormField = `"categoryId"`; } else if (dataProvider === "data-provider-supabase") { base.blogPostCategoryIdFormField = `"categoryId"`; + } else if (dataProvider === "data-provider-appwrite") { + base.blogPostCategoryIdFormField = `"category"`; } else { if (uiFramework === "mui" || isHeadless) { base.blogPostCategoryIdFormField = `"category.id"`; @@ -191,7 +193,7 @@ module.exports = { } // ## blogPostCategoryTableField - if (base.isGraphQL) { + if (base.isGraphQL || dataProvider === "data-provider-appwrite") { if (isHeadless) { base.blogPostCategoryTableField = `"category.title"`; } diff --git a/refine-nextjs/plugins/antd-example/src/app/blog-posts/edit/[id]/page.tsx b/refine-nextjs/plugins/antd-example/src/app/blog-posts/edit/[id]/page.tsx index 9e9ffbff1..7034cf2b7 100644 --- a/refine-nextjs/plugins/antd-example/src/app/blog-posts/edit/[id]/page.tsx +++ b/refine-nextjs/plugins/antd-example/src/app/blog-posts/edit/[id]/page.tsx @@ -31,6 +31,18 @@ export default function BlogPostEdit() { meta: { select: '*, categories(id,title)', }, +<%_ } _%> +<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%> + queryOptions: { + select: ({ data }) => { + return { + data: { + ...data, + category: data.category.$id, + }, + }; + }, + }, <%_ } _%> }); @@ -38,7 +50,11 @@ export default function BlogPostEdit() { const { selectProps: categorySelectProps } = useSelect({ resource: "categories", +<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%> + defaultValue: blogPostsData?.<%- blogPostCategoryFieldName %>, +<%_ } else { _%> defaultValue: blogPostsData?.<%- blogPostCategoryFieldName %>?.id, +<%_ } _%> <%_ if (answers["data-provider"] === "data-provider-hasura") { _%> meta: { fields: BLOG_POSTS_CATEGORIES_SELECT_QUERY, diff --git a/refine-nextjs/plugins/antd-example/src/app/blog-posts/page.tsx b/refine-nextjs/plugins/antd-example/src/app/blog-posts/page.tsx index c0e1e35ef..a04124e6d 100644 --- a/refine-nextjs/plugins/antd-example/src/app/blog-posts/page.tsx +++ b/refine-nextjs/plugins/antd-example/src/app/blog-posts/page.tsx @@ -45,7 +45,7 @@ export default function BlogPostList() { <%_ } _%> }); -<%_ if (!isGraphQL) { _%> +<%_ if (!isGraphQL && answers["data-provider"] !== "data-provider-appwrite") { _%> const { data: categoryData, isLoading: categoryIsLoading } = useMany({ resource: "categories", ids: tableProps?.dataSource?.map((item) => item?.<%- blogPostCategoryFieldName %>?.id).filter(Boolean) ?? [], @@ -71,7 +71,7 @@ export default function BlogPostList() { } title={"Category"} - <%_ if (!isGraphQL) { _%> + <%_ if (!isGraphQL && answers["data-provider"] !== "data-provider-appwrite") { _%> render={(value) => categoryIsLoading ? ( <>Loading... @@ -86,7 +86,9 @@ export default function BlogPostList() { - dataIndex={["created_at"]} + dataIndex={["created_at"]} +<%_ } else if (answers["data-provider"] === "data-provider-appwrite") { _%> + dataIndex={["$createdAt"]} <%_ } else { _%> dataIndex={["createdAt"]} <%_ } _%> diff --git a/refine-nextjs/plugins/antd-example/src/app/blog-posts/show/[id]/page.tsx b/refine-nextjs/plugins/antd-example/src/app/blog-posts/show/[id]/page.tsx index a26fdad80..cca792751 100644 --- a/refine-nextjs/plugins/antd-example/src/app/blog-posts/show/[id]/page.tsx +++ b/refine-nextjs/plugins/antd-example/src/app/blog-posts/show/[id]/page.tsx @@ -46,7 +46,7 @@ export default function BlogPostShow() { const record = data?.data; -<%_ if (!isGraphQL) { _%> +<%_ if (!isGraphQL && answers["data-provider"] !== "data-provider-appwrite") { _%> const { data: categoryData, isLoading: categoryIsLoading } = useOne({ resource: "categories", id: record?.<%- blogPostCategoryFieldName %>?.id || "", @@ -65,7 +65,7 @@ export default function BlogPostShow() { {"Content"} {"Category"} -<%_ if (isGraphQL) { _%> +<%_ if (isGraphQL || answers["data-provider"] === "data-provider-appwrite") { _%> ?.title} /> <%_ } else { _%> {"Status"} {"CreatedAt"} +<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%> + +<%_ } else if (answers["data-provider"] === "data-provider-hasura") { _%> + +<%_ } else { _%> +<%_ } _%> ); }; diff --git a/refine-nextjs/plugins/data-provider-appwrite/src/providers/data-provider/index.ts b/refine-nextjs/plugins/data-provider-appwrite/src/providers/data-provider/index.ts index 7d9aaf090..82a3bc4ee 100644 --- a/refine-nextjs/plugins/data-provider-appwrite/src/providers/data-provider/index.ts +++ b/refine-nextjs/plugins/data-provider-appwrite/src/providers/data-provider/index.ts @@ -4,9 +4,9 @@ import { dataProvider, liveProvider } from "@refinedev/appwrite"; import { appwriteClient } from "@utils/appwrite/client"; export const appwriteDataProvider = dataProvider(appwriteClient, { - databaseId: "database", + databaseId: "default", }); export const appwriteLiveProvider = liveProvider(appwriteClient, { - databaseId: "database", + databaseId: "default", }); diff --git a/refine-nextjs/plugins/data-provider-appwrite/src/utils/constants.ts b/refine-nextjs/plugins/data-provider-appwrite/src/utils/constants.ts index 8be31586b..b376660d5 100644 --- a/refine-nextjs/plugins/data-provider-appwrite/src/utils/constants.ts +++ b/refine-nextjs/plugins/data-provider-appwrite/src/utils/constants.ts @@ -1,3 +1,3 @@ -export const APPWRITE_URL = "https://refine.appwrite.org/v1"; -export const APPWRITE_PROJECT = "61c4368b4e349"; +export const APPWRITE_URL = "https://cloud.appwrite.io/v1"; +export const APPWRITE_PROJECT = "6697687d002cbd31ba6b"; export const APPWRITE_JWT_KEY = "appwrite-jwt"; diff --git a/refine-nextjs/plugins/headless-example/src/app/blog-posts/create/page.tsx b/refine-nextjs/plugins/headless-example/src/app/blog-posts/create/page.tsx index 805ef3a1a..8356533fa 100644 --- a/refine-nextjs/plugins/headless-example/src/app/blog-posts/create/page.tsx +++ b/refine-nextjs/plugins/headless-example/src/app/blog-posts/create/page.tsx @@ -111,7 +111,11 @@ export default function BlogPostCreate() { ))} +<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%> + {(errors as any)?.<%- blogPostCategoryFieldName %>?.message as string} +<%_ } else { _%> {(errors as any)?.<%- blogPostCategoryFieldName %>?.id?.message as string} +<%_ } _%>