- PC: Loader chat
- QC: Auth , Profile, portofolio & user search
## No Issuue
git commit -m
This commit is contained in:
2024-05-16 10:03:34 +08:00
parent c57e495d68
commit 66b9902d97
74 changed files with 1336 additions and 622 deletions

View File

@@ -0,0 +1,2 @@
export var validRegex =
/^([a-zA-Z0-9\.!#$%&'*+/=?^_`{|}~-]+)@([a-zA-Z0-9])+.([a-z]+)(.[a-z]+)?$/;

View File

@@ -17,7 +17,7 @@ import {
import { ProfileView } from "../profile";
import { ListPortofolioView } from "../portofolio";
import { MODEL_PROFILE_OLD } from "@/app_modules/home/model/user_profile";
import { LIST_PORTOFOLIO } from "@/app_modules/model_global/portofolio";
import { MODEL_PORTOFOLIO_Lama } from "@/app_modules/model_global/portofolio";
import User_Logout from "@/app_modules/auth/logout/view";
import { MODEL_PORTOFOLIO } from "../portofolio/model/interface";
import { MODEL_PROFILE } from "../profile/model/interface";
@@ -28,10 +28,9 @@ export default function KatalogView({
userLoginId,
}: {
profile: MODEL_PROFILE;
listPorto: LIST_PORTOFOLIO;
listPorto: MODEL_PORTOFOLIO;
userLoginId: string;
}) {
return (
<>
<Stack>
@@ -41,9 +40,9 @@ export default function KatalogView({
profile={profile}
userLoginId={userLoginId}
/>
<Stack my={"lg"} w={"100%"}>
{profile?.User.id === userLoginId ? <User_Logout /> : ""}
</Stack>
<Stack my={"lg"} w={"100%"}>
{profile?.User.id === userLoginId ? <User_Logout /> : ""}
</Stack>
</Stack>
</>
);

View File

@@ -72,6 +72,7 @@ export default function CreatePortofolio({
withAsterisk
label="Nama Bisnis"
placeholder="Nama bisnis"
error={value.namaBisnis.length > 100 ? "Maksimal 100 karakter" : ""}
onChange={(val) => {
setValue({
...value,
@@ -98,6 +99,9 @@ export default function CreatePortofolio({
withAsterisk
label="Alamat Kantor"
placeholder="Alamat kantor"
error={
value.alamatKantor.length > 100 ? "Maksimal 100 karakter" : ""
}
onChange={(val) => {
setValue({
...value,
@@ -108,7 +112,7 @@ export default function CreatePortofolio({
<TextInput
withAsterisk
label="Nomor Telepon Kantor"
placeholder="62 xxx xxx xxx"
placeholder="Nomor telepon kantor"
type="number"
onChange={(val) => {
setValue({
@@ -124,6 +128,7 @@ export default function CreatePortofolio({
withAsterisk
label="Deskripsi"
placeholder="Deskripsi singkat mengenai usaha"
error={value.deskripsi.length > 150 ? "Maksimal 150 karakter" : ""}
onChange={(val) => {
setValue({
...value,
@@ -270,7 +275,11 @@ async function onSubmit(
if (_.values(porto).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
if (!file)
return ComponentGlobal_NotifikasiPeringatan("Lengkapi logo binnis");
return ComponentGlobal_NotifikasiPeringatan("Lengkapi logo bisnis");
if (porto.namaBisnis.length > 100) return null;
if (porto.alamatKantor.length > 100) return null;
if (porto.deskripsi.length > 150) return null;
const gambar = new FormData();
gambar.append("file", file as any);

View File

@@ -12,6 +12,7 @@ import { useRouter } from "next/navigation";
import { Portofolio_funEditDataBisnis } from "../../fun/edit/fun_edit_data_bisnis_by_id";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
export default function Portofolio_EditDataBisnis({
dataPorto,
@@ -21,15 +22,9 @@ export default function Portofolio_EditDataBisnis({
listBidang: MODEL_PORTOFOLIO_BIDANG_BISNIS[];
}) {
const router = useRouter();
const [porto, setPorto] = useState(dataPorto);
const [value, setValue] = useState(dataPorto);
const [loading, setLoading] = useState(false);
// const [value, setPorto] = useState({
// namaBisnis: "",
// masterBidangBisnisId: "",
// alamatKantor: "",
// tlpn: "",
// deskripsi: "",
// });
return (
<>
{/* <pre>{JSON.stringify(porto, null, 2)}</pre> */}
@@ -37,19 +32,20 @@ export default function Portofolio_EditDataBisnis({
<Stack>
<TextInput
withAsterisk
value={porto.namaBisnis}
value={value.namaBisnis}
label="Nama Bisnis"
placeholder="Nama bisnis"
error={value.namaBisnis.length > 100 ? "Maksimal 100 karakter" : ""}
onChange={(val) => {
setPorto({
...porto,
setValue({
...value,
namaBisnis: val.target.value,
});
}}
/>
<Select
withAsterisk
value={porto.MasterBidangBisnis.id}
value={value.MasterBidangBisnis.id}
label="Bidang Bisnis"
placeholder="Pilih salah satu bidang bisnis"
data={listBidang.map((e) => ({
@@ -57,8 +53,8 @@ export default function Portofolio_EditDataBisnis({
label: e.name,
}))}
onChange={(val) => {
setPorto({
...(porto as any),
setValue({
...(value as any),
MasterBidangBisnis: {
id: val,
},
@@ -67,25 +63,28 @@ export default function Portofolio_EditDataBisnis({
/>
<TextInput
withAsterisk
value={porto.alamatKantor}
value={value.alamatKantor}
label="Alamat Kantor"
placeholder="Alamat kantor"
error={
value.alamatKantor.length > 100 ? "Maksimal 100 karakter" : ""
}
onChange={(val) => {
setPorto({
...porto,
setValue({
...value,
alamatKantor: val.target.value,
});
}}
/>
<TextInput
withAsterisk
value={porto.tlpn}
value={value.tlpn}
label="Nomor Telepon Kantor"
placeholder="62 xxx xxx xxx"
type="number"
onChange={(val) => {
setPorto({
...porto,
setValue({
...value,
tlpn: val.target.value,
});
}}
@@ -95,12 +94,13 @@ export default function Portofolio_EditDataBisnis({
minRows={2}
maxRows={5}
withAsterisk
value={porto.deskripsi}
value={value.deskripsi}
label="Deskripsi"
placeholder="Deskripsi singkat mengenai usaha"
error={value.deskripsi.length > 150 ? "Maksimal 150 karakter" : ""}
onChange={(val) => {
setPorto({
...porto,
setValue({
...value,
deskripsi: val.target.value,
});
}}
@@ -111,7 +111,7 @@ export default function Portofolio_EditDataBisnis({
loading={loading ? true : false}
loaderPosition="center"
onClick={() => {
onUpdate(router, porto as any, setLoading);
onUpdate(router, value as any, setLoading);
}}
>
Update
@@ -126,6 +126,13 @@ async function onUpdate(
data: MODEL_PORTOFOLIO,
setLoading: any
) {
if (_.values(data).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
if (data.namaBisnis.length > 100) return null;
if (data.alamatKantor.length > 100) return null;
if (data.deskripsi.length > 150) return null;
await Portofolio_funEditDataBisnis(data).then((res) => {
if (res.status === 200) {
setLoading(true);

View File

@@ -7,6 +7,7 @@ import {
Group,
Loader,
Paper,
ScrollArea,
SimpleGrid,
Stack,
Text,
@@ -24,32 +25,33 @@ import {
IconPencilPlus,
} from "@tabler/icons-react";
import { LIST_PORTOFOLIO } from "@/app_modules/model_global/portofolio";
import { MODEL_PORTOFOLIO_Lama } from "@/app_modules/model_global/portofolio";
import { useRouter } from "next/navigation";
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
import { Warna } from "@/app/lib/warna";
import { MODEL_PROFILE } from "../../profile/model/interface";
import { MODEL_PORTOFOLIO } from "../model/interface";
export default function ListPortofolioView({
listPorto,
profile,
userLoginId,
}: {
listPorto: LIST_PORTOFOLIO[];
listPorto: MODEL_PORTOFOLIO[];
profile: MODEL_PROFILE;
userLoginId: string;
}) {
const router = useRouter();
const [porto, setPorto] = useState(listPorto);
// const [porto, setPorto] = useState(listPorto);
const [loading, setLoading] = useState(false);
const [loadingPorto, setLoadingPorto] = useState(false);
const [idPorto, setIdPorto] = useState("")
const [idPorto, setIdPorto] = useState("");
return (
<>
{/* <pre>{JSON.stringify(porto, null, 2)}</pre> */}
<Paper p={"md"} shadow="lg" withBorder bg={"gray.1"}>
<Stack spacing={"lg"}>
<Stack spacing={"sm"}>
<Group position="apart">
<ActionIcon variant="transparent" disabled></ActionIcon>
<Title order={4}>Portofolio</Title>
@@ -68,55 +70,67 @@ export default function ListPortofolioView({
<ActionIcon variant="transparent" disabled></ActionIcon>
)}
</Group>
<Box>
{_.isEmpty(porto) ? (
<Center>
<Text fs={"italic"} fz={"xs"}>
- Belum Ada Portofolio -
</Text>
</Center>
) : (
<SimpleGrid
cols={4}
spacing="md"
breakpoints={[
{ maxWidth: "md", cols: 3, spacing: "md" },
{ maxWidth: "sm", cols: 2, spacing: "sm" },
{ maxWidth: "xs", cols: 1, spacing: "sm" },
]}
>
{porto.map((e) => (
<Paper
shadow="md"
key={e.id}
bg={"gray.5"}
radius={"md"}
onClick={() => {
setIdPorto(e.id)
setLoadingPorto(true);
router.push(`/dev/portofolio/main/${e.id}/`);
}}
>
<Grid align="center" p={"sm"}>
<Grid.Col span={"auto"}>
<Text fw={"bold"} lineClamp={1}>
{e.namaBisnis}
</Text>
</Grid.Col>
<Grid.Col span={"content"}>
<Stack>
{idPorto === e.id && loadingPorto ? (
<Loader color="gray" size={25}/>
) : (
<IconCaretRight color="black" size={25} />
)}
</Stack>
</Grid.Col>
</Grid>
</Paper>
))}
</SimpleGrid>
)}
<Box
h={
_.isEmpty(listPorto)
? 50
: listPorto.length === 1
? 100
: listPorto.length === 2
? 150
: 200
}
>
<ScrollArea h={"100%"} scrollbarSize={10}>
{_.isEmpty(listPorto) ? (
<Center>
<Text fs={"italic"} fz={"xs"} c={"gray"}>
- Belum Ada Portofolio -
</Text>
</Center>
) : (
<SimpleGrid
cols={4}
spacing="md"
breakpoints={[
{ maxWidth: "md", cols: 3, spacing: "md" },
{ maxWidth: "sm", cols: 2, spacing: "sm" },
{ maxWidth: "xs", cols: 1, spacing: "sm" },
]}
>
{listPorto.map((e, i) => (
<Paper
shadow="sm"
key={i}
bg={"gray.5"}
radius={"md"}
onClick={() => {
setIdPorto(e?.id);
setLoadingPorto(true);
router.push(`/dev/portofolio/main/${e?.id}/`);
}}
>
<Grid align="center" p={"sm"}>
<Grid.Col span={"auto"}>
<Text fw={"bold"} lineClamp={1}>
{e?.namaBisnis}
</Text>
</Grid.Col>
<Grid.Col span={"content"}>
<Stack>
{idPorto === e?.id && loadingPorto ? (
<Loader color="gray" size={25} />
) : (
<IconCaretRight color="black" size={25} />
)}
</Stack>
</Grid.Col>
</Grid>
</Paper>
))}
</SimpleGrid>
)}
</ScrollArea>
</Box>
</Stack>
</Paper>

View File

@@ -185,16 +185,20 @@ export default function ViewPortofolio({
</Grid>
</Stack>
</Paper>
<Button
radius={"xl"}
bg={"red"}
color="red"
onClick={() => {
open();
}}
>
<IconTrash />
</Button>
{userLoginId === dataPorto.Profile.User.id ? (
<Button
radius={"xl"}
bg={"red"}
color="red"
onClick={() => {
open();
}}
>
<IconTrash />
</Button>
) : (
""
)}
</Stack>
<Modal opened={opened} onClose={close} centered withCloseButton={false}>
@@ -227,7 +231,7 @@ async function onDelete(
) {
await Portofolio_funDeletePortofolioById(dataPorto).then((res) => {
if (res.status === 200) {
setLoadingDel(true)
setLoadingDel(true);
ComponentGlobal_NotifikasiBerhasil(res.message);
router.push(RouterProfile.katalog + `${dataPorto.profileId}`);
} else {

View File

@@ -1,4 +1,6 @@
import { MODEL_USER } from "@/app_modules/home/model/interface";
import { MODEL_IMAGES } from "@/app_modules/model_global/interface";
import { MODEL_PROFILE } from "../../profile/model/interface";
export interface MODEL_PORTOFOLIO {
id: string;
@@ -13,6 +15,7 @@ export interface MODEL_PORTOFOLIO {
Logo: MODEL_IMAGES;
logoId: string;
Portofolio_MediaSosial: MODEL_PORTOFOLIO_MEDSOS
Profile: MODEL_PROFILE
}
export interface MODEL_PORTOFOLIO_BIDANG_BISNIS {

View File

@@ -34,6 +34,7 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
import { useForm } from "@mantine/form";
import { useTimeout } from "@mantine/hooks";
import { validRegex } from "../../component/regular_expressions";
export default function CreateProfile({ userId }: { userId: any }) {
const [filePP, setFilePP] = useState<File | null>(null);
@@ -210,7 +211,7 @@ export default function CreateProfile({ userId }: { userId: any }) {
label="Email"
placeholder="Contoh: User@gmail.com"
error={
value.email.length > 0 && !value.email.includes("@")
value.email.length > 0 && !value.email.match(validRegex)
? "Invalid email"
: ""
}
@@ -225,6 +226,7 @@ export default function CreateProfile({ userId }: { userId: any }) {
withAsterisk
label="Alamat"
placeholder="Alamat lengkap"
error={value.alamat.length > 100 ? "Max 100 karakter" : ""}
onChange={(val) => {
setValue({
...value,
@@ -232,6 +234,7 @@ export default function CreateProfile({ userId }: { userId: any }) {
});
}}
/>
<Select
withAsterisk
label="Jenis Kelamin"
@@ -247,6 +250,7 @@ export default function CreateProfile({ userId }: { userId: any }) {
});
}}
/>
<ButtonAction
value={value as any}
userId={userId}
@@ -283,8 +287,8 @@ function ButtonAction({
};
if (_.values(body).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
if (!body.email.includes("@"))
return ComponentGlobal_NotifikasiPeringatan("Invalid Email");
if (!body.email.match(validRegex)) return null;
if (body.alamat.length > 100) return null;
const gambarPP = new FormData();
gambarPP.append("filePP", filePP as any);

View File

@@ -17,6 +17,8 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/
import { MODEL_PROFILE } from "../model/interface";
import { Profile_funEditById } from "../fun/update/fun_edit_profile_by_id";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { validRegex } from "../../component/regular_expressions";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
const router = useRouter();
@@ -29,7 +31,10 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
const body = dataProfile;
// console.log(body)
if (_.values(body).includes("")) return toast("Lengkapi data");
if (_.values(body).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi data");
if (!body.email.match(validRegex)) return null;
if (body.alamat.length > 100) return null;
await Profile_funEditById(body).then((res) => {
if (res.status === 200) {
@@ -100,7 +105,8 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
label="Email"
placeholder="email"
error={
dataProfile?.email?.length > 0 && !dataProfile?.email.includes("@")
dataProfile?.email?.length > 0 &&
!dataProfile?.email.match(validRegex)
? "Invalid email"
: ""
}
@@ -118,6 +124,7 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
label="Alamat"
placeholder="alamat"
value={dataProfile.alamat}
error={dataProfile.alamat.length > 100 ? "Max 100 karakter" : ""}
onChange={(val) => {
setDataProfile({
...dataProfile,

View File

@@ -5,6 +5,8 @@ import { MODEL_PROFILE } from "../model/interface";
import _ from "lodash";
import { v4 } from "uuid";
import fs from "fs";
import { revalidatePath } from "next/cache";
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
export default async function funCreateNewProfile(
req: MODEL_PROFILE,
@@ -22,6 +24,10 @@ export default async function funCreateNewProfile(
if (findEmail) return { status: 400, message: "Email telah digunakan" };
const gambarProfile: any = gambarPP.get("filePP");
if (gambarProfile === "null")
return { status: 400, message: "Lengkapi Foto Profile" };
const fileName = gambarProfile.name;
const fileExtension = _.lowerCase(gambarProfile.name.split(".").pop());
const fRandomName = v4(fileName) + "." + fileExtension;
@@ -42,6 +48,9 @@ export default async function funCreateNewProfile(
fs.writeFileSync(`./public/profile/foto/${uploadPP.url}`, uploadPP_Folder);
const gambarBackground: any = gambarBG.get("fileBG");
if (gambarBackground === "null")
return { status: 400, message: "Lengkapi Foto Background" };
const fileNameBG = gambarBackground.name;
const fileExtensionBG = _.lowerCase(gambarBackground.name.split(".").pop());
const fRandomNameBG = v4(fileNameBG) + "." + fileExtensionBG;
@@ -65,8 +74,6 @@ export default async function funCreateNewProfile(
uploadBG_Folder
);
const createProfile = await prisma.profile.create({
data: {
userId: body.userId,
@@ -80,6 +87,7 @@ export default async function funCreateNewProfile(
});
if (!createProfile) return { status: 400, message: "Gagal membuat profile" };
revalidatePath(RouterHome.main_home);
return {
status: 201,