diff --git a/firestore.rules b/firestore.rules index cb72c29c..13dd1c13 100644 --- a/firestore.rules +++ b/firestore.rules @@ -67,8 +67,9 @@ service cloud.firestore { 'menu_combined', 'tagsValue', 'claps', - 'takesg' - ]) && fields.size() == 41 + 'takesg', + 'custom' + ]) && fields.size() == 42 } // TODO: Need structure diff --git a/src/Components/Custom.js b/src/Components/Custom.js index aee02725..7f0abdf3 100644 --- a/src/Components/Custom.js +++ b/src/Components/Custom.js @@ -37,7 +37,7 @@ export class Custom extends React.Component { creating: false, created: false, invalid: false, - firebaseUser: null + firebaseUser: null, }; } @@ -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", ]; }; @@ -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; @@ -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 }); }); }; @@ -200,10 +203,13 @@ export class Custom extends React.Component {

) : ( - +
+ +
+
)} ); @@ -324,35 +330,39 @@ export class Custom extends React.Component {

-

{this.state.created ? (

Success!

- Subdomain created at{" "} - - {this.state.name}.foodleh.app - +
+ Website created at{" "} + + https://{this.state.name}.foodleh.app + +
+
+ Edit website at:{" "} + + https://{this.state.name}.foodleh.app/dashboard + +
) : null} @@ -367,7 +377,7 @@ export class Custom extends React.Component { return (
-

Create A Custom Domain / Website

+

Build Your Own Custom Website

e.g. huathuatrice.foodleh.app
@@ -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 diff --git a/src/Components/Firestore.js b/src/Components/Firestore.js index c3780600..d3f18928 100644 --- a/src/Components/Firestore.js +++ b/src/Components/Firestore.js @@ -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(); } @@ -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, }; diff --git a/src/Components/ListForm.js b/src/Components/ListForm.js index a7a3eb9d..892c2511 100644 --- a/src/Components/ListForm.js +++ b/src/Components/ListForm.js @@ -154,6 +154,7 @@ const handleData = async ({ .add({ ...field, claps: 0, + custom: false }) .then(function (docRef) { console.log(docRef.id);