-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from Team3256/admin-dashboard-fixes
Admin dashboard fixes
- Loading branch information
Showing
6 changed files
with
142 additions
and
242 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 |
---|---|---|
@@ -1,100 +1,100 @@ | ||
import { createClient } from "@/lib/utils/supabase/client"; | ||
|
||
export async function addAssignment({ match, team, alliance, assignee }) { | ||
const supabase = createClient(); | ||
const supabase = createClient(); | ||
console.log("sadfsafdfsd"); | ||
const { data: profileData, error: profileError } = await supabase | ||
.from("profiles") | ||
.select("id") | ||
.eq("email", assignee) | ||
.single(); | ||
|
||
const { data: profileData, error: profileError } = await supabase | ||
.from("profiles") | ||
.select("id") | ||
.eq("email", assignee) | ||
.single(); | ||
const { data, error } = await supabase | ||
.from("assignments") | ||
.upsert([ | ||
{ | ||
match: match, | ||
team: team, | ||
alliance: alliance, | ||
assignee: profileData?.id, | ||
event_log: { | ||
auto: { log: [], checkboxes: null }, | ||
teleop: { log: [], checkboxes: null }, | ||
endgame: { log: [], checkboxes: null }, | ||
}, | ||
}, | ||
]) | ||
.select(); | ||
|
||
const { data, error } = await supabase | ||
.from("assignments") | ||
.insert([ | ||
{ | ||
match: match, | ||
team: team, | ||
alliance: alliance, | ||
assignee: profileData?.id, | ||
event_log: { | ||
auto: { log: [], checkboxes: null }, | ||
teleop: { log: [], checkboxes: null }, | ||
endgame: { log: [], checkboxes: null }, | ||
}, | ||
}, | ||
]) | ||
.select(); | ||
|
||
if (error) { | ||
console.error("Error: ", error); | ||
} else { | ||
console.log("Data: ", data); | ||
} | ||
if (error) { | ||
console.error("Error: ", error); | ||
} else { | ||
console.log("Data: ", data); | ||
} | ||
} | ||
|
||
export async function addEvents({ event }) { | ||
const supabase = createClient(); | ||
const supabase = createClient(); | ||
|
||
const { data, error } = await supabase | ||
.from("events") | ||
.insert([ | ||
{ | ||
key: event.key, | ||
name: event.name, | ||
}, | ||
]) | ||
.select(); | ||
const { data, error } = await supabase | ||
.from("events") | ||
.insert([ | ||
{ | ||
key: event.key, | ||
name: event.name, | ||
}, | ||
]) | ||
.select(); | ||
|
||
if (error) { | ||
console.error("Error: ", error); | ||
} else { | ||
console.log("Data: ", data); | ||
} | ||
if (error) { | ||
console.error("Error: ", error); | ||
} else { | ||
console.log("Data: ", data); | ||
} | ||
} | ||
|
||
export async function addMatches({ match }) { | ||
const supabase = createClient(); | ||
const supabase = createClient(); | ||
|
||
const { data, error } = await supabase | ||
.from("matches") | ||
.insert([ | ||
{ | ||
key: match.match_key, | ||
event: match.event, | ||
}, | ||
]) | ||
.select(); | ||
const { data, error } = await supabase | ||
.from("matches") | ||
.insert([ | ||
{ | ||
key: match.match_key, | ||
event: match.event, | ||
}, | ||
]) | ||
.select(); | ||
|
||
if (error) { | ||
console.error("Error: ", error); | ||
} else { | ||
console.log("Data: ", data); | ||
} | ||
if (error) { | ||
console.error("Error: ", error); | ||
} else { | ||
console.log("Data: ", data); | ||
} | ||
} | ||
|
||
export async function getEmails( | ||
setMembers: (members: { [key: string]: string[] }) => void, | ||
setMembers: (members: { [key: string]: string[] }) => void, | ||
) { | ||
const supabase = createClient(); | ||
const supabase = createClient(); | ||
|
||
// const { data, error } = await supabase.from("users").select("email"); | ||
const { data, error } = await supabase.from("profiles").select("email"); | ||
// const { data, error } = await supabase.from("users").select("email"); | ||
const { data, error } = await supabase.from("profiles").select("email"); | ||
|
||
if (error) { | ||
console.error("Error: ", error); | ||
} else { | ||
console.log("Data: ", data); | ||
} | ||
if (error) { | ||
console.error("Error: ", error); | ||
} else { | ||
console.log("Data: ", data); | ||
} | ||
|
||
const extractedEmails = data.map((obj) => obj.email); | ||
const extractedEmails = data.map((obj) => obj.email); | ||
|
||
// Update the state to create an object where each email is a key with an empty array value | ||
setMembers((previousState) => ({ | ||
...previousState, // This keeps existing state entries intact | ||
...extractedEmails.reduce((acc, email) => { | ||
acc[email] = []; | ||
return acc; | ||
}, {}), | ||
})); | ||
// Update the state to create an object where each email is a key with an empty array value | ||
setMembers((previousState) => ({ | ||
...previousState, // This keeps existing state entries intact | ||
...extractedEmails.reduce((acc, email) => { | ||
acc[email] = []; | ||
return acc; | ||
}, {}), | ||
})); | ||
} |
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
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
Oops, something went wrong.