Skip to content

Commit

Permalink
Merge pull request #124 from BaniHillabi/master
Browse files Browse the repository at this point in the history
feat (frontend) : add type tim update for admin
  • Loading branch information
BaniHillabi authored Sep 9, 2024
2 parents c5f5e5d + 097b9a5 commit fc8d05c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/actions/Tim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

import { revalidatePath } from "next/cache";
import { deleteTim, updateTim } from "@/queries/tim.query";
import { Tipe } from "@prisma/client";

export async function updateTimForm(data: FormData, id: string) {
const asal_sekolah = data.get("asal_sekolah") as string;
const tipe_tim = data.get("tipe_tim") as Tipe;

try {
await updateTim(
{ id },
{
asal_sekolah: asal_sekolah,
tipe_tim: tipe_tim
}
);
revalidatePath("/", "layout");
Expand Down
36 changes: 36 additions & 0 deletions src/app/(admin)/admin/tim/[id]/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export default function TimForm({
{ label: "SMA", value: "SMA" },
];

const options_type = [
{ label: "12 Anggota", value: "SMALL" },
{ label: "15 Anggota", value: "NORMAL" },
];

async function Update(data: FormData) {
const toastId = toast.loading("Loading...");
const result = await updateTimForm(data, id!);
Expand Down Expand Up @@ -111,6 +116,37 @@ export default function TimForm({
/>
</div>

<div className="flex flex-col gap-2">
<label htmlFor={"tipe_tim"} className="text-[16px]">
Tipe Tim
</label>
<Select
name="tipe_tim"
unstyled
defaultValue={{
label: data?.tipe_tim.toString() === "SMALL" ? "12 Anggota" : "15 Anggota" ,
value: data?.tipe_tim.toString(),
}}
isDisabled={false}
options={options_type}
id="tipe_tim"
placeholder="Tipe tim"
classNames={{
control: () =>
"rounded-[14px] border focus:bg-[#F1F6F9] border-neutral-400 px-[18px] active:border-black hover:border-black py-[14px] text-black placeholder-neutral-500 bg-white focus:outline-none transition-all duration-500 placeholder:text-[#C8C8C8]",
menu: () =>
"bg-white rounded-lg px-[18px] py-[14px] border border-neutral-400",
multiValue: () =>
"bg-primary-400 px-4 py-2 text-white rounded-2xl",
valueContainer: () => "flex gap-2",
menuList: () => "text-base flex flex-col gap-1",
option: () =>
"hover:bg-neutral-300 hover:cursor-pointer transition-all duration-500 rounded-lg p-2",
input: () => "focus:bg-[#F1F6F9]",
}}
/>
</div>

<TextField
id="updated_at"
type="text"
Expand Down

0 comments on commit fc8d05c

Please sign in to comment.