bugs and futures
parent
4292fb56ec
commit
f64d555c8b
|
@ -60,7 +60,7 @@ export class CAuth {
|
|||
|
||||
public async RequestResetPassword(email: string): Promise<IAuthResetPassword> {
|
||||
try {
|
||||
let res = await fetch(`${environment.endpoint}/users/send/email`, {
|
||||
let res = await fetch(`${environment.endpoint}/users/password/send/email`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ email }),
|
||||
headers: {
|
||||
|
@ -75,7 +75,7 @@ export class CAuth {
|
|||
|
||||
public async ResetPassword(email: string, password: string, token: string): Promise<IAuthResetPassword> {
|
||||
try {
|
||||
let res = await fetch(`${environment.endpoint}/users/check/email`, {
|
||||
let res = await fetch(`${environment.endpoint}/users/password/check/email`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ email, password, token }),
|
||||
headers: {
|
||||
|
|
|
@ -43,4 +43,24 @@ export interface IInvestData {
|
|||
|
||||
export interface IDeinvestData {
|
||||
id: string
|
||||
}
|
||||
}
|
||||
|
||||
export interface IInvestResponse {
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface IInvest {
|
||||
id: number;
|
||||
status: number;
|
||||
created_at: Date;
|
||||
updated_at: Date;
|
||||
_id: string;
|
||||
user_id: number;
|
||||
type: string;
|
||||
currency: string;
|
||||
value: number;
|
||||
fund_id: string;
|
||||
locked: boolean;
|
||||
}
|
||||
|
||||
export type IInvests = IInvest[]
|
|
@ -1,4 +1,4 @@
|
|||
import { IDeinvestData, IFundResponse, IFundsResponse, IFundType, IInvestData } from "./api.fund.interface";
|
||||
import { IDeinvestData, IFundResponse, IFundsResponse, IFundType, IInvestData, IInvestResponse, IInvests } from "./api.fund.interface";
|
||||
import { environment } from '../../environments/environment';
|
||||
import { Auth } from "../auth/api.auth";
|
||||
|
||||
|
@ -45,12 +45,12 @@ export class CFund {
|
|||
}
|
||||
}
|
||||
|
||||
public async Invest(data: IInvestData): Promise<void> {
|
||||
public async Invest(data: IInvestData): Promise<IInvestResponse> {
|
||||
try {
|
||||
(data as any).type = 'stake';
|
||||
(data as any).currency = 'USDT';
|
||||
|
||||
let res = await fetch(`${environment.endpoint}/fund/types`, {
|
||||
let res = await fetch(`${environment.endpoint}/stakes`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
|
@ -64,12 +64,12 @@ export class CFund {
|
|||
}
|
||||
}
|
||||
|
||||
public async Deinvest(data: IDeinvestData): Promise<void> {
|
||||
public async Deinvest(data: IDeinvestData): Promise<IInvestResponse> {
|
||||
try {
|
||||
(data as any).type = 'unstake';
|
||||
(data as any).currency = 'USDT';
|
||||
|
||||
let res = await fetch(`${environment.endpoint}/fund/types`, {
|
||||
let res = await fetch(`${environment.endpoint}/stakes`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
|
@ -82,6 +82,21 @@ export class CFund {
|
|||
return Promise.reject(error)
|
||||
}
|
||||
}
|
||||
|
||||
public async Table(): Promise<IInvests> {
|
||||
try {
|
||||
let res = await fetch(`${environment.endpoint}/stakes`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': `Bearer ${Auth.AccessToken}`
|
||||
}
|
||||
})
|
||||
return await res.json()
|
||||
} catch (error) {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const Fund: CFund = new CFund()
|
|
@ -18,6 +18,6 @@
|
|||
</span>
|
||||
|
||||
<span class="value">{{LockTime}}</span>
|
||||
<span class="postfix">ماه</span>
|
||||
<span class="postfix">روز</span>
|
||||
</p>
|
||||
</section>
|
|
@ -42,12 +42,12 @@
|
|||
|
||||
<div class="flex column ai-c">
|
||||
<span>حداقل خرید</span>
|
||||
<strong>{{item.minimum_investment}}</strong>
|
||||
<strong>{{item.minimum_investment}} USDT</strong>
|
||||
</div>
|
||||
|
||||
<div class="flex column ai-c">
|
||||
<span>میزان قفل شدن سرمایه</span>
|
||||
<strong>{{item.lock_time}}</strong>
|
||||
<strong>{{item.lock_time}} روز</strong>
|
||||
</div>
|
||||
|
||||
<a [routerLink]="'/funds/'+item.id" class="flex column ai-c">
|
||||
|
|
|
@ -71,6 +71,10 @@ export class ExchangeBoxComponent implements OnInit {
|
|||
private async _Withdraw(): Promise<void> {
|
||||
try {
|
||||
if (this.Address.length != 42 && this.Address.startsWith('0x') == false) return this._Error()
|
||||
if (this.CoreService.Wallets[0].balance < this.Amount) {
|
||||
this.CoreService.Toast('موجودی کیف پول کافی نیست.')
|
||||
return this._Error()
|
||||
}
|
||||
this.Loading = true
|
||||
let res = await this._ApiService.Transaction.Widthdraw({
|
||||
network: this.CoreService.Networks[this.Selected].type,
|
||||
|
@ -79,8 +83,10 @@ export class ExchangeBoxComponent implements OnInit {
|
|||
})
|
||||
if ([400, 401, 500].includes((res as any).statusCode)) return this.CoreService.ForgetAuth()
|
||||
this.Loading = false
|
||||
this.CoreService.Toast('عملیات با موفقیت انجام شد.')
|
||||
this.CoreService.AfterTransaction()
|
||||
} catch (error) {
|
||||
this.CoreService.Toast('خطا در برداشت رخ داد !')
|
||||
this._Error()
|
||||
}
|
||||
}
|
||||
|
@ -95,8 +101,10 @@ export class ExchangeBoxComponent implements OnInit {
|
|||
})
|
||||
if ([400, 401, 500].includes((res as any).statusCode)) return this.CoreService.ForgetAuth()
|
||||
this.Loading = false
|
||||
this.CoreService.Toast('عملیات با موفقیت انجام شد.')
|
||||
this.CoreService.AfterTransaction()
|
||||
} catch (error) {
|
||||
this.CoreService.Toast('خطا در پردازش رخ داد !')
|
||||
this._Error()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ header {
|
|||
}
|
||||
|
||||
span.title {
|
||||
font-family: "Fugaz One", cursive;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<div data-simplebar>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>نام صندوق</th>
|
||||
<th>مقدار</th>
|
||||
<th>وضعیت</th>
|
||||
<th>قفل شده</th>
|
||||
<th>تاریخ و ساعت</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr *ngFor="let item of Value">
|
||||
<td>{{FundOf(item.fund_id)}}</td>
|
||||
<td>{{item.value}} <sub>{{item.currency}}</sub> </td>
|
||||
<td [attr.status]="[Status[item.status]]">
|
||||
{{Status[item.status]}}
|
||||
</td>
|
||||
<td>
|
||||
{{item.locked?'قفل شده':'آزاد'}}
|
||||
</td>
|
||||
<td>{{CoreService.DateTimeOf(item.created_at)}}</td>
|
||||
<td>
|
||||
<button [disabled]="Disabled" (click)="Deinvest(item)">آزاد سازی</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
|
@ -0,0 +1,83 @@
|
|||
table {
|
||||
background-color: #fff;
|
||||
|
||||
width: calc(100% - 40px);
|
||||
|
||||
margin: 20px;
|
||||
|
||||
padding: 12px;
|
||||
|
||||
border-radius: 8px;
|
||||
|
||||
box-shadow: 0 3px 6px rgba($color: #000000, $alpha: 0.2);
|
||||
|
||||
border-collapse: collapse;
|
||||
|
||||
td,
|
||||
th {
|
||||
white-space: pre;
|
||||
text-align: right;
|
||||
border-bottom: 1px solid rgba($color: #000000, $alpha: 0.2);
|
||||
}
|
||||
|
||||
td {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
td:last-child,
|
||||
th:last-child {
|
||||
max-width: 45px;
|
||||
}
|
||||
|
||||
td:not(:last-child),
|
||||
th:not(:last-child) {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
th {
|
||||
opacity: 0.8;
|
||||
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
td.address {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
td[status="در حال بررسی"],
|
||||
td[status="در حال پردازش"],
|
||||
td[status="پردازش شده"] {
|
||||
color: #ffa502;
|
||||
}
|
||||
|
||||
td[status="رد شده"] {
|
||||
color: #ff6348;
|
||||
}
|
||||
|
||||
td[status="تایید شده"],
|
||||
td[status="انجام شده"] {
|
||||
color: #2ed573;
|
||||
}
|
||||
|
||||
tbody tr {
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba($color: #fff, $alpha: 0.7);
|
||||
}
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
|
||||
border-radius: 6px;
|
||||
|
||||
background-color: #1ce087;
|
||||
|
||||
&:disabled {
|
||||
color: #fff;
|
||||
background-color: #858585;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { InvestmentTableComponent } from './investment-table.component';
|
||||
|
||||
describe('InvestmentTableComponent', () => {
|
||||
let component: InvestmentTableComponent;
|
||||
let fixture: ComponentFixture<InvestmentTableComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ InvestmentTableComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(InvestmentTableComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,47 @@
|
|||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import moment from 'jalali-moment'
|
||||
import { Fund, IInvest, IInvests } from '../../../../api/api.interface';
|
||||
import { CoreService } from '../../../../core/core.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-investment-table',
|
||||
templateUrl: './investment-table.component.html',
|
||||
styleUrls: ['./investment-table.component.scss']
|
||||
})
|
||||
export class InvestmentTableComponent implements OnInit {
|
||||
|
||||
@Input() Value: IInvests = []
|
||||
@Input() Funds: Fund[] = []
|
||||
@Input() Disabled: boolean = false
|
||||
|
||||
@Output() OnDeinvest: EventEmitter<string> = new EventEmitter()
|
||||
|
||||
public Status: string[] = [
|
||||
'در حال بررسی',
|
||||
'در حال پردازش',
|
||||
'رد شده',
|
||||
'پردازش شده',
|
||||
'تایید شده',
|
||||
'انجام شده'
|
||||
]
|
||||
|
||||
constructor(public CoreService: CoreService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
public FundOf(id: string): string {
|
||||
return this.Funds.find(item => item.id.toString() == id)?.title || '-'
|
||||
}
|
||||
|
||||
public Deinvest(item: IInvest): void {
|
||||
if (item.locked) {
|
||||
let date = moment(item.created_at)
|
||||
let found = this.Funds.find(i => i.id == item.id)!
|
||||
date.add(found.lock_time, 'days')
|
||||
date.locale('fa')
|
||||
return this.CoreService.Toast(`متاسفانه امکان ازاد سازی وجه گذاشته شده تا ${date.format('MM/DD hh:mm')} وجود ندارد`)
|
||||
}
|
||||
this.OnDeinvest.emit(item.id.toString())
|
||||
}
|
||||
}
|
|
@ -51,6 +51,10 @@ export class MenuComponent implements OnInit {
|
|||
SetMenuByPath(): void {
|
||||
let path = window.location.pathname;
|
||||
this.Index = this.Menus.findIndex(item => item.path == path)
|
||||
|
||||
if (window.matchMedia('max-width: 750px').matches) {
|
||||
this.Toggle = false
|
||||
}
|
||||
}
|
||||
|
||||
Logout(): void {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="state-info flex column ai-s">
|
||||
<div class="state-info flex ai-s" [ngClass]="[flex]" >
|
||||
<div class="item flex nowrap ai-c">
|
||||
<div class="icon flex ai-c jc-c" style="background: #FDA050; color: #fff;">
|
||||
<i class="material-icons-outlined">account_balance_wallet</i>
|
||||
|
|
|
@ -2,8 +2,14 @@ div.state-info {
|
|||
width: 100%;
|
||||
min-width: 300px;
|
||||
|
||||
&.wrap {
|
||||
div.item {
|
||||
max-width: 300px;
|
||||
}
|
||||
}
|
||||
|
||||
div.item {
|
||||
margin: 0 20px 20px 20px;
|
||||
margin: 10px;
|
||||
|
||||
min-width: 300px;
|
||||
width: calc(100% - 80px);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { CoreService } from '../../../../core/core.service';
|
||||
|
||||
@Component({
|
||||
|
@ -8,6 +8,7 @@ import { CoreService } from '../../../../core/core.service';
|
|||
})
|
||||
export class StatesComponent implements OnInit {
|
||||
|
||||
@Input() flex: 'wrap' | 'column' = 'column'
|
||||
|
||||
public get Balance(): string | number {
|
||||
return this._CoreService.Wallets[0] ? this._CoreService.Wallets[0].balance : '-'
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<button [disabled]="Loading" (click)="Submit()">{{Tab == 0 ? 'گذاشتن' : 'برداشتن'}} USDT</button>
|
||||
|
||||
<ng-container *ngIf="Tab == 1">
|
||||
<span class="fee">دستمزد شبکه {{Fee}}% می باشد</span>
|
||||
<span class="fee">دستمزد شبکه {{Fee}} USDT می باشد</span>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
|
@ -18,6 +18,7 @@ import { ProfileComponent } from './routes/profile/profile.component';
|
|||
import { OverviewComponent } from './routes/overview/overview.component';
|
||||
import { TradesComponent } from './routes/trades/trades.component';
|
||||
import { KycComponent } from './routes/kyc/kyc.component';
|
||||
import { InvestmentTableComponent } from './components/investment-table/investment-table.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
@ -33,6 +34,7 @@ import { KycComponent } from './routes/kyc/kyc.component';
|
|||
TransactionCardComponent,
|
||||
KycComponent,
|
||||
StatesComponent,
|
||||
InvestmentTableComponent,
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
<p class="subtitle">با بات ملون سرمایه گذاری کنید و به صورت ماهانه برداشت کنید</p>
|
||||
|
||||
<div class="flex wrap">
|
||||
<app-states></app-states>
|
||||
<app-states flex="wrap"></app-states>
|
||||
|
||||
<section class="flex column">
|
||||
<h3>لیست سرمایه گذاری ها</h3>
|
||||
<app-investment-table [Disabled]="Loading" [Value]="Invests" [Funds]="Items"></app-investment-table>
|
||||
|
||||
<ng-container *ngIf="Selected == -1">
|
||||
<h1>يک صندوق برای سرمایه گذاری انتخاب کنید</h1>
|
||||
|
||||
|
@ -15,12 +18,12 @@
|
|||
|
||||
<div class="flex column ai-c">
|
||||
<span>حداقل خرید</span>
|
||||
<strong>{{item.minimum_investment}}</strong>
|
||||
<strong>{{item.minimum_investment}} USDT</strong>
|
||||
</div>
|
||||
|
||||
<div class="flex column ai-c">
|
||||
<span>میزان قفل شدن سرمایه</span>
|
||||
<strong>{{item.lock_time}}</strong>
|
||||
<strong>{{item.lock_time}} روز</strong>
|
||||
</div>
|
||||
|
||||
<a (click)="FetchFundById(item.id)" class="flex column ai-c">
|
||||
|
@ -41,18 +44,18 @@
|
|||
</h2>
|
||||
</div>
|
||||
<!-- <app-fund-about [Content]="Item.description" [StartAt]="StartAt(Item.init_date)"
|
||||
[Type]="TypeOf(Item.ftype)"></app-fund-about>
|
||||
<app-fund-state [MinInvestment]="Item.minimum_investment" [LockTime]="Item.lock_time">
|
||||
</app-fund-state> -->
|
||||
[Type]="TypeOf(Item.ftype)"></app-fund-about> -->
|
||||
<div class="input-container flex nowrap ai-c">
|
||||
<div class="flex column">
|
||||
<label for="amount">مقدار سرمایه گذاری USDT</label>
|
||||
<input (keyup.enter)="Invest()" [(ngModel)]="Amount" min="0" type="number" dir="ltr"
|
||||
id="amount">
|
||||
<input (keyup.enter)="Invest()" [(ngModel)]="Amount" [disabled]="Loading"
|
||||
[min]="Item.minimum_investment" type="number" dir="ltr" id="amount">
|
||||
</div>
|
||||
<button (click)="Invest()">سرمایه گذاری</button>
|
||||
<button [disabled]="Loading" (click)="Invest()">سرمایه گذاری</button>
|
||||
</div>
|
||||
<br>
|
||||
<app-fund-state [MinInvestment]="Item.minimum_investment" [LockTime]="Item.lock_time">
|
||||
</app-fund-state>
|
||||
<app-fund-price-chart [Value]="Item.chart"></app-fund-price-chart>
|
||||
<app-fund-pie-chart [Value]="Item.portfolio"></app-fund-pie-chart>
|
||||
|
||||
|
|
|
@ -10,10 +10,9 @@ main {
|
|||
}
|
||||
|
||||
section.flex.column {
|
||||
margin-right: 10%;
|
||||
margin-bottom: 20vh;
|
||||
|
||||
width: 50%;
|
||||
width: 100%;
|
||||
|
||||
p.subtitle {
|
||||
line-height: 32px;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { Fund, IFundsResponse } from '../../../../api/api.interface';
|
||||
import { Fund, IFundsResponse, IInvests } from '../../../../api/api.interface';
|
||||
import { ApiService } from '../../../../api/api.service';
|
||||
import { CoreService } from '../../../../core/core.service';
|
||||
|
||||
|
@ -24,6 +24,7 @@ export class InvestmentComponent implements OnInit {
|
|||
return `${date.getDate() + 1}/${date.getMonth() + 1}/${date.getFullYear()} ${date.getHours()}:${date.getMinutes()}`
|
||||
}
|
||||
|
||||
public Invests: IInvests = []
|
||||
public Items: IFundsResponse = []
|
||||
public Item?: Fund = undefined
|
||||
public Selected: number = -1
|
||||
|
@ -33,6 +34,7 @@ export class InvestmentComponent implements OnInit {
|
|||
constructor(private _ApiService: ApiService, private _CoreService: CoreService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.FetchInvests()
|
||||
this._FetchAll()
|
||||
}
|
||||
|
||||
|
@ -48,6 +50,16 @@ export class InvestmentComponent implements OnInit {
|
|||
try {
|
||||
this.Selected = id
|
||||
this.Item = (await this._ApiService.Fund.One(id.toString())).funds
|
||||
this.Amount = this.Item.minimum_investment
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async FetchInvests(): Promise<void> {
|
||||
try {
|
||||
this.Invests = await this._ApiService.Fund.Table()
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
@ -77,6 +89,25 @@ export class InvestmentComponent implements OnInit {
|
|||
if ([400, 401, 500].includes((res as any).code)) return this._CoreService.ForgetAuth()
|
||||
this.Loading = false
|
||||
this._CoreService.Toast('سرمایه گذاری شما انجام شد.')
|
||||
this.FetchInvests()
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public async Deinvest(id: string): Promise<void> {
|
||||
try {
|
||||
this.Loading = true
|
||||
let res = await this._ApiService.Fund.Deinvest({
|
||||
id
|
||||
})
|
||||
// error happent
|
||||
if ([400, 401, 500].includes((res as any).code)) return this._CoreService.ForgetAuth()
|
||||
this.Loading = false
|
||||
if ((res as any).status && (res as any).status == false)
|
||||
return this._CoreService.Toast('خطا در آزاد سازی رخ داد !')
|
||||
this._CoreService.Toast('آزاد سازی سرمایه گذاری شما انجام شد.')
|
||||
this.FetchInvests()
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue