Skip to content

Commit

Permalink
Merge pull request #70 from jphacks/feat/kubosaka/fix-camera-page
Browse files Browse the repository at this point in the history
課題ある時のみカメラオンにするように修正
  • Loading branch information
Kubosaka authored Nov 16, 2024
2 parents ed400de + a56c9f9 commit 14a5858
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions app/src/app/camera/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const CameraApp = () => {
todayAssignment | undefined
>();
const [assignments, setAssignments] = useState<todayAssignment[]>([]);
const [isActive, setIsActive] = useState<boolean>(true);
const [isActive, setIsActive] = useState<boolean>(false);
const [isPointDialogOpen, setIsPointDialogOpen] = usePointDialogOpen();
const [loginUser, setLoginUser] = useState<User>();

Expand All @@ -114,19 +114,18 @@ const CameraApp = () => {
);
const assignmentData = await resAssignment.json();

if (assignmentData.length === 0) {
setIsActive(false);
return;
}

const isAnsweredAll = assignmentData.every(
(assignment: todayAssignment) => assignment.isAnswered,
);
if (isAnsweredAll) {
setIsActive(false);

if (assignmentData.length === 0) {
return;
}

if (!isAnsweredAll) {
setIsActive(true);
}

const notAnsweredAssignment = assignmentData.find(
(assignment: todayAssignment) => !assignment.isAnswered,
);
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/AssignmentBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { todayAssignment } from "@/types";
import type { todayAssignment } from "@/types";

interface AssignmentBadgeProps {
assignment: todayAssignment;
Expand Down

0 comments on commit 14a5858

Please sign in to comment.