19 lines
612 B
TypeScript
19 lines
612 B
TypeScript
import {Module} from "@/interfaces";
|
|
|
|
export const MODULE_ARRAY: Module[] = ["reading", "listening", "writing", "speaking"];
|
|
|
|
export const moduleLabels: {[key in Module]: string} = {
|
|
listening: "Listening",
|
|
reading: "Reading",
|
|
speaking: "Speaking",
|
|
writing: "Writing",
|
|
};
|
|
|
|
export const sortByModule = (a: {module: Module}, b: {module: Module}) => {
|
|
return MODULE_ARRAY.findIndex((x) => a.module === x) - MODULE_ARRAY.findIndex((x) => b.module === x);
|
|
};
|
|
|
|
export const sortByModuleName = (a: string, b: string) => {
|
|
return MODULE_ARRAY.findIndex((x) => a === x) - MODULE_ARRAY.findIndex((x) => b === x);
|
|
};
|