Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from piyushkumar12111111/main
Browse files Browse the repository at this point in the history
updatedCode
  • Loading branch information
piyushkumar12111111 authored Apr 1, 2024
2 parents 75920f1 + 86e271d commit 7b27506
Show file tree
Hide file tree
Showing 24 changed files with 1,037 additions and 151 deletions.
22 changes: 22 additions & 0 deletions Backend/handlers/addhotelHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package handlers

import (
"encoding/json"
"net/http"

"github.com/piyushkumar/hotelsystem/models"
)

// AddHotel adds a new hotel to the list.
func AddHotel(w http.ResponseWriter, r *http.Request) {
var hotel models.Hotel
if err := json.NewDecoder(r.Body).Decode(&hotel); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

hotels = append(hotels, hotel) // Add the hotel to the in-memory store

w.WriteHeader(http.StatusCreated)
json.NewEncoder(w).Encode(hotel)
}
22 changes: 22 additions & 0 deletions Backend/handlers/deletehotelHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package handlers

import (
"net/http"
"github.com/gorilla/mux"
)

// DeleteHotel removes a hotel from the list based on its ID.
func DeleteHotel(w http.ResponseWriter, r *http.Request) {
id := mux.Vars(r)["id"]

for index, hotel := range hotels {
if hotel.ID == id {
// Remove the hotel from the slice
hotels = append(hotels[:index], hotels[index+1:]...)
w.WriteHeader(http.StatusNoContent)
return
}
}

http.Error(w, "Hotel not found", http.StatusNotFound)
}
20 changes: 20 additions & 0 deletions Backend/handlers/listhotelHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package handlers

import (
"encoding/json"
"net/http"

"github.com/piyushkumar/hotelsystem/models"
)

// In-memory store for demonstration
var hotels = []models.Hotel{
{ID: "1", Name: "Hotel Sunshine", Location: "California", Rating: 5},
{ID: "2", Name: "Grand Plaza", Location: "New York", Rating: 4},
}

// ListHotels sends a list of hotels as a JSON response.
func ListHotels(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(hotels)
}
6 changes: 5 additions & 1 deletion Backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ func main() {

log.Println("Server starting on port 9080...")

//!
//! hotel apis

r.HandleFunc("/hotels", handlers.ListHotels).Methods("GET")
r.HandleFunc("/hotel", handlers.AddHotel).Methods("POST")
r.HandleFunc("/hotel/{id}", handlers.DeleteHotel).Methods("DELETE")
// Start the server

log.Fatal(http.ListenAndServe(":9080", r))
Expand Down
9 changes: 9 additions & 0 deletions Backend/models/hotelModel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package models

// Hotel represents the hotel model.
type Hotel struct {
ID string `json:"id"`
Name string `json:"name"`
Location string `json:"location"`
Rating int `json:"rating"`
}
2 changes: 1 addition & 1 deletion Backend/tmp/build-errors.log
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
Binary file modified Backend/tmp/main.exe
Binary file not shown.
Binary file removed Backend/tmp/main.exe~
Binary file not shown.
52 changes: 26 additions & 26 deletions Frontend/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# # This file configures the analyzer, which statically analyzes Dart code to
# # check for errors, warnings, and lints.
# #
# # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# # invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
# # The following line activates a set of recommended lints for Flutter apps,
# # packages, and plugins designed to encourage good coding practices.
# include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# linter:
# # The lint rules applied to this project can be customized in the
# # section below to disable rules from the `package:flutter_lints/flutter.yaml`
# # included above or to enable additional rules. A list of all available lints
# # and their documentation is published at
# # https://dart-lang.github.io/linter/lints/index.html.
# #
# # Instead of disabling a lint rule for the entire project in the
# # section below, it can also be suppressed for a single line of code
# # or a specific dart file by using the `// ignore: name_of_lint` and
# # `// ignore_for_file: name_of_lint` syntax on the line or in the file
# # producing the lint.
# rules:
# # avoid_print: false # Uncomment to disable the `avoid_print` rule
# # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
# # Additional information about this file can be found at
# # https://dart.dev/guides/language/analysis-options
7 changes: 5 additions & 2 deletions Frontend/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) {

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
// throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
Expand All @@ -22,11 +22,14 @@ if (flutterVersionName == null) {
}

apply plugin: 'com.android.application'
// START: FlutterFire Configuration
apply plugin: 'com.google.gms.google-services'
// END: FlutterFire Configuration
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
105 changes: 105 additions & 0 deletions Frontend/android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"project_info": {
"project_number": "259327151092",
"project_id": "checking-89b41",
"storage_bucket": "checking-89b41.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:259327151092:android:6111def00b69cc17a587a1",
"android_client_info": {
"package_name": "com.example.firebase2"
}
},
"oauth_client": [
{
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA-T8G-r-9mPeqt7kaPkjv_lJk7c-tl3I4"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:259327151092:android:3232e9c4f0403779a587a1",
"android_client_info": {
"package_name": "com.example.hotel_booking"
}
},
"oauth_client": [
{
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA-T8G-r-9mPeqt7kaPkjv_lJk7c-tl3I4"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:259327151092:android:2ee71df70004724da587a1",
"android_client_info": {
"package_name": "com.firebasechekcing.projectchecking"
}
},
"oauth_client": [
{
"client_id": "259327151092-s0641c8r7b85mrdrseugtopkor64nrf9.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.firebasechekcing.projectchecking",
"certificate_hash": "e7a299b8e5bb449e34c6138c33229aeeadc36d7f"
}
},
{
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA-T8G-r-9mPeqt7kaPkjv_lJk7c-tl3I4"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
3 changes: 3 additions & 0 deletions Frontend/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ buildscript {

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
// START: FlutterFire Configuration
classpath 'com.google.gms:google-services:4.3.10'
// END: FlutterFire Configuration
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
53 changes: 53 additions & 0 deletions Frontend/lib/Screen/Authentication/controller/googlesignin.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:hotel_booking/Screen/Home/home.dart';

class AuthService {
final FirebaseAuth _auth = FirebaseAuth.instance;
final GoogleSignIn googleSignIn = GoogleSignIn();

Future<User?> signInWithGoogle(BuildContext context) async {
try {
final GoogleSignInAccount? googleSignInAccount =
await googleSignIn.signIn();
if (googleSignInAccount != null) {
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount.authentication;
final AuthCredential credential = GoogleAuthProvider.credential(
accessToken: googleSignInAuthentication.accessToken,
idToken: googleSignInAuthentication.idToken,
);
final UserCredential authResult =
await _auth.signInWithCredential(credential);
final User? user = authResult.user;

if (user != null) {
// Navigate to the HomeScreen if the sign in was successful

// Use the user's name and email
String name = user.displayName ?? "No name available";
String email = user.email ?? "No email available";

// For demonstration, let's print these values
print("Name: $name");
print("Email: $email");
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Home(),
));
}
return user;
}
} catch (error) {
print(error.toString());
return null;
}
}

Future<void> signOutGoogle() async {
await googleSignIn.signOut();
await _auth.signOut();
}
}
Loading

0 comments on commit 7b27506

Please sign in to comment.