mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
## Description This PR ensures that the default prettier config is used for examples and templates. This config is compatible with `prettier@3` as well (upgrading prettier is bigger change that can be a future PR). ## Changes - Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will be needed upgrading to prettier@3) - Added `examples/.prettierrc.json` with default config (this will change every example) - Added `packages/create-next-app/templates/.prettierrc.json` with default config (this will change every template) ## Related - Fixes #54402 - Closes #54409
39 lines
889 B
TypeScript
39 lines
889 B
TypeScript
import { useRouter } from "next/router";
|
|
import useSWR from "swr";
|
|
import Form from "../../components/Form";
|
|
|
|
const fetcher = (url: string) =>
|
|
fetch(url)
|
|
.then((res) => res.json())
|
|
.then((json) => json.data);
|
|
|
|
const EditPet = () => {
|
|
const router = useRouter();
|
|
const { id } = router.query;
|
|
const {
|
|
data: pet,
|
|
error,
|
|
isLoading,
|
|
} = useSWR(id ? `/api/pets/${id}` : null, fetcher);
|
|
|
|
if (error) return <p>Failed to load</p>;
|
|
if (isLoading) return <p>Loading...</p>;
|
|
if (!pet) return null;
|
|
|
|
const petForm = {
|
|
name: pet.name,
|
|
owner_name: pet.owner_name,
|
|
species: pet.species,
|
|
age: pet.age,
|
|
poddy_trained: pet.poddy_trained,
|
|
diet: pet.diet,
|
|
image_url: pet.image_url,
|
|
likes: pet.likes,
|
|
dislikes: pet.dislikes,
|
|
};
|
|
|
|
return <Form formId="edit-pet-form" petForm={petForm} forNewPet={false} />;
|
|
};
|
|
|
|
export default EditPet;
|