Skip to content

Commit

Permalink
Fix: struct change
Browse files Browse the repository at this point in the history
  • Loading branch information
Slouchwind committed Sep 20, 2024
1 parent 3a6a728 commit 1248c5c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/imgCol.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function ImgCol(
<div className='imgCol' style={imgStyle} {...other}>
<img
className='col'
src={`https://schale.gg/images/student/collection/${id}.webp`}
src={`https://schaledb.com/images/student/collection/${id}.webp`}
alt={`${id || ''} collection image`}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/students/students.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface schaleInfo {

export interface studentsJson {
fileJson?: fileInfo[];
schaleJson?: schaleInfo[];
schaleJson?: { [id: number]: schaleInfo };
}

export interface studentInfo {
Expand Down
9 changes: 5 additions & 4 deletions components/students/studentsMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ export async function getStudentsJson(locale: string): Promise<studentsJson> {
'en-US': 'en'
};
const fileJson: fileInfo[] = await fetch('../students.json').then(r => r.json());
const schaleJson: schaleInfo[] = await fetch(`https://schale.gg/data/${localeCodes[locale as Locales]}/students.min.json`).then(r => r.json());
const schaleJson: schaleInfo[] = await fetch(`https://schaledb.com/data/${localeCodes[locale as Locales]}/students.min.json`).then(r => r.json());
return { fileJson, schaleJson };
}

export function getStudentInfo({ fileJson, schaleJson }: studentsJson, studentId: number): studentInfo {
const file = fileJson && fileJson.filter(info => (info.id === studentId))[0];
const schale = schaleJson && schaleJson.filter(info => (info.Id === studentId))[0];
console.log({ fileJson, schaleJson });
const file = fileJson?.filter(info => (info.id === studentId))[0];
const schale = schaleJson?.[studentId];
return { file, schale };
}

export function getAllStudentsList({ schaleJson }: studentsJson): number[] {
if (!schaleJson) return [];
return schaleJson.map(v => v.Id).sort();
return Object.keys(schaleJson).map(k => Number(k));
}

export function getStuSenText(
Expand Down
2 changes: 1 addition & 1 deletion pages/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ interface StudentsSelectorProps {

function StudentsSelector({ schaleJson, studentsList, onClick, selectStudents }: StudentsSelectorProps) {
let chooseStudentsList = Object.entries(selectStudents).filter(v => v[1]).map(v => Number(v[0]));
let selector = schaleJson?.map(({ Id: id }) => {
let selector = getAllStudentsList({ schaleJson })?.map(id => {
if (!studentsList.includes(id)) return;
return (
<ImgCol
Expand Down

0 comments on commit 1248c5c

Please sign in to comment.