20 lines
456 B
TypeScript
20 lines
456 B
TypeScript
import { UserTestResponse } from "@/api/types";
|
|
|
|
export enum TestStatus {
|
|
Completed = "Completed",
|
|
Expired = "Expired",
|
|
InProgress = "In Progress"
|
|
}
|
|
|
|
export const getUserTestStatus = (userTest: UserTestResponse): TestStatus => {
|
|
let status: TestStatus = TestStatus.Completed;
|
|
|
|
if(!userTest.is_available && !userTest.is_completed)
|
|
return TestStatus.Expired;
|
|
|
|
if(!userTest.is_completed)
|
|
return TestStatus.InProgress;
|
|
|
|
|
|
return status
|
|
} |