Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
Updated example
Browse files Browse the repository at this point in the history
  • Loading branch information
dilan-dio4 committed May 6, 2021
1 parent f2a44e8 commit 4440fd3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import React from 'react'
import ebconfig from "./ebconfig.json";
// import ebconfig2 from "./ebconfig2";
import ebconfig2 from "./ebconfig2";
import { EasybaseProvider } from 'easybase-react';
import QueryExample from "./QueryExample";
import FunctionExample from "./CloudFunctionExample";
Expand Down Expand Up @@ -33,7 +33,7 @@ const IntegrationExample = () => (
)

const ProjectExample = () => (
<EasybaseProvider ebconfig={ebconfig} options={{ logging: true }}>
<EasybaseProvider ebconfig={ebconfig2} options={{ logging: true }}>
<ProjectUser />
</EasybaseProvider>
)
Expand Down
6 changes: 3 additions & 3 deletions example/src/DbCardElement.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React, { useRef } from "react";
import { useEasybase } from "easybase-react";

const CardElement = ({ rating, picture, app_name, hq, latest_release, _key }: any) => {
const CardElement = ({ rating, picture, app_name, hq, latest_release, _key, tableName }: any) => {

const inputEl = useRef<HTMLInputElement>(null);

const { db } = useEasybase();

const onRatingChange = (change: number) => {
db().set({ 'rating': rating + change }).where({ _key }).all()
db(tableName || "").set({ 'rating': rating + change }).where({ _key }).all()
}

const onDelete = () => {
db().delete().where({ _key }).one();
db(tableName || "").delete().where({ _key }).one();
}

return (
Expand Down
6 changes: 3 additions & 3 deletions example/src/ProjectUser.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import { useEasybase } from "easybase-react";
import CardElement from "./CardElement";
import DbCardElement from "./DbCardElement";

export default function ProjectUser() {

Expand Down Expand Up @@ -60,7 +60,7 @@ export default function ProjectUser() {
<button className="btn orange m-4" onClick={addUserRecord}><span>Add User Record</span></button>
</div>
<div className="d-flex">
{data.map((ele, index) => <CardElement {...ele} index={index} key={index} />)}
{data.map((ele, index) => <DbCardElement {...ele} tableName="REACT TEST" key={index} />)}
</div>
</div>
)
Expand All @@ -76,7 +76,7 @@ export default function ProjectUser() {
<button className="btn orange m-4" onClick={onSignUpClick}><span>Sign Up</span></button>
</div>
<div className="d-flex">
{data.map((ele, index) => <CardElement {...ele} index={index} key={index} />)}
{data.map((ele, index) => <DbCardElement {...ele} tableName="MOBILE APPS" key={index} />)}
</div>
</div>
)
Expand Down

0 comments on commit 4440fd3

Please sign in to comment.