Skip to content

Commit

Permalink
Merge branch 'master' into order-bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
beeppy committed Jun 8, 2020
2 parents 78c09cf + 5147a17 commit 37a5187
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 56 deletions.
5 changes: 3 additions & 2 deletions firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ service cloud.firestore {
'menu_combined',
'tagsValue',
'claps',
'takesg'
]) && fields.size() == 41
'takesg',
'custom'
]) && fields.size() == 42
}

// TODO: Need structure
Expand Down
86 changes: 49 additions & 37 deletions src/Components/Custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Custom extends React.Component {
creating: false,
created: false,
invalid: false,
firebaseUser: null
firebaseUser: null,
};
}

Expand All @@ -52,9 +52,9 @@ export class Custom extends React.Component {
getSteps = () => {
return [
"Step 1: Create Account",
"Step 2: Select Listing",
"Step 3: Choose Domain Name",
"Step 4: Create Domain/Website",
"Step 2: Select Your Listing",
"Step 3: Create Your Unique Link!",
"Step 4: Create Your Website",
];
};

Expand All @@ -75,11 +75,12 @@ export class Custom extends React.Component {
.then((snapshot) => {
var data = [];
snapshot.forEach((element) => {
data.push({
name: element.data().name,
id: element.id,
cover: element.data().url ? element.data().url : null,
});
if (!element.data().custom)
data.push({
name: element.data().name,
id: element.id,
cover: element.data().url ? element.data().url : null,
});
});
this.setState({ options: data });
return data;
Expand All @@ -90,20 +91,22 @@ export class Custom extends React.Component {
this.setState({ data: data, retrieved: true });
};

createDomain = async (redirect) => {
createDomain = async () => {
this.setState({ creating: true });
await db
.collection("pages")
.doc(this.state.name)
.set({
redirect: redirect,
css: { menu_color: "", menu_font_color: "" },
docid: this.state.id,
logo: "",
cover: this.state.cover,
user: this.state.firebaseUser.uid
user: this.state.firebaseUser.uid,
})
.then((d) => {
.then(async (d) => {
await db.collection("hawkers").doc(this.state.id).update({
custom: true,
});
this.setState({ creating: false, created: true });
});
};
Expand Down Expand Up @@ -200,10 +203,13 @@ export class Custom extends React.Component {
</p>
</div>
) : (
<StyledFirebaseAuth
uiConfig={uiConfigPage}
firebaseAuth={firebase.auth()}
/>
<div>
<StyledFirebaseAuth
uiConfig={uiConfigPage}
firebaseAuth={firebase.auth()}
/>
<br />
</div>
)}
</React.Fragment>
);
Expand Down Expand Up @@ -324,35 +330,39 @@ export class Custom extends React.Component {
<br />
<br />
<Button
onClick={() => this.createDomain(true)}
variant="contained"
color="secondary"
disabled={this.state.created || this.state.creating}
style={{ margin: "10px" }}
>
Create Subdomain
</Button>
<Button
onClick={() => this.createDomain(false)}
onClick={() => this.createDomain()}
variant="contained"
color="secondary"
disabled={this.state.created || this.state.creating}
style={{ margin: "10px" }}
>
Create Subdomain + Custom Website
Create Custom Website
</Button>
<br />
<br />
{this.state.created ? (
<div>
<h4 style={{ color: "green" }}>Success! </h4>
Subdomain created at{" "}
<a
href={"https://" + this.state.name + ".foodleh.app"}
target="blank"
>
{this.state.name}.foodleh.app
</a>
<h5>
Website created at{" "}
<a
href={"https://" + this.state.name + ".foodleh.app"}
target="blank"
>
https://{this.state.name}.foodleh.app
</a>
</h5>
<h5>
Edit website at:{" "}
<a
href={
"https://" + this.state.name + ".foodleh.app/dashboard"
}
target="blank"
>
https://{this.state.name}.foodleh.app/dashboard
</a>
</h5>
</div>
) : null}
</div>
Expand All @@ -367,7 +377,7 @@ export class Custom extends React.Component {
return (
<div class="container" style={{ paddingTop: "56px", width: "100%" }}>
<div style={{ margin: "20px" }}>
<h3>Create A Custom Domain / Website</h3>
<h3>Build Your Own Custom Website</h3>
<h5>e.g. huathuatrice.foodleh.app</h5>
</div>
<Stepper activeStep={this.state.step} orientation="vertical">
Expand Down Expand Up @@ -397,7 +407,9 @@ export class Custom extends React.Component {
color="primary"
onClick={this.increaseStep}
disabled={
(this.state.step === 1 ? this.state.id : true)
this.state.step === 0
? !this.state.firebaseUser
: (this.state.step === 1 ? this.state.id : true)
? this.state.step === 2
? !this.state.available
: false
Expand Down
34 changes: 17 additions & 17 deletions src/Components/Firestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,44 @@ firebase.initializeApp({
storageBucket: "hawkercentral.appspot.com",
messagingSenderId: "596185831538",
appId: "1:596185831538:web:9cbfb234d1fff146cf8aeb",
measurementId: "G-Z220VNJFT9"
measurementId: "G-Z220VNJFT9",
});

const uiConfig = {
// Popup signin flow rather than redirect flow.
signInFlow: 'popup',
signInFlow: "popup",
// Redirect to /signedIn after sign in is successful. Alternatively you can provide a callbacks.signInSuccess function.
// We will display Google and Facebook as auth providers.
signInOptions: [
{
provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
defaultCountry: 'SG'
}
defaultCountry: "SG",
},
],
callbacks: {
signInSuccessWithAuthResult(authResult, redirectUrl) {
// Do not automatically redirect.
return false;
},
}
},
};

const uiConfigPage = {
// Popup signin flow rather than redirect flow.
signInFlow: 'popup',
signInFlow: "popup",
// Redirect to /signedIn after sign in is successful. Alternatively you can provide a callbacks.signInSuccess function.
// We will display Google and Facebook as auth providers.
signInOptions: [
{
provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
defaultCountry: 'SG'
},
firebase.auth.EmailAuthProvider.PROVIDER_ID
],
credentialHelper: 'none',
signInOptions: [firebase.auth.EmailAuthProvider.PROVIDER_ID],
callbacks: {
signInSuccessWithAuthResult(authResult, redirectUrl) {
// Do not automatically redirect.
return false;
},
}
},
};

if (typeof window !== 'undefined') {
if (typeof window !== "undefined") {
firebase.analytics();
}

Expand All @@ -75,7 +70,12 @@ const geoToPromise = geofirex.get;

module.exports = {
__esModule: true,
geo, geoToPromise,
db, storage, firebase, uiConfig, uiConfigPage,
geo,
geoToPromise,
db,
storage,
firebase,
uiConfig,
uiConfigPage,
default: firebase,
};
1 change: 1 addition & 0 deletions src/Components/ListForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const handleData = async ({
.add({
...field,
claps: 0,
custom: false
})
.then(function (docRef) {
console.log(docRef.id);
Expand Down

0 comments on commit 37a5187

Please sign in to comment.