temporary server action for group and inside
This commit is contained in:
@@ -3,20 +3,12 @@
|
||||
import { LocationContext } from "@/components/locationContext";
|
||||
import { useContext, useState } from "react";
|
||||
import Grouping from "./Grouping";
|
||||
import { Group, JobCategory, updateGroups } from "./action";
|
||||
|
||||
type Props = {
|
||||
allJobs: JobCategory[];
|
||||
};
|
||||
|
||||
export type JobCategory = {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
|
||||
type Group = {
|
||||
id: number;
|
||||
jobs: number[];
|
||||
};
|
||||
export default function GroupCreator({ allJobs }: Props) {
|
||||
const locationContext = useContext(LocationContext);
|
||||
const [usedJobs, setUsedJobs] = useState<number[]>([]);
|
||||
@@ -40,7 +32,22 @@ export default function GroupCreator({ allJobs }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
function submit() {} //TODO! submit group
|
||||
async function submit() {
|
||||
if (
|
||||
locationContext?.zone[0] == undefined ||
|
||||
locationContext?.province[0] == undefined
|
||||
) {
|
||||
alert("ยังไม่ได้เลือกพื้นที่");
|
||||
return;
|
||||
}
|
||||
await updateGroups(
|
||||
locationContext.province[0],
|
||||
locationContext.zone[0],
|
||||
groups,
|
||||
);
|
||||
|
||||
alert("อัพเดทสำเร็จ");
|
||||
}
|
||||
|
||||
if (
|
||||
locationContext?.zone[0] == undefined ||
|
||||
|
||||
Reference in New Issue
Block a user