Skip to content

Instantly share code, notes, and snippets.

View 0xabdou's full-sized avatar
🏠
Working from home

abdou 0xabdou

🏠
Working from home
View GitHub Profile
@0xabdou
0xabdou / logged-in-page.tsx
Created February 21, 2021 18:00
The final version of the LoggedInPage
import {Avatar, Button, createStyles, makeStyles, Theme} from "@material-ui/core";
import {useCallback} from "react";
import {nonDraggable, textSelectable} from "../../../styles/shared";
import {useAppDispatch, useAppSelector} from "../../../app/redux-hooks";
import {shallowEqual} from "react-redux";
import {useAuthActions} from "../auth-actions-context";
const LoggedInPage = () => {
const user = useAppSelector(state => state.auth.currentUser, shallowEqual);
const dispatch = useAppDispatch();
@0xabdou
0xabdou / auth-slice.tsx
Created February 20, 2021 21:08
Final version of auth-slice.tsx
import {createAsyncThunk, createSlice} from "@reduxjs/toolkit";
import User from "./types/user";
import AuthError from "./types/auth-error";
import {EmailPass} from "./types/email-pass";
import {StoreExtraArg} from "../../app/dependencies";
import {isRight} from "fp-ts/Either";
export type AuthState = {
currentUser: User | null,
loading: boolean,
@0xabdou
0xabdou / agoumi.dart
Created October 14, 2020 11:49
Example of how to switch pages using a button while disabling swipe in a flutter PageView
import 'package:flutter/material.dart';
void main() async {
runApp(AgoumiApp());
}
class AgoumiApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@0xabdou
0xabdou / doc.txt
Last active September 24, 2020 12:10
NOTE: When creating a user, store only the jwt token, the phone number,
and facebook id if provided, the name and other user info are handled
in the next steps using already existing endpoints
NOTE: user info to be returned are: userId, phoneNumber, authToken
########### Endpoints with no authentication needed ##############
* loginWithFacebook: POST, params = {fbToken : String}
- Make a get request to facebook api with the token, and retrieve the facebook id
void main() {
final json = <String, dynamic>{
'price1': 1,
'price2': 1.1,
};
final price1 = double.parse(json['price1'].toString());
final price2 = double.parse(json['price2'].toString());
print(price1);
print(price2);
}

Filters request params

page: int, used for pagination

orderBy: String, ["mostRecent", "rating", "priceAsc"]

if one of the next location params is not null, the rest is also not null:

  1. lon: double, longitude of listing location
  2. lat: double, latitude of listing location
  3. radius: int, radius from (lat, lon) point, return all listings inside it
final formDataMap = {
'photos': photos,
'category_id': creation.category.id,
'type_id': creation.type.id,
'quantity': creation.quantity,
'locationLat': creation.location.latitude,
'locationLong': creation.location.longitude,
'areaNameAr': creation.location.localizedAreaName['ar'],
'areaNameFr': creation.location.localizedAreaName['fr'],
'hideNumber': creation.phoneHidden,
{
"data": [
{
"_id": "category0",
"name": "Huile d'olive",
"types": [
{
"_id": "oil_category_0_type_0",
"name": "Huile d’olive vierge extra",
"acidity": "≤ 0,8 %",
{
"data": [
{
"_id": "kind_1",
"name": "Olivier",
"varieties": [
{
"_id": "kind_1_variety_1",
"name": "Picholine marocaine"
},
final formDataMap = {
'photos': photos,
'type_id': creation.type.id,
'variety_id': creation.variety.id,
'destination_id': creation.destination.id,
'food_ids': creation.food.map((f) => f.id).toList(),
'locationLat': creation.location.latitude,
'locationLong': creation.location.longitude,
'areaNameAr': creation.location.localizedAreaName['ar'],
'areaNameFr': creation.location.localizedAreaName['fr'],