Skip to content

Commit

Permalink
refactor: actions
Browse files Browse the repository at this point in the history
  • Loading branch information
yutakobayashidev committed Oct 12, 2023
1 parent 508f564 commit ef5418a
Show file tree
Hide file tree
Showing 13 changed files with 425 additions and 457 deletions.
80 changes: 0 additions & 80 deletions frontend/src/app/(app)/bill/[id]/actions.ts

This file was deleted.

3 changes: 1 addition & 2 deletions frontend/src/app/(app)/bill/[id]/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import "dayjs/locale/ja";

import { addComment, Vote } from "@src/app/actions";
import { LoginPrompt } from "@src/components/login/login";
import dayjs from "dayjs";
import { type Session } from "next-auth";
import { useRef, useState, useTransition } from "react";
import { experimental_useFormStatus as useFormStatus } from "react-dom";
import { VscTriangleUp } from "react-icons/vsc";

import { addComment, Vote } from "./actions";

dayjs.locale("ja");

type Comment = {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/(app)/dashboard/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import { Dialog, Switch } from "@headlessui/react";
import GLogo from "@public/g-logo.svg";
import { DeleteAccount, updatePrefecture, updateUser } from "@src/app/actions";
import Modal from "@src/components/ui/dialog";
import { ArrowDownIcon } from "@xpadev-net/designsystem-icons";
import cn from "classnames";
import { useRouter } from "next/navigation";
import { type Session } from "next-auth";
import { useEffect, useState, useTransition } from "react";

import { DeleteAccount, updatePrefecture, updateUser } from "./actions";

export default function Settings({
prefectures,
user,
Expand Down
64 changes: 0 additions & 64 deletions frontend/src/app/(app)/dashboard/settings/actions.ts

This file was deleted.

18 changes: 13 additions & 5 deletions frontend/src/app/(app)/face/PersonModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Member } from "@src/types/member";
import { motion, transform, useMotionValue } from "framer-motion";
import Link from "next/link";
import { useRef } from "react";
import { FaGlobe, FaTwitter } from "react-icons/fa";
import { FaGlobe } from "react-icons/fa";

interface PersonModalProps {
member: Member;
Expand Down Expand Up @@ -81,7 +81,7 @@ const PersonModal: React.FC<PersonModalProps> = ({ member, onClose }) => {
dragConstraints={{ top: 0 }}
drag="y"
style={{ x: "-50%" }}
className="xs:p-8 fixed bottom-0 left-[50%] z-50 flex w-full max-w-[480px] flex-col rounded-t-4xl bg-white px-5 py-7 before:absolute before:left-[50%] before:top-[10px] before:h-[4px] before:w-[60px] before:-translate-x-1/2 before:bg-gray-200"
className="xs:p-8 rounded-t-4xl fixed bottom-0 left-[50%] z-50 flex w-full max-w-[480px] flex-col bg-white px-5 py-7 before:absolute before:left-[50%] before:top-[10px] before:h-[4px] before:w-[60px] before:-translate-x-1/2 before:bg-gray-200"
>
<h2 className="mb-5 text-center text-2xl font-bold">
<span className="mr-1">{member.name}</span>議員の情報
Expand Down Expand Up @@ -127,10 +127,18 @@ const PersonModal: React.FC<PersonModalProps> = ({ member, onClose }) => {
</Link>
{member.twitter && (
<a
href={`https://twitter.com/${member.twitter}`}
className="mr-3 inline-flex items-center rounded-full bg-[#1da1f2] px-3 py-2 text-sm font-semibold text-white"
href={`https://x.com/${member.twitter}`}
className="mr-3 inline-flex items-center rounded-full bg-gray-900 px-3 py-2 text-sm font-semibold text-white"
>
<FaTwitter className="mr-2 text-base" />@{member.twitter}
<svg
aria-label="X formerly known as Twitter"
fill="currentColor"
className="mx-auto mr-2 h-4 w-4"
viewBox="0 0 22 20"
>
<path d="M16.99 0H20.298L13.071 8.26L21.573 19.5H14.916L9.702 12.683L3.736 19.5H0.426L8.156 10.665L0 0H6.826L11.539 6.231L16.99 0ZM15.829 17.52H17.662L5.83 1.876H3.863L15.829 17.52Z"></path>
</svg>
@{member.twitter}
</a>
)}
</div>
Expand Down
33 changes: 15 additions & 18 deletions frontend/src/app/(app)/face/page.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
"use client";

import FaceDetection from "@src/app/(app)/face/FaceDetection";
import PersonModal from "@src/app/(app)/face/PersonModal";
import { getMember } from "@src/app/actions";
import { Member } from "@src/types/member";
import { AnimatePresence } from "framer-motion";
import { useState } from "react";
import { toast } from "sonner";

import PersonModal from "./PersonModal";

const useMember = () => {
const [member, setMember] = useState<Member | null>(null);

const fetchMember = async (name: string) => {
try {
const response = await fetch(`/api/members/${name}`);
if (response.ok) {
const foundMember: Member = await response.json();
setMember(foundMember);
} else {
getMember(name)
.then((res) => {
console.log(res);
setMember(res);

if (!res) {
toast.error("人物が見つかりませんでした");
}
})
.catch((e) => {
toast.error("問題が発生しました");
}
} catch (error) {
console.error(error);
toast.error("問題が発生しました");
}
});
};

const clearMember = () => setMember(null);
Expand All @@ -35,11 +35,8 @@ export default function Page() {
const { clearMember, fetchMember, member } = useMember();

const handleFaceDetect = async (name: string) => {
if (name !== "unknown") {
await fetchMember(name);
} else {
toast.error("人物を検出できませんでした");
}
console.log(name);
await fetchMember("岸田文雄");
};

return (
Expand Down
113 changes: 0 additions & 113 deletions frontend/src/app/(app)/meetings/[id]/actions.ts

This file was deleted.

Loading

0 comments on commit ef5418a

Please sign in to comment.