Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] evaluated Validate #775

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions frontend/app/routes/client._index/driving-state/arrived.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ import confetti from "canvas-confetti";
export const Arrived = ({ onEvaluated }: { onEvaluated: () => void }) => {
const { data } = useClientContext();
const [rating, setRating] = useState(0);
const [errorMessage, setErrorMessage] = useState<string>();

const onClick: MouseEventHandler<HTMLButtonElement> = useCallback(
(e) => {
e.preventDefault();
if (rating < 1 || rating > 5) {
setErrorMessage("評価は1から5の間でなければなりません。");
return;
}
try {
void fetchAppPostRideEvaluation({
pathParams: {
Expand Down Expand Up @@ -50,33 +55,40 @@ export const Arrived = ({ onEvaluated }: { onEvaluated: () => void }) => {
}, []);

return (
<Form className="w-full h-full flex flex-col items-center justify-center max-w-md mx-auto">
<div className="flex flex-col items-center gap-6 mb-14">
<PinIcon className="size-[90px]" color={colors.red[500]} />
<Text size="xl" bold>
目的地に到着しました
</Text>
</div>
<div className="flex flex-col items-center w-80">
<Text className="mb-4">今回のドライブはいかがでしたか?</Text>
<ClickableRating
name="rating"
rating={rating}
setRating={setRating}
className="mb-10"
/>
{data?.fare && (
<Price pre="運賃" value={data.fare} className="mb-6"></Price>
<>
<Form className="w-full h-full flex flex-col items-center justify-center max-w-md mx-auto">
<div className="flex flex-col items-center gap-6 mb-14">
<PinIcon className="size-[90px]" color={colors.red[500]} />
<Text size="xl" bold>
目的地に到着しました
</Text>
</div>
<div className="flex flex-col items-center w-80">
<Text className="mb-4">今回のドライブはいかがでしたか?</Text>
<ClickableRating
name="rating"
rating={rating}
setRating={setRating}
className="mb-10"
/>
{data?.fare && (
<Price pre="運賃" value={data.fare} className="mb-6"></Price>
)}
<Button
variant="primary"
type="submit"
onClick={onClick}
className="w-full"
>
評価して料金を支払う
</Button>
</div>
{errorMessage && (
<Text variant="danger" className="mt-2">
{errorMessage}
</Text>
)}
<Button
variant="primary"
type="submit"
onClick={onClick}
className="w-full"
>
評価して料金を支払う
</Button>
</div>
</Form>
</Form>
</>
);
};