Skip to content

Commit

Permalink
probably nuked it
Browse files Browse the repository at this point in the history
  • Loading branch information
mikezamayias committed Jan 18, 2022
1 parent d665b9a commit 8ec3c23
Show file tree
Hide file tree
Showing 15 changed files with 279 additions and 196 deletions.
23 changes: 0 additions & 23 deletions .firebase/hosting.YnVpbGQvd2Vi.cache

This file was deleted.

6 changes: 6 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
2 changes: 0 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

import 'ecommerce_website.dart';
import 'firebase_options.dart';
Expand All @@ -13,6 +12,5 @@ void main() async {
options: DefaultFirebaseOptions.currentPlatform,
);
setupLocator();
await dotenv.load(fileName: ".env");
runApp(const EcommerceWebsite());
}
4 changes: 1 addition & 3 deletions lib/models/user/user_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class UserModel with _$UserModel {
String? lastName,
String? email,
String? phoneNumber,
String? address,
String? city,
String? postalCode,
String? streetAddress,
String? userOrdersUid,
String? userCartUid,
}) = _UserModel;
Expand Down
86 changes: 20 additions & 66 deletions lib/models/user/user_model.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ class _$UserModelTearOff {
String? lastName,
String? email,
String? phoneNumber,
String? address,
String? city,
String? postalCode,
String? streetAddress,
String? userOrdersUid,
String? userCartUid}) {
return _UserModel(
Expand All @@ -39,9 +37,7 @@ class _$UserModelTearOff {
lastName: lastName,
email: email,
phoneNumber: phoneNumber,
address: address,
city: city,
postalCode: postalCode,
streetAddress: streetAddress,
userOrdersUid: userOrdersUid,
userCartUid: userCartUid,
);
Expand All @@ -62,9 +58,7 @@ mixin _$UserModel {
String? get lastName => throw _privateConstructorUsedError;
String? get email => throw _privateConstructorUsedError;
String? get phoneNumber => throw _privateConstructorUsedError;
String? get address => throw _privateConstructorUsedError;
String? get city => throw _privateConstructorUsedError;
String? get postalCode => throw _privateConstructorUsedError;
String? get streetAddress => throw _privateConstructorUsedError;
String? get userOrdersUid => throw _privateConstructorUsedError;
String? get userCartUid => throw _privateConstructorUsedError;

Expand All @@ -84,9 +78,7 @@ abstract class $UserModelCopyWith<$Res> {
String? lastName,
String? email,
String? phoneNumber,
String? address,
String? city,
String? postalCode,
String? streetAddress,
String? userOrdersUid,
String? userCartUid});
}
Expand All @@ -106,9 +98,7 @@ class _$UserModelCopyWithImpl<$Res> implements $UserModelCopyWith<$Res> {
Object? lastName = freezed,
Object? email = freezed,
Object? phoneNumber = freezed,
Object? address = freezed,
Object? city = freezed,
Object? postalCode = freezed,
Object? streetAddress = freezed,
Object? userOrdersUid = freezed,
Object? userCartUid = freezed,
}) {
Expand All @@ -133,17 +123,9 @@ class _$UserModelCopyWithImpl<$Res> implements $UserModelCopyWith<$Res> {
? _value.phoneNumber
: phoneNumber // ignore: cast_nullable_to_non_nullable
as String?,
address: address == freezed
? _value.address
: address // ignore: cast_nullable_to_non_nullable
as String?,
city: city == freezed
? _value.city
: city // ignore: cast_nullable_to_non_nullable
as String?,
postalCode: postalCode == freezed
? _value.postalCode
: postalCode // ignore: cast_nullable_to_non_nullable
streetAddress: streetAddress == freezed
? _value.streetAddress
: streetAddress // ignore: cast_nullable_to_non_nullable
as String?,
userOrdersUid: userOrdersUid == freezed
? _value.userOrdersUid
Expand All @@ -169,9 +151,7 @@ abstract class _$UserModelCopyWith<$Res> implements $UserModelCopyWith<$Res> {
String? lastName,
String? email,
String? phoneNumber,
String? address,
String? city,
String? postalCode,
String? streetAddress,
String? userOrdersUid,
String? userCartUid});
}
Expand All @@ -192,9 +172,7 @@ class __$UserModelCopyWithImpl<$Res> extends _$UserModelCopyWithImpl<$Res>
Object? lastName = freezed,
Object? email = freezed,
Object? phoneNumber = freezed,
Object? address = freezed,
Object? city = freezed,
Object? postalCode = freezed,
Object? streetAddress = freezed,
Object? userOrdersUid = freezed,
Object? userCartUid = freezed,
}) {
Expand All @@ -219,17 +197,9 @@ class __$UserModelCopyWithImpl<$Res> extends _$UserModelCopyWithImpl<$Res>
? _value.phoneNumber
: phoneNumber // ignore: cast_nullable_to_non_nullable
as String?,
address: address == freezed
? _value.address
: address // ignore: cast_nullable_to_non_nullable
as String?,
city: city == freezed
? _value.city
: city // ignore: cast_nullable_to_non_nullable
as String?,
postalCode: postalCode == freezed
? _value.postalCode
: postalCode // ignore: cast_nullable_to_non_nullable
streetAddress: streetAddress == freezed
? _value.streetAddress
: streetAddress // ignore: cast_nullable_to_non_nullable
as String?,
userOrdersUid: userOrdersUid == freezed
? _value.userOrdersUid
Expand All @@ -253,9 +223,7 @@ class _$_UserModel implements _UserModel {
this.lastName,
this.email,
this.phoneNumber,
this.address,
this.city,
this.postalCode,
this.streetAddress,
this.userOrdersUid,
this.userCartUid});

