import * as React from 'react';
import { Text, View } from 'react-native';
import { readRemoteFile } from 'react-native-csv';
import { IServiceControl } from "../../handlers/ControlInterface";
let inputDataset = ["../../datasets/productCategories.csv"];
export class StoreListService{
storeService: { svc: any; query: any; };
constructor(event: any,type: any){
this.storeService = {
svc: event,
query: type
}
}
svc: string | undefined;
query: string | undefined;
protected serviceList(event : IServiceControl){
switch(event.svc){
case "categories":
let list = new Map<string, any>();
readRemoteFile(inputDataset[0], {
download: true,
header: true,
complete: (results) => {
var rows = results.data;
for(let i = 0; i < rows.length; i++){
list.set("id",rows[i].ID);
list.set("cat",rows[i].Category);
}
}
});
return list;
break;
default: return null; break;
}
}
public eventStart(){
return this.serviceList(this.storeService);
}
}
import * as React from 'react';
import { FlatList, Text, View } from 'react-native';
import { StoresFeed } from '../handlers/stores/homepage/Feed';
import { StoreListService } from '../services/stores/homepage/List';
const CatsRender = ({item}: {item: any}) => {
return <Text style={pageStyle.LCList}>{item.cat}</Text>
}
export function Stores(){
return (
<React.Fragment>
<View style={screenStyle.list}>
<Text style={pageStyle.list}>Категории</Text>
<FlatList data={catList} renderItem={CatsRender} />
</View>
</React.Fragment>
);
}
const pageStyle = new StoresFeed('ui-change',0).eventStart(),
screenStyle = new StoresFeed('ui-change',1).eventStart();
let catList = new StoreListService('categories',null).eventStart();
Invalid Argument – yii\base\InvalidArgumentException
Invalid path alias: @frontend/views/index.php
import * as React from 'react';
import { Text, View } from 'react-native';
import { IServiceControl } from "../../handlers/ControlInterface";
const util = require('util'),
request = util.promisify(require('request')),
Fs = require('fs'),
Fsp = Fs.promises;
const CsvReadableStream = require('csv-reader');
let inputDataset = [
Fsp.createReadStream('../datasets/productCategories.csv', 'utf8').pipe(new CsvReadableStream({ parseNumbers: true, parseStrings: true, trim: true }))
];
export class StoreListService{
storeService: { svc: any; query: any; };
constructor(event: any,type: any){
this.storeService = {
svc: event,
query: type
}
}
svc: string | undefined;
query: string | undefined;
protected serviceList(event : IServiceControl){
switch(event.svc){
case "categories":
let list: any[];
inputDataset[0].on('data',function(row){
for(let i = 0; i < row.ID.length; i++){
list[$i]['id'] = row.ID[i];
list[$i]['cat'] = row.Category[i];
}
});
return JSON.stringify(list);
break;
default: return null; break;
}
}
public eventStart(){
return this.serviceList(this.storeService);
}
}
<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use yii\web\View;
class NewsController extends Controller{
public function actionIndex(){
return $this->render('news/index');
}
public function actionView($contentId){
return $this->render('news/view');
}
}
?>
import { StyleSheet, TextStyle } from 'react-native';
import { IHandlerControl } from "../../ControlInterface";
export class StoresFeed{
storesFeed: any;
constructor(event: any,type: any){
this.storesFeed = {
screenEvent: event,
eventType: type
}
}
protected handlerFeed(event : IHandlerControl){
if(event.screenEvent === 'ui-change'){
if(event.eventType == 0){
//Нулевое значение - это то, чего касается первоначальных элементов и компонентов
type Style = {
feedTitle: TextStyle,
listTitle: TextStyle,
FCtitle: TextStyle,
FCdescription: TextStyle,
FCprice: TextStyle,
FClink: TextStyle,
LClist: TextStyle,
LCprint: TextStyle
};
return StyleSheet.create<Style>({
feedTitle: {
color: '#ff0033',
fontSize: 70,
fontWeight: 'bold',
marginLeft: 2,
paddingTop: 1,
paddingBottom: 1
},
listTitle: {
color: '#d83b01',
fontSize: 60,
fontWeight: 'bold',
marginLeft: 2,
paddingTop: 1,
paddingBottom: 1
},
FCtitle:{
fontSize: 66,
fontStyle: 'italic'
},
FCdescription:{
fontSize: 50
},
FCprice:{
fontSize: 55,
fontWeight: 'bold'
},
FClink:{
fontSize: 45,
fontStyle: 'normal'
},
LClist:{
fontSize: 50
},
LCprint:{
color: '#201f1e',
fontStyle: 'italic'
}
});
}
}
}
public eventStart(){
this.handlerFeed(this.storesFeed);
}
}
<?php
namespace yii\components\CommunicationService;
use yii\base\Component;
use yii\db\Query;
use yii\models\UserService;
function getRandomFromRange(min, max) {
return rand() * (max - min) + min;
}
class SMSCode extends Component{
public $service;
public $code;
public $phone;
public function init(){
parent::init();
$this->service = 'signUp';
$this->code = 1234;
$this->phone = '9198298765';
}
public function sendCode($service = '', $phone = '', $code = null){
if($service != '' && $phone != '' && $code != null){
$this->service = $service;
$this->phone = $phone;
$this->code = $code;
}
$sms = new SenderCode();
$message = "";
switch($this->service){
case 'Forgot': $message = " - Restore your account access code"; break;
default: $message = " - Your account registration confirm code"; break;
}
$from = 'Investportal<9198298765@vtext.com>';
$to = $this->phone . '@vtext.com';
$content = $code . $message . "";
$sms->period = date('');
$sms->phone = $this->phone;
$sms->code = $this->code;
$sms->service = $this->service;
$smsStorage = $sms->save();
$smsMessage = mail($to,'', $content, "From: " . $from ."\n");
if($smsStorage && $smsMessage){ throw new HttpException(202 ,'SMS code send success!');}
else{ throw new HttpException(409 ,'The portal accounting service is temporarily unavailable! Try again later;-('); }
}
public function validCode($service = '', $phone = '', $code = null){
if($service != '' && $phone != '' && $code != null){
$this->service = $service;
$this->phone = $phone;
$this->code = $code;
}
$sms = SenderCode::find();
$validCode = $sms->where(['and',['code' => $this->code],['phone' => $this->phone],['service' => $this->service]])->all();
$deleteCode = (new Query)->createCommand()->delete('users', ['and',['code' => $this->code],['phone' => $this->phone],['service' => $this->service]])->execute();
foreach($validCode as $data){
if($this->code === $data->code){
if($deleteCode){ throw new HttpException(202 ,'SMS code is valid!');}
else{ throw new HttpException(409 ,'The portal accounting service is temporarily unavailable! Try again later;-('); }
}
else{ throw new HttpException(403 ,'The code is entered incorrectly and check it carefully, please!'); }
}
}
}
?>
<?php
namespace yii\components\SignService;
use yii\base\Component;
use yii\helpers\Json;
use app\models\UserService;
class SignUp extends Component{
public $type;
public $signQuery;
public function init(){
parent::init();
$this->signQuery = [];
$this->type = '';
}
public function proccess($signQuery = null, $type = ''){
if($signQuery != null && $type != ''){
$this->signQuery = $signQuery;
$this->type = $type;
}
$upModel = [
User::find(),
new User()
];
if($type === 'fbService'){
$token = $this->signQuery['fbToken'];
}
else{
$login = $this->signQuery['login'];
$pass = sha1($this->signQuery['password']);
$firstname = $this->signQuery['fn'];
$surname = $this->signQuery['sn'];
$mail = $this->signQuery['email'];
$phone = $this->signQuery['phone'];
$region = $this->signQuery['country'];
$isAccept = $this->signQuery['isAccept'] === TRUE;
$validLogin = $upModel[0]->where(['login' => $login])->all();
$validEMail = $upModel[0]->where(['email' => $mail])->all();
$validPassword = $upModel[0]->where(['password' => $pass])->all();
$validPhone = $upModel[0]->where(['phone' => $phone])->all();
if(!$validLogin && !$validEMail && !$validPassword && !$validPhone){
if($isAccept){
$upModel[1]->firstname = $firstname;
$upModel[1]->surname = $surname;
$upModel[1]->login = $login;
$upModel[1]->password = $pass;
$upModel[1]->email = $mail;
$upModel[1]->phone = $phone;
$upModel[1]->country = $region;
$upModel[1]->isAccept= TRUE;
if($upModel[1]->save()){ throw new HttpException(202 ,'Registration success!'); }
else{ throw new HttpException(409 ,'The portal accounting service is temporarily unavailable! Try again later;-('); }
}
else{ throw new HttpException(500 ,'New account data not is accept!'); }
}
else{
$validError = [];
header('Content-type: application/json;charset=UTF-8');
if($validLogin){ $validError[]['validError'] = 'The login you entered exists'; }
if($validEMail){ $validError[]['validError'] = 'The e-mail you entered exists'; }
if($validPassword){ $validError[]['validError'] = 'The password you entered exists'; }
if($validPhone){ $validError[]['validError'] = 'The phone number you entered exists'; }
throw new HttpException(400 ,Json::encode($validError));
}
}
}
}
class SignIn extends Component{
public $type;
public $signQuery;
public function init(){
parent::init();
$this->signQuery = [];
$this->type = '';
}
public function proccess($signQuery = null, $type = ''){
if($signQuery != null && $type != ''){
$this->signQuery = $signQuery;
$this->type = $type;
}
$inModel = User::find();
if($type === 'fbService'){
$token = $this->signQuery['fbToken'];
}
else{
$login = $this->signQuery['portalId'];
$pass = sha1($this->signQuery['password']);
$isLogin = $inModel->where(['login' => $login])->all() || $inModel->where(['email' => $login])->all() || $inModel->where(['phone' => $login])->all();
$isPass = $inModel->where(['password' => $pass]);
if($isLogin && $isPass){
$auth = User::findOne(['login' => $login]) || User::findOne('email' => $login]) || User::findOne(['phone' => $login]);
if(Yii::$app->user->login($auth)){ throw new HttpException(202 ,'Authorization success!'); }
else{ throw new HttpException(409 ,'The portal accounting service is temporarily unavailable! Try again later;-('); }
}
else{
$validError = [];
header('Content-type: application/json;charset=UTF-8');
if(!$isLogin){ $validError[]['validError'] = 'The login you entered no exists'; }
if(!$isPass){ $validError[]['validError'] = 'The password you entered exists'; }
throw new HttpException(400 ,Json::encode($validError));
}
}
}
}
class AutoSignIn extends Component{
public $signQuery;
public function init(){
parent::init();
$this->signQuery = [];
}
public function proccess($signQuery = null){
if($signQuery != null){ $this->signQuery = $signQuery; }
$inModel = User::find();
$login = $this->signQuery['portalId'];
$auth = User::findOne(['login' => $login]);
if(Yii::$app->user->login($auth)){ throw new HttpException(202 ,'First authorization success!'); }
else{ throw new HttpException(409 ,'The portal accounting service is temporarily unavailable! Try again later;-('); }
}
}
class Forgot extends Component{
public $signQuery;
public function init(){
parent::init();
$this->signQuery = [];
}
public function proccess($signQuery = null){
if($signQuery != null){
$this->signQuery = $signQuery;
}
$forgotModel = User::find();
$login = $this->signQuery['portalId'];
$newPass = sha1($this->signQuery['password']);
$isAccept = $this->signQuery['isAccept'] === TRUE;
$isLogin = $inModel->where(['login' => $login])->all() || $inModel->where(['email' => $login])->all() || $inModel->where(['phone' => $login])->all();
if($isLogin){
if($isAccept){
$forgotModel->filterWhere(['or',['login' => $login],['email' => $login],['phone' => $login]]);
$forgotModel->password = $newPass;
if($forgotModel->save()){ throw new HttpException(202 ,'Access restore success!'); }
else{ throw new HttpException(409 ,'The portal accounting service is temporarily unavailable! Try again later;-('); }
}
else{ throw new HttpException(500 ,'Account data for restore not is accept!'); }
}
else{
$validError = [];
header('Content-type: application/json;charset=UTF-8');
if(!$isLogin){ $validError[]['validError'] = 'The login you entered no exists'; }
throw new HttpException(400 ,Json::encode($validError));
}
}
}
class SignOut extends Component{
public function init(){ parent::init(); }
public function proccess(){
$out = Yii::app()->user->logout();
if($out){ throw new HttpException(202 ,'Sign account out success!'); }
else{ throw new HttpException(409 ,'The portal accounting service is temporarily unavailable! Try again later;-('); }
}
}
?>
<?php
namespace app\controllers;
use Yii;
use yii\web\controllers;
use yii\web\View;
use linslin\yii2\curl\Curl;
class SiteController extends Controller{
public function actionIndex(){
$this->registerCssFile("/css/inpage_codes/homepage_styles.css", 'homepage-ui');
$this->registerJsFile("/js/inpage_codes/homepage_script.js", View::POS_END, 'homepage-ux');
return $this->render('index');
}
public function actionAccountService($service){
$q = json_decode($_POST['serviceQuery']);
switch($service){
case "signIn":
if($_POST['serviceQuery']){
$sign = $q['asq']; //Authoriation service query
$type = $q['asqt']; //ASQ Type
Yii::app->portalUserService->SignIn->proccess($sign,$type);
}
else{ throw new HttpException(405 ,'Query conflict'); }
break;
case "signUp":
if($_POST['serviceQuery']){
$sign = $q['rsq']; //Registration service query
$type = $q['rsqt']; //RSQ Type
Yii::app->portalUserService->SignUp->proccess($sign,$type);
}
else{ throw new HttpException(405 ,'Query conflict'); }
break;
case "forgot":
if($_POST['serviceQuery']){
$sign = $q['fsq']; //Forgot service query
Yii::app->portalUserService->Forgot->proccess($sign);
}
else{ throw new HttpException(405 ,'Query conflict'); }
break;
case "autoAuth":
if($_POST['serviceQuery']){
$sign = $q['fsq']; //Forgot service query
Yii::app->portalUserService->AutoSignIn->proccess($sign);
}
else{ throw new HttpException(405 ,'Query conflict'); }
break;
case "signOut":
if(!Yii::$app->user->isGuest){ Yii::app->portalUserService->SignOut->proccess(); }
else{ throw new HttpException(405 ,'Service conflict'); }
break;
default: throw new HttpException(404 ,'Service not found'); break;
}
}
public function actionServiceCodeCenter($service){
$q = json_decode($_POST['serviceQuery']);
switch($service){
case "signUp":
if($_POST['serviceQuery']){
$sign = $q['rsq']; //Registration service query
if($sign['service'] === 'Inbox'){
$query = json_encode(['fsq' => ['svc' => 'SignUp']]);
$wsInit = new Curl();
$query = $wsInit->post((!empty($_SERVER['HTTPS'])) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] ."/accounts/accept/codeGenerator")->setOption(CURLOPT_POSTFIELDS, http_build_query(array('serviceQuery' => $query)));
$sign['code'] = $query;
}
if($sign['service'] === 'Inbox'){ Yii::app->portalCommunicationService->SMSCode->sendCode('SignUp', $sign['phone']); }
else if($sign['service'] === 'Valid'){ Yii::app->portalCommunicationService->SMSCode->validCode('SignUp', $sign['phone'], $sign['code']); }
else{ throw new HttpException(403 ,'Operation conflict'); }
}
else{ throw new HttpException(405 ,'Query conflict'); }
break;
case "forgot":
if($_POST['serviceQuery']){
$sign = $q['fsq']; //Forgot service query
if($sign['service'] === 'Inbox'){
$query = json_encode(['fsq' => ['svc' => 'Forgot']]);
$wsInit = new Curl();
$query = $wsInit->post((!empty($_SERVER['HTTPS'])) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] ."/accounts/accept/codeGenerator")->setOption(CURLOPT_POSTFIELDS, http_build_query(array('serviceQuery' => $query)));
$sign['code'] = $query;
}
if($sign['service'] === 'Inbox'){ Yii::app->portalCommunicationService->SMSCode->sendCode('Forgot', $sign['phone']); }
else if($sign['service'] === 'Valid'){ Yii::app->portalCommunicationService->SMSCode->validCode('Forgot', $sign['phone'], $sign['code']); }
else{ throw new HttpException(403 ,'Operation conflict'); }
}
else{ throw new HttpException(405 ,'Query conflict'); }
break;
case "codeGenerator":
if($_POST['serviceQuery']){
$source = $q['fsq'];
$generateCode = [
ceil(getRandomFromRange(1000,9999)),
ceil(getRandomFromRange(2000,4600))
];
$isSignUp = $source['svc'] === 'SignUp' ? TRUE : FALSE;
$isForgot = $source['svc'] === 'Forgot' ? TRUE : FALSE;
if($isSignUp){ $newCode = $generateCode[0]; }
else if($isForgot){ $newCode = $generateCode[1]; }
throw new HttpException(201 ,$newCode);
}
else{ throw new HttpException(405 ,'Query conflict'); }
break;
default: throw new HttpException(404 ,'Service not found'); break;
}
}
}
?>
Errors in code
- Type 'Style' does not satisfy the constraint 'NamedStyles | NamedStyles
- Type 'Style' is not assignable to type 'NamedStyles
- Types of property 'feedCont' are incompatible.
- Type '[title: TextStyle, description: TextStyle, price: TextStyle, link: TextStyle]' is not assignable to type 'TextStyle | ViewStyle | ImageStyle'.
- Type '[title: TextStyle, description: TextStyle, price: TextStyle, link: TextStyle]' has no properties in common with type 'ImageStyle'.
- Cannot find name 'title'.
- Cannot find name 'description'.
- Cannot find name 'price'.
- Cannot find name 'link'.
- Cannot find name 'list'.
- ',' expected.
- ',' expected.
- ',' expected.
- ',' expected.
- ',' expected.
- ',' expected.
- ',' expected.
import { StyleSheet, TextStyle, ViewStyle } from 'react-native';
import { IHandlerControl } from "../../ControlInterface";
export class StoresFeed{
storesFeed: any;
constructor(event: any,type: any){
this.storesFeed = {
screenEvent: event,
eventType: type
}
}
protected handlerFeed(event : IHandlerControl){
if(event.screenEvent === 'ui-change'){
type Style = {
feedTitle: TextStyle,
listTitle: TextStyle,
feedCont: [
title: TextStyle,
description: TextStyle,
price: TextStyle,
link: TextStyle
],
listCont: [
list: ViewStyle,
print: TextStyle
]
};
if(event.eventType == 0){
//Нулевое значение - это то, чего касается первоначальных элементов и компонентов
return StyleSheet.create<Style>({
feedTitle: {
color: '#ff0033',
fontSize: '140%',
fontWeight: 'bold',
marginLeft: '2%',
paddingTop: '1%',
paddingBottom: '1%'
},
listTitle: {
color: '#d83b01',
fontSize: '120%',
fontWeight: 'bold',
marginLeft: '2%',
paddingTop: '1%',
paddingBottom: '1%'
},
feedCont: [
title:{
fontSize: '130%',
fontWeight: 'italic'
},
description:{
fontSize: '100%'
},
price:{
fontSize: '110%',
fontWeight: 'bold'
}
link:{
fontSize: '90%',
fontWeight: 'normal'
}
],
listCont: [
list:{
fontSize: '100%'
},
print:{
color: '#201f1e',
fontWeight: 'italic'
}
]
});
}
}
}
public eventStart(){
this.handlerFeed(this.storesFeed);
}
}