Compare commits
6 Commits
f79ff26958
...
d32289c833
| Author | SHA1 | Date | |
|---|---|---|---|
| d32289c833 | |||
| 3c45010b26 | |||
| 4927428607 | |||
| 04298c9f54 | |||
| 6759a1bf8f | |||
| 92624cbac9 |
@@ -16,7 +16,7 @@ import { useSessionStore } from "@/lib/store/sessionStore";
|
|||||||
import { getProdPerms } from "@/utils/querys/prodUser/getProdPerms";
|
import { getProdPerms } from "@/utils/querys/prodUser/getProdPerms";
|
||||||
|
|
||||||
import { useForm } from "@tanstack/react-form";
|
import { useForm } from "@tanstack/react-form";
|
||||||
|
import { useState } from "react";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
@@ -24,6 +24,7 @@ import { toast } from "sonner";
|
|||||||
export default function ProdUserCard() {
|
export default function ProdUserCard() {
|
||||||
const { token } = useSessionStore();
|
const { token } = useSessionStore();
|
||||||
const { data, isError, isLoading } = useQuery(getProdPerms(token ?? ""));
|
const { data, isError, isLoading } = useQuery(getProdPerms(token ?? ""));
|
||||||
|
const [creating, setCreating] = useState(false);
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@@ -34,7 +35,8 @@ export default function ProdUserCard() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onSubmit: async ({ value }) => {
|
onSubmit: async ({ value }) => {
|
||||||
console.log(value);
|
setCreating(true);
|
||||||
|
//console.log(value);
|
||||||
|
|
||||||
if (value.role === "") {
|
if (value.role === "") {
|
||||||
toast.error(
|
toast.error(
|
||||||
@@ -50,15 +52,22 @@ export default function ProdUserCard() {
|
|||||||
//console.log(res.data);
|
//console.log(res.data);
|
||||||
|
|
||||||
if (!res.data.success) {
|
if (!res.data.success) {
|
||||||
toast.error(res.data.data?.errors[0].message);
|
const errMSG: string = res.data.data.errors
|
||||||
|
? res.data.data?.errors[0].message
|
||||||
|
: res.data.data;
|
||||||
|
|
||||||
|
toast.error(`${errMSG}`);
|
||||||
|
setCreating(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.data.success) {
|
if (res.data.success) {
|
||||||
toast.success(res.data.message);
|
toast.success(res.data.message);
|
||||||
form.reset();
|
form.reset();
|
||||||
|
setCreating(false);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
setCreating(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -205,7 +214,9 @@ export default function ProdUserCard() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="flex justify-end mr-3">
|
<div className="flex justify-end mr-3">
|
||||||
<Button onClick={form.handleSubmit}>Submit</Button>
|
<Button onClick={form.handleSubmit} disabled={creating}>
|
||||||
|
Submit
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</LstCard>
|
</LstCard>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admConfig": {
|
"admConfig": {
|
||||||
"build": 406,
|
"build": 410,
|
||||||
"oldBuild": "backend-0.1.3.zip"
|
"oldBuild": "backend-0.1.3.zip"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -10,20 +10,43 @@ export const pickedup = async (data: any) => {
|
|||||||
|
|
||||||
if (!data.sscc && !data.runningNr) {
|
if (!data.sscc && !data.runningNr) {
|
||||||
// data.runningNr = data.sscc.slice(10, -1);
|
// data.runningNr = data.sscc.slice(10, -1);
|
||||||
return {success: false, message: "Missing data please try again", data: []};
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Missing data please try again",
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.all) {
|
if (data.areaFrom) {
|
||||||
try {
|
try {
|
||||||
const updateRn = await db
|
const updateRn = await db
|
||||||
.update(ocmeData)
|
.update(ocmeData)
|
||||||
.set({ pickedUp: true, upd_date: sql`NOW()` })
|
.set({ pickedUp: true, upd_date: sql`NOW()` })
|
||||||
|
.where(eq(ocmeData.areaFrom, data.areaFrom))
|
||||||
.returning({ runningNr: ocmeData.runningNr });
|
.returning({ runningNr: ocmeData.runningNr });
|
||||||
createLog("info", "ocme", "ocme", `Pending pallets were just cleared out.`);
|
createLog(
|
||||||
return {success: true, message: `Pending pallets were just cleared out.`, data: updateRn};
|
"info",
|
||||||
|
"ocme",
|
||||||
|
"ocme",
|
||||||
|
`Pending pallets were just cleared out.`
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `Pending pallets were just cleared out.`,
|
||||||
|
data: updateRn,
|
||||||
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createLog("error", "ocme", "ocme", `Error clearing out the pallets.`);
|
createLog(
|
||||||
return {success: false, message: `Error clearing out the pallets.`, error};
|
"error",
|
||||||
|
"ocme",
|
||||||
|
"ocme",
|
||||||
|
`Error clearing out the pallets.`
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: `Error clearing out the pallets.`,
|
||||||
|
error,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,10 +56,28 @@ export const pickedup = async (data: any) => {
|
|||||||
.set({ pickedUp: true, upd_date: sql`NOW()` })
|
.set({ pickedUp: true, upd_date: sql`NOW()` })
|
||||||
.where(eq(ocmeData.runningNr, data.runningNr))
|
.where(eq(ocmeData.runningNr, data.runningNr))
|
||||||
.returning({ runningNr: ocmeData.runningNr });
|
.returning({ runningNr: ocmeData.runningNr });
|
||||||
createLog("info", "ocme", "ocme", `${parseInt(data.runningNr)} was just pickedup`);
|
createLog(
|
||||||
return {success: true, message: `${parseInt(data.runningNr)} was just pickedup`, data: updateRn};
|
"info",
|
||||||
|
"ocme",
|
||||||
|
"ocme",
|
||||||
|
`${parseInt(data.runningNr)} was just pickedup`
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `${parseInt(data.runningNr)} was just pickedup`,
|
||||||
|
data: updateRn,
|
||||||
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createLog("error", "ocme", "ocme", `${parseInt(data.runningNr)} was just pickedup`);
|
createLog(
|
||||||
return {success: false, message: `${parseInt(data.runningNr)} was not pickedup`, error};
|
"error",
|
||||||
|
"ocme",
|
||||||
|
"ocme",
|
||||||
|
`${parseInt(data.runningNr)} was just pickedup`
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: `${parseInt(data.runningNr)} was not pickedup`,
|
||||||
|
error,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user