Skip to content

Commit

Permalink
Merge pull request #210 from ahsanzizan/main
Browse files Browse the repository at this point in the history
Major fixes in organisasi segment
  • Loading branch information
ahsanzizan authored Jun 12, 2024
2 parents dbb4c1c + 1e5a3e7 commit dfa398d
Show file tree
Hide file tree
Showing 26 changed files with 170 additions and 268 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `image_description` to the `Organisasi` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE `Organisasi` ADD COLUMN `image_description` VARCHAR(191) NOT NULL;
31 changes: 16 additions & 15 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,22 @@ model Period_Year {
}

model Organisasi {
id String @id @default(uuid()) @map("suborgan_id") @db.Char(36)
period_id String
period Period_Year @relation(fields: [period_id], references: [id])
organisasi Organisasi_Type
organisasi_name String @map("organisasi_name")
logo String
description String @db.LongText
vision String
mission String
image String
companion String
structure String @db.LongText
contact String
created_at DateTime @default(now())
updated_at DateTime @updatedAt
id String @id @default(uuid()) @map("suborgan_id") @db.Char(36)
period_id String
period Period_Year @relation(fields: [period_id], references: [id])
organisasi Organisasi_Type
organisasi_name String @map("organisasi_name")
logo String
description String @db.LongText
vision String
mission String
image String
image_description String
companion String
structure String @db.LongText
contact String
created_at DateTime @default(now())
updated_at DateTime @updatedAt
@@unique([organisasi, period_id])
@@map("Organisasi")
Expand Down
2 changes: 2 additions & 0 deletions src/actions/organisasi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export async function suborganCreate(data: FormData) {
const companion = data.get("companion") as string;
const structure = data.get("structure") as string;
const contact = data.get("contact") as string;
const imageDescription = data.get("image_description") as string;

const image = data.get("image") as File;
const logo = data.get("logo") as File;
Expand All @@ -55,6 +56,7 @@ export async function suborganCreate(data: FormData) {
structure: structure,
contact: contact,
period: period,
image_description: imageDescription,
});
} catch (e) {
console.log(e);
Expand Down
Empty file.
16 changes: 15 additions & 1 deletion src/app/(admin)/admin/organisasi/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import { Organisasi_Type } from "@prisma/client";

import { findOrganisasi } from "@/utils/database/organisasi.query";
import { findLatestPeriod } from "@/utils/database/period.query";

export default async function Edit({
params,
}: {
params: { organisasi: string };
}) {
console.log(params);
const latestPeriod = await findLatestPeriod();
const organisasi = await findOrganisasi({
organisasi_period_id: {
period_id: latestPeriod.id,
organisasi: params.organisasi as Organisasi_Type,
},
});

console.log(organisasi);

return <></>;
}
Empty file.
8 changes: 6 additions & 2 deletions src/app/(admin)/admin/organisasi/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { H1 } from "@/app/_components/global/Text";

export default function SubOrgan() {
return <H1>Sub-organ</H1>;
export default function SuborAdmin() {
return (
<>
<H1>TOLONG DISLICE</H1>
</>
);
}
22 changes: 0 additions & 22 deletions src/app/(admin)/admin/sub-organ/[slug]/page.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions src/app/(admin)/admin/sub-organ/page.tsx

This file was deleted.

24 changes: 24 additions & 0 deletions src/app/(main)/organisasi/[slug]/[period]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Organisasi_Type } from "@prisma/client";
import { notFound } from "next/navigation";

import { findOrganisasi } from "@/utils/database/organisasi.query";
import { findPeriod } from "@/utils/database/period.query";

export default async function OrganisasiByPeriod({
param,
}: {
param: { slug: string; period: string };
}) {
const period = await findPeriod(param.period);
if (!period) return notFound();

const organisasi = await findOrganisasi({
organisasi_period_id: {
organisasi: param.slug.toUpperCase() as Organisasi_Type,
period_id: period.id,
},
});
console.log(organisasi);

return <></>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Image from "@/app/_components/global/Image";
import { P, UnderlinedTitle } from "@/app/_components/global/Text";
import { SectionWrapper } from "@/app/_components/global/Wrapper";

export default function OrgGallery({ Images }: { Images: string[] }) {
export default function OrgGallery({ image }: { image: string }) {
return (
<SectionWrapper id="gallery">
<div className="flex flex-col gap-[54px] w-full">
Expand All @@ -24,33 +24,16 @@ export default function OrgGallery({ Images }: { Images: string[] }) {
</div>
</div>
<div className="flex gap-[18px] flex-col lg:flex-row items-center">
<div className="w-full lg:w-1/2 rounded-2xl overflow-hidden">
<div className="w-full rounded-2xl overflow-hidden">
<Image
src={Images[0]}
src={image}
alt="Image"
width={587}
height={407}
unoptimized
className="w-full h-full"
/>
</div>
<div className="w-full lg:w-1/2 flex flex-wrap gap-[18px]">
{Images.slice(1).map((image, i) => (
<div
key={i}
className="w-full sm:w-[48.2%] lg:w-[45%] h-[50%] rounded-2xl overflow-hidden"
>
<Image
src={image}
alt="Image"
width={284}
height={194}
unoptimized
className="w-full h-full"
/>
</div>
))}
</div>
</div>
</div>
</SectionWrapper>
Expand Down
30 changes: 30 additions & 0 deletions src/app/(main)/organisasi/[slug]/components/parts/Overview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { SelectField } from "@/app/_components/global/Input";
import { H2, P } from "@/app/_components/global/Text";
import { SectionWrapper } from "@/app/_components/global/Wrapper";

export default function Overview() {
return (
<SectionWrapper id={"overview"}>
<div className="flex flex-col gap-[58px] w-full">
<div className="w-full flex flex-col gap-[18px]">
<div className="flex md:gap-0 items-center justify-between">
<div className="flex flex-col gap-[44px]">
<div className="bg-primary-50 rounded-full w-[106px] h-[106px] border border-primary-400 flex justify-center items-center"></div>
<H2 className="font-bold">Media Moklet</H2>
</div>
<SelectField
name="Periode"
options={[{ label: "2023/2024", value: "2023/2024" }]}
/>
</div>
<P>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam
volutpat tellus quis urna gravida, quis ultrices arcu consequat.
Praesent aliquet ante molestie faucibus facilisis. Integer
fermentum, sapien ac tempor tempor.
</P>
</div>
</div>
</SectionWrapper>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export default function VisiMisi() {
return (
<SectionWrapper
id="visimisi"
className="flex justify-between w-full py-[62px]"
className="flex justify-between w-full py-[62px] flex-col gap-8 md:flex-row"
>
<div className="absolute bg-primary-400 w-screen h-[246px] -translate-x-1/2 left-1/2 -z-[999] -top-1/2 translate-y-1/2"></div>
<div className="flex gap-7 w-[48%]">
<div className="absolute bg-primary-400 w-screen h-full -translate-x-1/2 left-1/2 -z-[999] -top-1/2 translate-y-1/2"></div>
<div className="flex gap-7 w-full md:w-[48%]">
<div className="w-[52px] h-[52px] bg-white rounded-full flex justify-center items-center">
<OpenedBook />
</div>
Expand All @@ -21,7 +21,7 @@ export default function VisiMisi() {
</P>
</div>
</div>
<div className="flex gap-7 w-[48%]">
<div className="flex gap-7 w-full md:w-[48%]">
<div className="w-[52px] h-[52px] bg-white rounded-full flex justify-center items-center">
<OpenedBook />
</div>
Expand Down
39 changes: 39 additions & 0 deletions src/app/(main)/organisasi/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Organisasi_Type } from "@prisma/client";

import { findOrganisasi } from "@/utils/database/organisasi.query";
import { findLatestPeriod } from "@/utils/database/period.query";
import { findNewestPost } from "@/utils/database/post.query";

import Contact from "./components/parts/Contact";
import OrgGallery from "./components/parts/Gallery";
import Overview from "./components/parts/Overview";
import RelatedNews from "./components/parts/RelatedNews";
import Structure from "./components/parts/Stucture";
import VisiMisi from "./components/parts/VisiMisi";

const image = "https://placehold.co/750x500?text=1";

export default async function Organ({ params }: { params: { slug: string } }) {
const organisasiType = params.slug.toUpperCase() as Organisasi_Type;
const latestPeriod = await findLatestPeriod();
const organisasi = await findOrganisasi({
organisasi_period_id: {
organisasi: organisasiType,
period_id: latestPeriod.id,
},
});
const relatedNews = await findNewestPost(5, {
tags: { some: { tagName: organisasiType } },
});

return (
<>
<Overview />
<VisiMisi />
<Structure />
<OrgGallery image={image} />
<RelatedNews data={relatedNews} orgName={organisasiType} />
<Contact />
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ export default function OrganizationSection({
<P>{data.sectionDesc}</P>
</div>
<div className="w-full lg:w-[618px] flex flex-col gap-[18px]">
{data.sectionOrgans.map((organ) => (
{data.sectionOrgans.map((organisasi) => (
<Link
className="w-full rounded-xl border p-[22px] border-neutral-400 flex items-center justify-between gap-[42px] group transition-all hover:border-primary-300 duration-300"
href={`/sub-organ/${organ.name}`}
key={organ.name}
href={`/organisasi/${organisasi.name}`}
key={organisasi.name}
>
<div className="flex items-center gap-[26px]">
<Image
alt={organ.name}
src={organ.image}
alt={organisasi.name}
src={organisasi.image}
width={62}
height={62}
unoptimized
/>
<div className="flex flex-col gap-[6px]">
<H4>{organ.name}</H4>
<P>{organ.desc}</P>
<H4>{organisasi.name}</H4>
<P>{organisasi.desc}</P>
</div>
</div>
<ArrowRight className="group-hover:translate-x-1/4 transition-all duration-300" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { ReactElement } from "react";

import Book from "@/app/_components/icons/Book";
import Language from "@/app/_components/icons/Language";
import Weight from "@/app/_components/icons/Weight";
import { FaGlobe } from "react-icons/fa";
import { FaUserGroup } from "react-icons/fa6";

import OrganizationSection from "../OrganizationSection";

Expand All @@ -22,8 +20,8 @@ export interface SuborganSection {

const organizations: SuborganSection[] = [
{
sectionName: "Olahraga",
sectionLogo: <Weight />,
sectionName: "Organisasi",
sectionLogo: <FaGlobe />,
sectionDesc:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam volutpat tellus quis urna gravida. Quis ultrices arcu consequat. Praesent aliquet ante molestie faucibus facilisis. Integer fermentum, sapien ac.",
sectionOrgans: [
Expand Down Expand Up @@ -54,8 +52,8 @@ const organizations: SuborganSection[] = [
],
},
{
sectionName: "Seni & Bahasa",
sectionLogo: <Language />,
sectionName: "Sub-organisasi",
sectionLogo: <FaUserGroup />,
sectionDesc:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam volutpat tellus quis urna gravida. Quis ultrices arcu consequat. Praesent aliquet ante molestie faucibus facilisis. Integer fermentum, sapien ac.",
sectionOrgans: [
Expand Down Expand Up @@ -85,26 +83,6 @@ const organizations: SuborganSection[] = [
},
],
},
{
sectionName: "Ilmu",
sectionLogo: <Book />,
sectionDesc:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam volutpat tellus quis urna gravida. Quis ultrices arcu consequat. Praesent aliquet ante molestie faucibus facilisis. Integer fermentum, sapien ac.",
sectionOrgans: [
{
name: "Palwaga",
desc: "Lorem ipsum dolor sit amet, consectetur adipiscing",
image: "https://placehold.co/62x62?text=Logo",
href: "#",
},
{
name: "Comet",
desc: "Lorem ipsum dolor sit amet, consectetur adipiscing",
image: "https://placehold.co/62x62?text=Logo",
href: "#",
},
],
},
];

export default function Organizations() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import Hero from "./_components/Parts/Hero";
import Organizations from "./_components/Parts/Organizations";

export default async function SubOrganPage() {
export default async function OrganisasiPage() {
return (
<>
<Hero />
<Organizations />
</>
);
Expand Down
Loading

0 comments on commit dfa398d

Please sign in to comment.