Skip to content

Commit

Permalink
request page
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmasken committed Feb 13, 2024
1 parent abb2f71 commit f6887ef
Show file tree
Hide file tree
Showing 62 changed files with 420 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .dfx/network/local/ic-https-outcalls-adapter-pid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13400
21685
2 changes: 1 addition & 1 deletion .dfx/network/local/icx-proxy-pid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13545
25492
2 changes: 1 addition & 1 deletion .dfx/network/local/pid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13395
21676
2 changes: 1 addition & 1 deletion .dfx/network/local/replica-configuration/replica-1.port
Original file line number Diff line number Diff line change
@@ -1 +1 @@
39797
46511
2 changes: 1 addition & 1 deletion .dfx/network/local/replica-configuration/replica-pid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13407
21692
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
�q/(���������:��
�x0(���������:��
���
Ъ�
��
��
��@
��˸D
��˸D
acknowledge_entries
add
add_tentative_device
Expand Down Expand Up @@ -36,7 +36,7 @@ $authn_method_registration_mode_enter%
remove
replace
update
verify_tentative_deviceget_anchor_credentialsget_delegation get_id_aliasget_principal http_requestidentity_authn_infolookupstats �q*ݹ
verify_tentative_deviceget_anchor_credentialsget_delegation get_id_aliasget_principal http_requestidentity_authn_infolookupstats �x*ݹ
O
candid:args@(opt InternetIdentityInit) �����Q&1��)�������p��Y���~
��
Expand Down Expand Up @@ -665,9 +665,9 @@ service : (opt InternetIdentityInit) -> {
dfx��{"pullable":{"wasm_url": "https://github.com/dfinity/internet-identity/releases/download/release-2024-02-02/internet_identity_dev.wasm.gz","dependencies": [],"init_guide": "Use '(null)' for sensible defaults. See the candid interface for more details."}} c�� #FK���X|�b�}"�Q�hs��l��
K
supported_certificate_versions)1,2 �Իbؗ�ь;Z�FATb��'��_�M�'�&��2 �B�v�;BT�� ܿ7���Mp��c򵻯���8Z
/x2��s�2� �O��H�� ��C�<�����Ϙ=8R��D9�����������
��a��Z���
����������3� ���� ï�~� ��T�ֹ�W
0x3���3� ���T S�+����ά��϶�gO�VGq����������
�# =��Z���
�ѥ�������4� ��� �ם~� ��T�ֹ�W
��������

*
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
�u(�:�J
�(�:�J
��R
��R
��@
���
���
icrc1_transfer!__get_candid_interface_tmp_hack
archives 
get_blocksget_data_certificateget_transactions http_requesticrc1_balance_oficrc1_decimals  icrc1_feeicrc1_metadataicrc1_minting_account 
icrc1_nameicrc1_supported_standards icrc1_symbolicrc1_total_supply �u*�F
icrc1_nameicrc1_supported_standards icrc1_symbolicrc1_total_supply �*�F
�F
candid:service�F�Etype BlockIndex = nat;
type Subaccount = blob;
Expand Down Expand Up @@ -288,12 +288,13 @@ service : (ledger_arg : LedgerArg) -> {
`
git_commit_idO)b3b00ba59c366384e3e0cd53a69457e9053ec987
 }�o���>�#c,�%� �gN�]{���'�G\2 �% ���C.Q��f�L4�b("ɬS��28Z
x��u��� ����[�2"�#��������([���ɜ� ����������
x����� ��<�tB/���"��u��
r��5KhY������������

��
�V� �1Kdz��u�1��Bԃ�XOLO����!���
����������� ���� �ǒW�
����
�V� �1Kdz��u�1��Bԃ�XOLO��A�P���
�ѥ�������� ���� �ǒW�
��
�����
K�����"

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
�5(���������:�>
�5(���������:�>
��E
��E
��@
Expand Down Expand Up @@ -299,12 +299,12 @@ service: (asset_canister_args: opt AssetCanisterArgs) -> {
K
supported_certificate_versions)1,2 �Իbؗ�ь;Z�FATb��'��_�M�'�&��2 <�����q3����L������]>Ք�~�l�08Z
5x
��t�
� �yg��1<W�~s���ޭ�6��G��s~��$��������
����
� �yg��1<W�~s���ޭ�6��G��s~��$���ٽ������

��
�V� �1Kdz��u�1��Bԃ�XOLO��~����
����������6� ����
�V� �1Kdz��u�1��Bԃ�XOLO��A�v���
�ѥ�������6� ᓀ�
��Ɉ� ���8�
�����
K��ǭ����"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
64 changes: 51 additions & 13 deletions canisters/backend/main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this {
type User = Types.User;
type Notification = Types.Notification;
type Employee = Types.Employee;
type Invoice = Types.Invoice;
public type TransactionId = Nat32;
// #endregion

Expand All @@ -53,13 +54,17 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this {
stable var entries : [(Nat, Transaction)] = [];
stable var users : [(Nat, Employee)] = [];
stable var notifs : [(Nat, Notification)] = [];
stable var invo : [(Nat, Invoice)] = [];
stable var transactionCounter : Nat = 0;
stable var contactsCounter : Nat = 0;
stable var notificationsCounter : Nat = 0;
stable var invoiceCounter : Nat = 0;
let transactions: HashMap.HashMap<Nat, Transaction> = HashMap.fromIter(Iter.fromArray(entries), entries.size(), Nat.equal, Hash.hash);
let contacts: HashMap.HashMap<Nat, Employee> = HashMap.fromIter(Iter.fromArray(users), users.size(), Nat.equal, Hash.hash);
let notifications: HashMap.HashMap<Nat, Notification> = HashMap.fromIter(Iter.fromArray(notifs), notifs.size(), Nat.equal, Hash.hash);
let MAX_TRANSACTIONS = 30_000;
let invoices: HashMap.HashMap<Nat, Invoice> = HashMap.fromIter(Iter.fromArray(invo), invo.size(), Nat.equal, Hash.hash);



public shared ({ caller }) func getAddress() : async Text {
Expand Down Expand Up @@ -824,20 +829,7 @@ public shared ({caller}) func getMyContactsLength() : async Text {
return Buffer.toArray<Notification>(my_notifications);
};

///get no of notifications added by caller
// public shared ({caller}) func getMyNotificationsLength() : async Text {
// let allEntries
// = Iter.toArray(notifications.entries());
// var size = 0;
// for ((_, notification) in allEntries.vals()){
// if(notification.sender == Principal.toText(caller)){


// size += 1;
// };
// };
// return Nat.toText(size);
// };
//get notifications added by caller and not read
public shared ({caller}) func getUnreadNotifications() : async [Notification] {
let allEntries = Iter.toArray(notifications.entries());
Expand Down Expand Up @@ -908,6 +900,52 @@ public shared ({caller}) func getMyContactsLength() : async Text {
// };
// };

//create invoice
public shared ({caller}) func create_invoice (args: Types.CreateInvoiceArgs) : async Types.CreateInvoiceResult {
let id : Nat = invoiceCounter;
// increment counter
invoiceCounter += 1;

let invoice : Invoice = {
id;
creator : Princiapl.toText(caller);
payer = args.payer;
amount = args.amount;
memo : ?args.memo;
status = false;
created_at = Time.now();
modified_at = Time.now();
};

invoices.put(id, invoice);
return #ok({invoice});

};

//region get invoices that have been according to invoice payer or invoice creator .
public shared ({caller}) func get_invoices() : async [Invoice] {
let allEntries = Iter.toArray(invoices.entries());
let my_invoices = Buffer.Buffer<Invoice>(50);
// let outputArray : [Transaction] = [];
for ((_, invoice) in allEntries.vals()){
if(invoice.payer == Principal.toText(caller)){
my_invoices.add(invoice);
// outputArray := Array.append(outputArray, [(transaction)]);
Debug.print("Invoice: " # debug_show(invoice));
};
if(invoice.payer == Principal.toText(caller)){
my_invoices.add(invoice);
// outputArray := Array.append(outputArray, [(transaction)]);
Debug.print("Invoice: " # debug_show(invoice));
};
};

return Buffer.toArray<Invoice>(my_invoices);
};

//if user is creator show invoices




};
Expand Down
38 changes: 33 additions & 5 deletions canisters/backend/types.mo
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ module {
};

public type Invoice = {
from : Principal;
to : Principal;
id: Nat;
creator : Principal;
payer : Principal;
amount : Nat;
memo : Text;
memo : ?Text;
status : InvoiceStatus;
created_at : Int;
modified_at : Int;
Expand All @@ -42,8 +43,6 @@ module {
destination : Principal;
};



public type User = {
name : Text;
email_notifications : Bool;
Expand Down Expand Up @@ -211,5 +210,34 @@ module {
};
};

//creator : Principal;
//payer : Principal;
// amount : Nat;
//memo : ?Text;
// status : InvoiceStatus;
// created_at : Int;
// modified_at : Int;

//region create invoice
public type CreateInvoiceArgs = {

payer : Text;
amount : Text;
memo: ?Text;

};
public type CreateInvoiceResult = Result.Result<CreateInvoiceSuccess, CreateInvoiceErr>;
public type CreateInvoiceSuccess = {
invoice : Invoice;
};
public type CreateInvoiceErr = {
message : ?Text;
kind : {
#InvalidUser;
#InvalidId;
#Other;
};
};


};
28 changes: 27 additions & 1 deletion frontend/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,20 @@ const toggleDarkMode = () => {
alt="Vite logo"
/>
<span>Send</span>
</router-link>
</router-link>
<router-link
v-if="authStore.isConfigured === true"
active-class="group router-link-exact-active cursor-pointer flex flex-row bg-[#7152F30D] rounded-r-[10px] text-base text-[#7152F3] font-semibold py-[13px] pr-[10px] pl-[13px] space-x-4"
class="group flex flex-row bg-[#7152F30D cursor-pointer rounded-r-[10px] text-base text-[#16151C] dark:text-gray-400 font-light hover:bg-[#7152F30D] py-[13px] pr-[10px] pl-[13px] space-x-4"
to="/home/request"
>
<img
src="./assets/payroll.png"
class="shrink-0 h-6 w-6"
alt="Vite logo"
/>
<span>Request</span>
</router-link>
<router-link
v-if="authStore.isConfigured === true"
active-class="group router-link-exact-active cursor-pointer flex flex-row bg-[#7152F30D] rounded-r-[10px] text-base text-[#7152F3] font-semibold py-[13px] pr-[10px] pl-[13px] space-x-4"
Expand All @@ -191,6 +204,19 @@ const toggleDarkMode = () => {
/>
<span>Transactions</span>
</router-link>
<router-link
v-if="authStore.isConfigured === true"
active-class="group router-link-exact-active cursor-pointer flex flex-row bg-[#7152F30D] rounded-r-[10px] text-base text-[#7152F3] font-semibold py-[13px] pr-[10px] pl-[13px] space-x-4"
class="group flex flex-row bg-[#7152F30D cursor-pointer rounded-r-[10px] text-base text-[#16151C] dark:text-gray-400 font-light hover:bg-[#7152F30D] py-[13px] pr-[10px] pl-[13px] space-x-4"
to="/home/invoices"
>
<img
src="./assets/payroll.png"
class="shrink-0 h-6 w-6"
alt="Vite logo"
/>
<span>Invoices</span>
</router-link>
<router-link
v-if="authStore.isConfigured === true"
active-class="group router-link-exact-active cursor-pointer flex flex-row bg-[#7152F30D] rounded-r-[10px] text-base text-[#7152F3] font-semibold py-[13px] pr-[10px] pl-[13px] space-x-4"
Expand Down
8 changes: 8 additions & 0 deletions frontend/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ const router = createRouter({
path: "/home/transfer",
component: () => import("../views/Transfer.vue"),
},
{
path: "/home/request",
component: () => import("../views/Request.vue"),
},
{
path: "/home/candidates",
component: () => import("../views/Candidates.vue"),
Expand All @@ -48,6 +52,10 @@ const router = createRouter({
path: "/home/transactions",
component: () => import("../views/Transactions.vue"),
},
{
path: "/home/invoices",
component: () => import("../views/Invoices.vue"),
},
{
path: "/home/jobs",
component: () => import("../views/Jobs.vue"),
Expand Down
10 changes: 10 additions & 0 deletions frontend/store/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const useAuthStore = defineStore("auth", {
payments: null,
registrationData: {},
transferArgs: {},
requestArgs: {},
tradingbalance: null,
fundingbalance: null,
fundingaddress: null,
Expand Down Expand Up @@ -168,6 +169,15 @@ export const useAuthStore = defineStore("auth", {

console.log(response);
},

async createInvoice(amount, payer) {
const response = await this.whoamiActor?.create_invoice({
amount: amount,
payer: payer
});

console.log(response);
}
},
getters: {
getConfiguration(state) {
Expand Down
33 changes: 33 additions & 0 deletions frontend/views/Invoices.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<div class="space-y-2 ">
<h1 class="uppercase tracking-widest text-gray-800 dark:text-white font-semibold">Transactions</h1>
<p class="uppercase tracking-widest text-gray-800 dark:text-white font-semibold">
This is a list of all your transactions
</p>
<div
class=" p-2 "
v-for="invoice in invoices" :key="transaction.id">


<TransactionCard :sender="invoice.creator" :id="invoice.id" :receiver="invoice.payer"
:amount="invoice.amount"
/>
</div>

</div>
</template>
<script setup>
import { useAuthStore } from "../store/auth";
import { ref, watchEffect } from "vue";
import TransactionCard from "../components/TransactionCard.vue"
const authStore = useAuthStore();
let invoices = ref([]);
watchEffect(async () => {
const res = await authStore.whoamiActor?.get_invoices();
invoices.value = await res;
});
</script>

0 comments on commit f6887ef

Please sign in to comment.