@@ -39,10 +39,6 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
3939 const session = useSession ( ) ;
4040 const { _t } = useTranslation ( ) ;
4141 const router = useRouter ( ) ;
42- const setDebounceHandler = useDebouncedCallback ( async ( slug : string ) => {
43- const handle = await articleActions . getUniqueArticleHandle ( slug ) ;
44- form . setValue ( "handle" , handle ) ;
45- } , 2000 ) ;
4642 const updateMyArticleMutation = useMutation ( {
4743 mutationFn : (
4844 input : z . infer < typeof ArticleRepositoryInput . updateMyArticleInput >
@@ -57,13 +53,21 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
5753 } ,
5854 } ) ;
5955
60- const [ tags , setTags ] = React . useState < string [ ] > ( [ ] ) ;
56+ const setDebounceHandler = useDebouncedCallback ( async ( slug : string ) => {
57+ const handle = await articleActions . getUniqueArticleHandle ( slug ) ;
58+ form . setValue ( "handle" , handle ) ;
59+ updateMyArticleMutation . mutate ( {
60+ article_id : article ?. id ?? "" ,
61+ handle : handle ,
62+ } ) ;
63+ } , 2000 ) ;
6164
6265 const form = useForm <
6366 z . infer < typeof ArticleRepositoryInput . updateMyArticleInput >
6467 > ( {
6568 defaultValues : {
6669 article_id : article . id ,
70+ title : article ?. title ?? "" ,
6771 handle : article ?. handle ?? "" ,
6872 excerpt : article ?. excerpt ?? "" ,
6973 metadata : {
@@ -95,7 +99,7 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
9599 } ,
96100 } ) ;
97101 } ;
98- //className="m-3 h-[100vh-20px] w-[100vw-20px]"
102+
99103 return (
100104 < Sheet open = { open } onOpenChange = { onClose } >
101105 < SheetContent >
@@ -127,7 +131,7 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
127131 />
128132 </ FormControl >
129133 < FormDescription className = "-mt-1" >
130- https://www.techdiary.dev/{ session ?. user ?. username } /
134+ https://www.techdiary.dev/@ { session ?. user ?. username } /
131135 { form . watch ( "handle" ) }
132136 </ FormDescription >
133137 < FormMessage />
@@ -170,13 +174,28 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
170174 click-through-rates.
171175 </ FormDescription >
172176 < FormControl >
173- < Input { ...field } placeholder = { form . watch ( "handle " ) } />
177+ < Input { ...field } placeholder = { form . watch ( "title " ) } />
174178 </ FormControl >
175179 < FormMessage />
176180 </ FormItem >
177181 ) }
178182 />
179183
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+
180199 < FormField
181200 control = { form . control }
182201 name = "metadata.seo.keywords"
@@ -253,7 +272,7 @@ const ArticleEditorDrawer: React.FC<Props> = ({ article, open, onClose }) => {
253272 /> */ }
254273 </ div >
255274
256- < Button > { _t ( "Save" ) } </ Button >
275+ < Button type = "submit" > { _t ( "Save" ) } </ Button >
257276 </ form >
258277 </ Form >
259278 </ div >
0 commit comments