Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Abdou Ouahib aouahib

🏠
Working from home
View GitHub Profile
@aouahib
aouahib / logged-in-page.tsx
Created Feb 21, 2021
The final version of the LoggedInPage
View logged-in-page.tsx
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();
@aouahib
aouahib / auth-slice.tsx
Created Feb 20, 2021
Final version of auth-slice.tsx
View 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,
@aouahib
aouahib / agoumi.dart
Created Oct 14, 2020
Example of how to switch pages using a button while disabling swipe in a flutter PageView
View agoumi.dart
import 'package:flutter/material.dart';
void main() async {
runApp(AgoumiApp());
}
class AgoumiApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
View doc.txt
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
View casting.dart
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);
}
View filter_specs.md

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
View oil_formdata.dart
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,
View oil_categories.json
{
"data": [
{
"_id": "category0",
"name": "Huile d'olive",
"types": [
{
"_id": "oil_category_0_type_0",
"name": "Huile d’olive vierge extra",
"acidity": "≤ 0,8 %",
View plant_types.json
{
"data": [
{
"_id": "kind_1",
"name": "Olivier",
"varieties": [
{
"_id": "kind_1_variety_1",
"name": "Picholine marocaine"
},
View animal_creation_formdata.dart
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'],