Skip to content

Commit

Permalink
fix: tags delete update create write #449
Browse files Browse the repository at this point in the history
fixed tag isssues in write post settings page working fine create select and delete tag from a post
  • Loading branch information
jasirtp committed Nov 11, 2021
1 parent a9f0825 commit c00f21a
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions component/myblogs/WriteNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function WriteNav({
async function getSettingsTags() {
try {
const res = await TagService.getTags();
console.log("get tags response", res);
// console.log("get tags response", res);
if (res && res.length) {
const resTagOptions = res.map((tag) => {
return {
Expand All @@ -100,7 +100,7 @@ export default function WriteNav({
* @author akhilalekha
*/
const handleTags = async (e) => {
console.log("handle tags", e);
// console.log("handle tags", e);

const newTag = e
.filter((tag) => {
Expand All @@ -113,7 +113,6 @@ export default function WriteNav({
try {
if (newTag.length > 0) {
const res = await TagService.postTags(userCookie, newTag);
console.log({ res }, 'res');
const arr = [{ tag_id: res.id, post_id: currentPost.id }];
const response = await TagService.postSaveTags(userCookie, arr);
e.splice(-1, 1);
Expand All @@ -127,11 +126,7 @@ export default function WriteNav({
else {
// gets new added tag and closed tag using filter
const addTag = e.filter(({ id: id1 }) => !currentPost.tags.some(({ id: id2 }) => id2 === id1));
console.log(addTag, 'addTag');

const removeTag = currentPost.tags.filter(({ id: id1 }) => !e.some(({ id: id2 }) => id2 === id1));
console.log(removeTag, 'removeTag');

if (addTag.length) {
const arr = addTag.map(({ id }) => { return { tag_id: id, post_id: currentPost.id } })
const res = await TagService.postSaveTags(userCookie, arr);
Expand Down

0 comments on commit c00f21a

Please sign in to comment.