Skip to content

Commit

Permalink
fix: resolved messages
Browse files Browse the repository at this point in the history
  • Loading branch information
alenmestrov committed Nov 14, 2024
1 parent c53bf43 commit 0849be5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
5 changes: 2 additions & 3 deletions app/src/api/clientApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export interface GetProposalMessagesResponse {
export interface SendProposalMessageRequest {
// proposalId: String;
proposal_id: String;
author: String;
text: String;
message: Message;
}

export interface SendProposalMessageResponse {
Expand All @@ -46,7 +45,7 @@ export interface ApproveProposalResponse {

export enum ClientMethod {
GET_PROPOSAL_MESSAGES = 'get_proposal_messages',
SEND_PROPOSAL_MESSAGE = 'send_proposal_message',
SEND_PROPOSAL_MESSAGE = 'send_proposal_messages',
CREATE_PROPOSAL_MESSAGES = 'create_new_proposal',
APPROVE_PROPOSAL_MESSAGE = 'approve_proposal',
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/api/dataSource/LogicApiDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class LogicApiDataSource implements ClientApi {
return { error };
}

const response = await getJsonRpcClient().mutate<
const response = await getJsonRpcClient().execute<
SendProposalMessageRequest,
SendProposalMessageResponse
>(
Expand Down
23 changes: 17 additions & 6 deletions app/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import { getStorageApplicationId } from '../../utils/node';
import {
clearApplicationId,
getJWTObject,
getStorageExecutorPublicKey,
} from '../../utils/storage';
import { useNavigate } from 'react-router-dom';
Expand Down Expand Up @@ -186,11 +187,16 @@ export default function HomePage() {
async function sendProposalMessage(request: SendProposalMessageRequest) {
const params: SendProposalMessageRequest = {
proposal_id: request.proposal_id,
author: request.author,
text: request.text,
message: {
id: request.message.id,
proposal_id: request.proposal_id,
author: request.message.author,
text: request.message.text,
created_at: new Date().toISOString(),
},
};
const result: ResponseData<GetProposalMessagesResponse> =
await new LogicApiDataSource().getProposalMessages(params);
const result: ResponseData<SendProposalMessageResponse> =
await new LogicApiDataSource().sendProposalMessage(params);
if (result?.error) {
console.error('Error:', result.error);
window.alert(`${result.error.message}`);
Expand Down Expand Up @@ -401,8 +407,13 @@ export default function HomePage() {
onClick={() => {
sendProposalMessage({
proposal_id: selectedProposal.id,
author: getStorageExecutorPublicKey(),
text: 'test' + Math.random(),
message: {
id: 'test' + Math.random(),
proposal_id: selectedProposal.id,
author: getJWTObject()?.executor_public_key,
text: 'test' + Math.random(),
created_at: new Date().toISOString(),
},
} as SendProposalMessageRequest);
}}
>
Expand Down

0 comments on commit 0849be5

Please sign in to comment.