-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
9,787 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//Parent Account Requests | ||
|
||
// CreateNewAccount | ||
// - ManageChildren | ||
// - GetChildren | ||
// - InviteChild | ||
// - Role (1-4) | ||
// - TransitionChildRole | ||
// - SetChildAllowance | ||
// - TransferFunds | ||
|
||
import db, { getFamily } from "../db/db"; | ||
import { | ||
collection, | ||
doc, | ||
setDoc, | ||
updateDoc, | ||
arrayUnion, | ||
getDocs, | ||
query, | ||
where, | ||
} from "firebase/firestore"; | ||
|
||
export const GetFamily = async (familyName) => { | ||
console.log("Getting Family"); | ||
return await getFamily(familyName); | ||
}; | ||
|
||
export const CreateNewFamily = async (familyName) => { | ||
await setDoc(doc(db, "families", familyName), { | ||
familyName: familyName, | ||
children: [], | ||
}); | ||
return { success: true }; | ||
}; | ||
export const GetChildren = async (familyId) => { | ||
return { children }; | ||
}; | ||
|
||
export const InviteChild = async (familyId, childName, role) => { | ||
return { success: true }; | ||
}; | ||
|
||
export const AddChild = async ( | ||
familyName, | ||
childName, | ||
role, | ||
balance, | ||
allowance | ||
) => { | ||
const coll = collection(db, "families"); | ||
const docs = await getDocs(coll); | ||
console.log("getDocs", docs); | ||
let famDoc = null; | ||
await docs.forEach((doc) => { | ||
console.log("snap", doc); | ||
famDoc = doc; | ||
}); | ||
|
||
await updateDoc(famDoc, { | ||
children: arrayUnion({ | ||
allowance: allowance, | ||
name: childName, | ||
role: role, | ||
balance: balance, | ||
}), | ||
}); | ||
return { success: true, familyDoc }; | ||
}; | ||
|
||
export const TransitionChildRole = async (familyId, childId, newRole) => { | ||
return { success: true }; | ||
}; | ||
|
||
export const SetChildAllowance = async (familyId, childId, allowance) => { | ||
return { success: true }; | ||
}; | ||
|
||
export const TransferFunds = async (familyId, childId, amount) => { | ||
return { success: true }; | ||
}; | ||
|
||
export const ExportChild = async (familyId, childId) => { | ||
return { success: true }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Children Account Requests | ||
// - GetBalance | ||
// - GetTransactions | ||
// - GetAllowance | ||
// - SendPayment | ||
// - RequestOneTimeAllowance | ||
|
||
export const GetBalance = async (familyId, childId) => { | ||
return { balance: 0 }; | ||
}; | ||
|
||
export const GetTransactions = async (familyId, childId) => { | ||
return { transactions: [] }; | ||
}; | ||
|
||
export const GetAllowance = async (familyId, childId) => { | ||
return { allowance: 0 }; | ||
}; | ||
|
||
export const SendPayment = async (familyId, childId, amount) => { | ||
return { success: true }; | ||
}; | ||
|
||
export const RequestOneTimeAllowance = async (familyId, childId, amount) => { | ||
return { success: true }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const db = require("./db"); | ||
const DB_COLLECTION = "families"; | ||
|
||
const collection = db.collection(DB_COLLECTION); | ||
console.log(`Connected to collection ${db.projectId}/${DB_COLLECTION}`); | ||
|
||
export default collection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { initializeApp } from "firebase/app"; | ||
import { getFirestore, collection, getDocs } from "firebase/firestore"; | ||
|
||
const firebaseConfig = require("../service-account.json"); | ||
console.log(firebaseConfig); | ||
|
||
const app = initializeApp(firebaseConfig); | ||
|
||
const db = getFirestore(app); | ||
utils.info(`Connection to GCP Project ${db.projectId} successful!`); | ||
export default db; | ||
|
||
export const getFamily = async (familyName) => { | ||
const querySnapshot = await getDocs(collection(db, "families")); | ||
let res = null; | ||
const docs = await querySnapshot.forEach((doc) => { | ||
if (doc.data()["family-name"] === familyName) { | ||
res = doc.data(); | ||
} | ||
}); | ||
return res; | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/react | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=react | ||
|
||
### react ### | ||
.DS_* | ||
*.log | ||
logs | ||
**/*.backup.* | ||
**/*.back.* | ||
|
||
node_modules | ||
bower_components | ||
|
||
*.sublime* | ||
|
||
psd | ||
thumb | ||
sketch | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/react | ||
|
||
service-account.json |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Outlet, useParams, Link } from "react-router-dom"; | ||
import { AddChild, CreateNewFamily, GetFamily } from "../serviceRequests/Admin"; | ||
import { useEffect, useState } from "react"; | ||
import { async } from "@firebase/util"; | ||
//Specifc, Private Family Page | ||
const Accounts = () => { | ||
const { family } = useParams(); | ||
const [fam, setFam] = useState([]); | ||
const [children, setChildren] = useState([]); | ||
|
||
useEffect(() => { | ||
async function getData() { | ||
// await CreateNewFamily("atlantabitdevs"); | ||
const res = await AddChild("atlantabitdevs", "Bryan", "piggy", 20, 0); | ||
// const _fam = await GetFamily("atlantabitdevs"); | ||
// setFam(_fam); | ||
// const members = await _fam.children.map((member) => member.name); | ||
// setChildren(members); | ||
} | ||
getData(); | ||
}, []); | ||
|
||
// const members = ["Steven", "Alex", "Bryan", "Jordan"]; | ||
|
||
return ( | ||
<div> | ||
<h2>Welcome {family} family!</h2> | ||
<ul> | ||
{children && | ||
children.map((member, key) => { | ||
return ( | ||
<li key={key}> | ||
<Link to={`${member}`}>{member}'s Account</Link> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
<Outlet /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Accounts; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//Parent Account Requests | ||
|
||
// CreateNewAccount | ||
// - ManageChildren | ||
// - GetChildren | ||
// - InviteChild | ||
// - Role (1-4) | ||
// - TransitionChildRole | ||
// - SetChildAllowance | ||
// - TransferFunds | ||
|
||
// import db, { getFamily } from "../db/db"; | ||
// import { | ||
// collection, | ||
// doc, | ||
// setDoc, | ||
// updateDoc, | ||
// arrayUnion, | ||
// getDocs, | ||
// query, | ||
// where, | ||
// } from "firebase/firestore"; | ||
|
||
export const GetFamily = async (familyName) => { | ||
console.log("Getting Family"); | ||
// return await getFamily(familyName); | ||
}; | ||
|
||
export const CreateNewFamily = async (familyName) => { | ||
// await setDoc(doc(db, "families", familyName), { | ||
// familyName: familyName, | ||
// children: [], | ||
// }); | ||
return { success: true }; | ||
}; | ||
export const GetChildren = async (familyId) => { | ||
return { children }; | ||
}; | ||
|
||
export const InviteChild = async (familyId, childName, role) => { | ||
return { success: true }; | ||
}; | ||
|
||
export const AddChild = async ( | ||
familyName, | ||
childName, | ||
role, | ||
balance, | ||
allowance | ||
) => { | ||
// const coll = collection(db, "families"); | ||
// const docs = await getDocs(coll); | ||
// console.log("getDocs", docs); | ||
// let famDoc = null; | ||
// await docs.forEach((doc) => { | ||
// console.log("snap", doc); | ||
// famDoc = doc; | ||
// }); | ||
|
||
// await updateDoc(famDoc, { | ||
// children: arrayUnion({ | ||
// allowance: allowance, | ||
// name: childName, | ||
// role: role, | ||
// balance: balance, | ||
// }), | ||
// }); | ||
return { success: true, familyDoc }; | ||
}; | ||
|
||
export const TransitionChildRole = async (familyId, childId, newRole) => { | ||
return { success: true }; | ||
}; | ||
|
||
export const SetChildAllowance = async (familyId, childId, allowance) => { | ||
return { success: true }; | ||
}; | ||
|
||
export const TransferFunds = async (familyId, childId, amount) => { | ||
return { success: true }; | ||
}; | ||
|
||
export const ExportChild = async (familyId, childId) => { | ||
return { success: true }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Children Account Requests | ||
// - GetBalance | ||
// - GetTransactions | ||
// - GetAllowance | ||
// - SendPayment | ||
// - RequestOneTimeAllowance | ||
|
||
export const GetBalance = async (familyId, childId) => { | ||
return { balance: 0 }; | ||
}; | ||
|
||
export const GetTransactions = async (familyId, childId) => { | ||
return { transactions: [] }; | ||
}; | ||
|
||
export const GetAllowance = async (familyId, childId) => { | ||
return { allowance: 0 }; | ||
}; | ||
|
||
export const SendPayment = async (familyId, childId, amount) => { | ||
return { success: true }; | ||
}; | ||
|
||
export const RequestOneTimeAllowance = async (familyId, childId, amount) => { | ||
return { success: true }; | ||
}; |
File renamed without changes.
Oops, something went wrong.