You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(word-editor): implement new word action (#39)
This Pull Request implements the `add` functionality for word on the
word editor. The `add` operation takes the current input entered into
the editor on submit, perform a submit operation with the `"add"` action
through the `handleSubmitWord` handler and routes to the `/editor` page
after successful word addition operation.
### Changes Made
- Removed `WordEditor` component integration in `/editor` route;
prepping it as the jargons editor (a dashboard 😉)
- Added the "add new word" route for adding new word to dictionary at
`/editor/new`
- Integrated `WordEditor` and it `SubmitButton` component to the add new
word route
- Integrated the `writeNewWord` function into the `handleSubmitWord`
handler with logic to execute it only when word-editor `action` is
`"new"`
```js
if (action === "new") {
const newWord = await writeNewWord(userOctokit, forkedRepoDetails, {
title,
content
}, {
env: "browser"
});
console.log("New word added: ", newWord);
}
```
- Modified the `handleSubmitWord` handler to move the
`updateExistingWord` function integration to the conditions of executing
only when `action` is `"edit"` in contrast to the `"new"`
- Added a new utils function `captilizeText` (quick one from chatGPT 😉);
which is used to capitalize the title text incases where the entered
word title is in lowercase

- Used the `trim()`method on the entered word `title` to remove
whitespaces from input
### Screencast
https://github.com/babblebey/jargons.dev/assets/25631971/0f6d00a8-c239-4da0-85cb-08cd9e688c76
0 commit comments