Skip to content

Commit

Permalink
fix: integration fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardik-hi committed Aug 19, 2022
1 parent 06de8f5 commit 348fa0a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
17 changes: 9 additions & 8 deletions src/adapters/esamwad/contentPages.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ export class ContentPagesEsamwadService implements IServicelocator {
//to create a content page
public async createContentPage(request: any, contentPageData: ContentPagesDto) {
var axios = require("axios");
const blocksData = contentPageData.blocks.map(({ blockIndex, blockType, blockData }, idx) => ({ block_index: blockIndex, block_type: blockType, block_data: blockData, content_page_id: idx }));
const blocksData = contentPageData.blocks.map(({ blockType, blockData }, idx) => ({ block_index: idx, block_type: blockType, block_data: blockData }));
var data = {
query: `mutation create_content_page($_slug: String, $_status: String,$_author: String, $_title: String, $_data: [blocks_insert_input!], $created_by: String, $modified_by: String) {
query: `mutation create_content_page($_slug: String, $_status: String,$_author: String, $_title: String, $_data: [blocks_insert_input!]!, $_created_by: String, $_modified_by: String) {
insert_content_pages_one(object: {slug: $_slug, status: $_status, author: $_author, title: $_title, blocks: {data: $_data}, created_by: $_created_by, modified_by: $_modified_by}) {
id
}
}
`,
variables: {
_slug: contentPageData?.slugUrl,
_slug: contentPageData?.urlSlug,
_title: contentPageData?.title,
_status: contentPageData?.status,
_data: blocksData,
Expand All @@ -34,7 +34,6 @@ export class ContentPagesEsamwadService implements IServicelocator {
_modified_by: "eyJhbGciOiJSUzI1NiIsInR5cCIgO"
}
};

var config = {
method: "post",
url: this.baseURL,
Expand Down Expand Up @@ -70,9 +69,11 @@ export class ContentPagesEsamwadService implements IServicelocator {
slug
title
status
author
id
blocks(order_by: {block_index: desc}) {
blocks(order_by: {block_index: asc}) {
block_data
block_index
block_type
id
}
Expand Down Expand Up @@ -169,7 +170,7 @@ export class ContentPagesEsamwadService implements IServicelocator {
) {
var axios = require("axios");
const pageId = parseInt(contentPageId);
const blocksData = contentPageData.blocks.map(({ blockIndex, blockType, blockData }, idx) => ({ block_index: blockIndex, block_type: blockType, block_data: blockData, content_page_id: idx }));
const blocksData = contentPageData.blocks.map(({blockType, blockData }, idx) => ({ block_index: idx, block_type: blockType, block_data: blockData, content_page_id: contentPageId }));

var updateData = {
query: `mutation update_content_page_data($_id: Int!, $_author: String, $_modified_at: timestamptz, $_modified_by: String, $_slug: String, $_title: String, $_status: String, $_data: [blocks_insert_input!] = {}) {
Expand All @@ -187,11 +188,11 @@ export class ContentPagesEsamwadService implements IServicelocator {
`,
variables: {
_id: pageId,
_slug: contentPageData?.slugUrl,
_slug: contentPageData?.urlSlug,
_author: contentPageData?.author,
_status: contentPageData?.status,
_title: contentPageData?.title,
_modified_at: + new Date().toISOString(),
_modified_at: new Date().toISOString(),
_modified_by: "329uinfnf84f4jf94f",
_data: blocksData
},
Expand Down
4 changes: 2 additions & 2 deletions src/contentPages/dto/block.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class BlockDto {
@ApiProperty({
type: Number,
description: "Index of the block for relative ordering of blocks (higher index denotes lower position on the page",
default: {},
default: 0,
})
@Expose()
blockIndex: number;
Expand All @@ -39,6 +39,6 @@ export class BlockDto {
this.blockId = obj?.id ?? "";
this.blockType = obj?.block_type ?? "";
this.blockData = obj?.block_data ?? {};
this.blockIndex = obj?.block_index ?? 0;
this.blockIndex = obj?.block_index??0;
}
}
7 changes: 4 additions & 3 deletions src/contentPages/dto/contentPages.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class ContentPagesDto {
default: "",
})
@Expose()
slugUrl: string;
urlSlug: string;

@ApiProperty({
type: String,
Expand Down Expand Up @@ -62,10 +62,11 @@ export class ContentPagesDto {

constructor(obj: any) {
this.contentPageId = obj?.id ?? "",
this.slugUrl = obj?.slug ?? "",
this.author = obj?.author ?? "",
this.urlSlug = obj?.slug ?? "",
this.title = obj?.title ?? "",
this.dateModified = obj?.modified_at ?? "",
this.status = obj?.status ?? "",
this.blocks = obj?.blocks ?? []
this.blocks = obj?.blocks?.map((val:any) => (new BlockDto(val))) ?? []
}
}

0 comments on commit 348fa0a

Please sign in to comment.