forked from pdsls.dev/pdsls
this repo has no description

cleanup create component

Changed files
+13 -29
src
components
+13 -29
src/components/create.tsx
··· 18 18 let model: monaco.editor.IModel; 19 19 let formRef!: HTMLFormElement; 20 20 21 - const placeholder = (date: string) => { 21 + const placeholder = () => { 22 22 return { 23 23 $type: "app.bsky.feed.post", 24 24 text: "This post was sent from PDSls", ··· 31 31 }, 32 32 }, 33 33 langs: ["en"], 34 - createdAt: date, 34 + createdAt: new Date().toISOString(), 35 35 }; 36 36 }; 37 37 ··· 163 163 const createModel = () => { 164 164 if (!model) 165 165 model = monaco.editor.createModel( 166 - JSON.stringify( 167 - props.create ? placeholder(new Date().toISOString()) : props.record, 168 - null, 169 - 2, 170 - ), 166 + JSON.stringify(props.create ? placeholder() : props.record, null, 2), 171 167 "json", 172 168 ); 173 169 }; ··· 279 275 </form> 280 276 </div> 281 277 </Modal> 282 - <Show when={props.create}> 283 - <button 284 - onclick={() => { 285 - createModel(); 286 - setOpenDialog(true); 287 - }} 288 - > 289 - <Tooltip text="Create record" children={<div class="i-lucide-square-pen text-xl" />} /> 290 - </button> 291 - </Show> 292 - <Show when={!props.create}> 293 - <button 294 - onclick={() => { 295 - createModel(); 296 - setOpenDialog(true); 297 - }} 298 - > 299 - <Tooltip text="Edit"> 300 - <div class="i-lucide-pencil text-xl" /> 301 - </Tooltip> 302 - </button> 303 - </Show> 278 + <button 279 + onclick={() => { 280 + createModel(); 281 + setOpenDialog(true); 282 + }} 283 + > 284 + <Tooltip text={`${props.create ? "Create" : "Edit"} record`}> 285 + <div class={`${props.create ? "i-lucide-square-pen" : "i-lucide-pencil"} text-xl`} /> 286 + </Tooltip> 287 + </button> 304 288 </> 305 289 ); 306 290 };