()
| 147 | }; |
| 148 | |
| 149 | export const PluginAdd = () => { |
| 150 | const createPlugin = useCreatePlugin(); |
| 151 | function handleSave(event: React.SyntheticEvent) { |
| 152 | event.preventDefault(); |
| 153 | const formData = new FormData(event.target as HTMLFormElement); |
| 154 | const name = formData.get('name') as string; |
| 155 | const url = formData.get('url') as string; |
| 156 | createPlugin.mutate( |
| 157 | { name, url }, |
| 158 | { |
| 159 | onSuccess: () => { |
| 160 | toast('Successfully added plugin', { |
| 161 | icon: '👍', |
| 162 | className: 'bg-green-100 font-bold', |
| 163 | }); |
| 164 | }, |
| 165 | onError: (response) => { |
| 166 | toast('Something went wrong adding a plugin', { |
| 167 | icon: '😖', |
| 168 | className: 'bg-red-100 font-bold', |
| 169 | }); |
| 170 | }, |
| 171 | } |
| 172 | ); |
| 173 | } |
| 174 | return ( |
| 175 | <> |
| 176 | <form onSubmit={handleSave}> |
| 177 | <div className="form-control"> |
| 178 | <label className="label"> |
| 179 | <span className="label-text">Name</span> |
| 180 | </label> |
| 181 | <input |
| 182 | type="text" |
| 183 | aria-label="add plugin name" |
| 184 | name="name" |
| 185 | placeholder="Name" |
| 186 | className="input input-bordered" |
| 187 | /> |
| 188 | </div> |
| 189 | <div className="form-control"> |
| 190 | <label className="label"> |
| 191 | <span className="label-text">URL</span> |
| 192 | </label> |
| 193 | <input |
| 194 | type="text" |
| 195 | aria-label="add plugin url" |
| 196 | name="url" |
| 197 | placeholder="URL" |
| 198 | className="input input-bordered" |
| 199 | /> |
| 200 | </div> |
| 201 | <div className="modal-action"> |
| 202 | <button className="btn btn-primary" type="submit" aria-label="create plugin"> |
| 203 | Save |
| 204 | </button> |
| 205 | </div> |
| 206 | </form> |
nothing calls this directly
no test coverage detected