@@ -9,7 +9,7 @@ import { useTranslation } from "@/i18n/use-translation";
99import { useSession } from "@/store/session.atom" ;
1010import { zodResolver } from "@hookform/resolvers/zod" ;
1111import { useMutation } from "@tanstack/react-query" ;
12- import { LinkIcon } from "lucide-react" ;
12+ import { LinkIcon , Loader } from "lucide-react" ;
1313import { useRouter } from "next/navigation" ;
1414import React from "react" ;
1515import { SubmitHandler , useForm } from "react-hook-form" ;
@@ -75,7 +75,6 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
7575 title : article ?. metadata ?. seo ?. title ?? "" ,
7676 description : article ?. metadata ?. seo ?. description ?? "" ,
7777 keywords : article ?. metadata ?. seo ?. keywords ?? [ ] ,
78- canonical_url : article ?. metadata ?. seo ?. canonical_url ?? "" ,
7978 } ,
8079 } ,
8180 } ,
@@ -85,6 +84,8 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
8584 const handleOnSubmit : SubmitHandler <
8685 z . infer < typeof ArticleRepositoryInput . updateMyArticleInput >
8786 > = ( payload ) => {
87+ console . log ( payload ) ;
88+
8889 updateMyArticleMutation . mutate ( {
8990 article_id : article ?. id ?? "" ,
9091 excerpt : payload . excerpt ,
@@ -94,7 +95,6 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
9495 title : payload . metadata ?. seo ?. title ?? "" ,
9596 description : payload . metadata ?. seo ?. description ?? "" ,
9697 keywords : payload . metadata ?. seo ?. keywords ?? [ ] ,
97- canonical_url : payload . metadata ?. seo ?. canonical_url ?? "" ,
9898 } ,
9999 } ,
100100 } ) ;
@@ -109,7 +109,7 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
109109 onSubmit = { form . handleSubmit ( handleOnSubmit ) }
110110 className = "flex flex-col gap-2"
111111 >
112- { JSON . stringify ( form . formState . errors ) }
112+ { /* { JSON.stringify(form.formState.errors)} */ }
113113
114114 < FormField
115115 control = { form . control }
@@ -181,21 +181,6 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
181181 ) }
182182 />
183183
184- { /* <FormField
185- control={form.control}
186- name="metadata.seo.canonical_url"
187- render={({ field }) => (
188- <FormItem>
189- <FormLabel>{_t("Are you republishing")}?</FormLabel>
190- <FormDescription className="text-xs"></FormDescription>
191- <FormControl>
192- <Input {...field} />
193- </FormControl>
194- <FormMessage />
195- </FormItem>
196- )}
197- /> */ }
198-
199184 < FormField
200185 control = { form . control }
201186 name = "metadata.seo.keywords"
@@ -247,32 +232,17 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
247232 </ FormItem >
248233 ) }
249234 />
250- { /*
251- <FormField
252- control={form.control}
253- name="metadata.seo.keywords"
254- render={({ field }) => (
255- <FormItem>
256- <FormLabel>{_t("SEO Keywords")}</FormLabel>
257- <FormDescription className="text-xs">
258- Put some relevent keywords for better search engine
259- visibility
260- </FormDescription>
261- <FormControl>
262- <InputTags
263- value={[]}
264- onChange={(e) => {
265- console.log(e);
266- }}
267- />
268- </FormControl>
269- <FormMessage />
270- </FormItem>
271- )}
272- /> */ }
273235 </ div >
274236
275- < Button type = "submit" > { _t ( "Save" ) } </ Button >
237+ < Button
238+ type = "submit"
239+ disabled = { updateMyArticleMutation . isPending }
240+ >
241+ { updateMyArticleMutation . isPending && (
242+ < Loader className = "mr-2 h-4 w-4 animate-spin" />
243+ ) }
244+ { _t ( "Save" ) }
245+ </ Button >
276246 </ form >
277247 </ Form >
278248 </ div >
0 commit comments