Expand All @@ -273,19 +241,15 @@ class _$_UserModel implements _UserModel {
@override
final String? phoneNumber;
@override
final String? address;
@override
final String? city;
@override
final String? postalCode;
final String? streetAddress;
@override
final String? userOrdersUid;
@override
final String? userCartUid;

@override
String toString() {
return 'UserModel(uid: $uid, firstName: $firstName, lastName: $lastName, email: $email, phoneNumber: $phoneNumber, address: $address, city: $city, postalCode: $postalCode, userOrdersUid: $userOrdersUid, userCartUid: $userCartUid)';
return 'UserModel(uid: $uid, firstName: $firstName, lastName: $lastName, email: $email, phoneNumber: $phoneNumber, streetAddress: $streetAddress, userOrdersUid: $userOrdersUid, userCartUid: $userCartUid)';
}

@override
Expand All @@ -299,10 +263,8 @@ class _$_UserModel implements _UserModel {
const DeepCollectionEquality().equals(other.email, email) &&
const DeepCollectionEquality()
.equals(other.phoneNumber, phoneNumber) &&
const DeepCollectionEquality().equals(other.address, address) &&
const DeepCollectionEquality().equals(other.city, city) &&
const DeepCollectionEquality()
.equals(other.postalCode, postalCode) &&
.equals(other.streetAddress, streetAddress) &&
const DeepCollectionEquality()
.equals(other.userOrdersUid, userOrdersUid) &&
const DeepCollectionEquality()
Expand All @@ -317,9 +279,7 @@ class _$_UserModel implements _UserModel {
const DeepCollectionEquality().hash(lastName),
const DeepCollectionEquality().hash(email),
const DeepCollectionEquality().hash(phoneNumber),
const DeepCollectionEquality().hash(address),
const DeepCollectionEquality().hash(city),
const DeepCollectionEquality().hash(postalCode),
const DeepCollectionEquality().hash(streetAddress),
const DeepCollectionEquality().hash(userOrdersUid),
const DeepCollectionEquality().hash(userCartUid));

Expand All @@ -341,9 +301,7 @@ abstract class _UserModel implements UserModel {
String? lastName,
String? email,
String? phoneNumber,
String? address,
String? city,
String? postalCode,
String? streetAddress,
String? userOrdersUid,
String? userCartUid}) = _$_UserModel;

Expand All @@ -361,11 +319,7 @@ abstract class _UserModel implements UserModel {
@override
String? get phoneNumber;
@override
String? get address;
@override
String? get city;
@override
String? get postalCode;
String? get streetAddress;
@override
String? get userOrdersUid;
@override
Expand Down
8 changes: 2 additions & 6 deletions lib/models/user/user_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions lib/services/authentication_service.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';

import '../models/user/user_model.dart';
import 'firestore_service.dart';

class AuthenticationService {
Expand Down Expand Up @@ -30,14 +29,27 @@ class AuthenticationService {
Future<Object> signUpWithEmailAndPassword({
required String email,
required String password,
required String firstName,
required String lastName,
required String phoneNumber,
required String streetAddress,
required String city,
required String postalCode,
}) async {
try {
var authResult = await _auth.createUserWithEmailAndPassword(
email: email,
password: password,
);
await FirestoreService(uid: authResult.user!.uid)
.updateUserData(UserModel());
await FirestoreService().updateUserData(
email: email,
firstName: firstName,
lastName: lastName,
phoneNumber: phoneNumber,
streetAddress: streetAddress,
city: city,
postalCode: postalCode,
);
return authResult.user != null;
} catch (e) {
return e.toString();
Expand Down
23 changes: 19 additions & 4 deletions lib/services/firestore_service.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_ecommerce_website_demo/models/user/user_model.dart';

class FirestoreService {
String? uid;
Expand All @@ -19,8 +18,24 @@ class FirestoreService {
FirebaseFirestore.instance.collection('userOrders');

// Future - Update User Data
Future<void> updateUserData(UserModel userModel) {
return userCollection.doc(uid).set(userModel.toJson());
Future<void> updateUserData({
required String email,
required String firstName,
required String lastName,
required String phoneNumber,
required String streetAddress,
required String city,
required String postalCode,
}) async {
return userCollection.doc(uid).set({
email: email,
firstName: firstName,
lastName: lastName,
phoneNumber: phoneNumber,
streetAddress: streetAddress,
city: city,
postalCode: postalCode,
});
}

// Stream - Get User Data
Expand All @@ -29,7 +44,7 @@ class FirestoreService {
}

// Stream - Get Phone Data
Stream<QuerySnapshot<Object?>> get phones {
Stream<QuerySnapshot<Object?>> get phones {
return phonesCollection.snapshots();
}
}
Loading

0 comments on commit 8ec3c23

Please sign in to comment.