-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #331 from captableinc/feat/create-share-page
feat: Allocate shares to stakeholders
- Loading branch information
Showing
31 changed files
with
2,086 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
prisma/migrations/20240531045514_uniq_certificate_on_share/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
Warnings: | ||
- A unique constraint covering the columns `[companyId,certificateId]` on the table `Share` will be added. If there are existing duplicate values, this will fail. | ||
*/ | ||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Share_companyId_certificateId_key" ON "Share"("companyId", "certificateId"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 59 additions & 11 deletions
70
src/app/(authenticated)/(dashboard)/[publicId]/securities/shares/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/(authenticated)/(dashboard)/[publicId]/settings/company/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { cn } from "@/lib/utils"; | ||
|
||
export interface ISVGProps extends React.SVGProps<SVGSVGElement> { | ||
size?: number; | ||
className?: string; | ||
} | ||
|
||
export const LoadingSpinner = ({ | ||
size = 24, | ||
className, | ||
...props | ||
}: ISVGProps) => { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={size} | ||
height={size} | ||
{...props} | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
stroke="currentColor" | ||
strokeWidth="2" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
className={cn("animate-spin", className)} | ||
> | ||
<title>Loading</title> | ||
<path d="M21 12a9 9 0 1 1-6.219-8.56" /> | ||
</svg> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; | ||
|
||
interface EmptySelectProps { | ||
title: string; | ||
description: string; | ||
} | ||
|
||
export function EmptySelect({ title, description }: EmptySelectProps) { | ||
return ( | ||
<Alert variant="destructive"> | ||
<AlertTitle>{title}</AlertTitle> | ||
<AlertDescription>{description}</AlertDescription> | ||
</Alert> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { SecuritiesStatusEnum } from "@prisma/client"; | ||
import { capitalize } from "lodash-es"; | ||
|
||
export const statusValues = Object.keys(SecuritiesStatusEnum).map((item) => ({ | ||
label: capitalize(item), | ||
value: item, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
StepperModal, | ||
StepperModalContent, | ||
type StepperModalProps, | ||
StepperStep, | ||
} from "@/components/ui/stepper"; | ||
import { AddShareFormProvider } from "@/providers/add-share-form-provider"; | ||
import { api } from "@/trpc/server"; | ||
import { ContributionDetails } from "./steps/contribution-details"; | ||
import { Documents } from "./steps/documents"; | ||
import { GeneralDetails } from "./steps/general-details"; | ||
import { RelevantDates } from "./steps/relevant-dates"; | ||
|
||
async function ContributionDetailsStep() { | ||
const stakeholders = await api.stakeholder.getStakeholders.query(); | ||
return <ContributionDetails stakeholders={stakeholders} />; | ||
} | ||
|
||
async function GeneralDetailsStep() { | ||
const shareClasses = await api.shareClass.get.query(); | ||
return <GeneralDetails shareClasses={shareClasses} />; | ||
} | ||
|
||
export const ShareModal = (props: Omit<StepperModalProps, "children">) => { | ||
return ( | ||
<StepperModal {...props}> | ||
<AddShareFormProvider> | ||
<StepperStep title="General details"> | ||
<StepperModalContent> | ||
<GeneralDetailsStep /> | ||
</StepperModalContent> | ||
</StepperStep> | ||
<StepperStep title="Contribution details"> | ||
<StepperModalContent> | ||
<ContributionDetailsStep /> | ||
</StepperModalContent> | ||
</StepperStep> | ||
<StepperStep title="Relevant dates"> | ||
<StepperModalContent> | ||
<RelevantDates /> | ||
</StepperModalContent> | ||
</StepperStep> | ||
<StepperStep title="Documents"> | ||
<StepperModalContent> | ||
<Documents /> | ||
</StepperModalContent> | ||
</StepperStep> | ||
</AddShareFormProvider> | ||
</StepperModal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useDataTable } from "@/components/ui/data-table/data-table"; | ||
import { ResetButton } from "@/components/ui/data-table/data-table-buttons"; | ||
import { DataTableFacetedFilter } from "@/components/ui/data-table/data-table-faceted-filter"; | ||
import { DataTableViewOptions } from "@/components/ui/data-table/data-table-view-options"; | ||
import { Input } from "@/components/ui/input"; | ||
import { statusValues } from "./data"; | ||
|
||
export function ShareTableToolbar() { | ||
const { table } = useDataTable(); | ||
const isFiltered = table.getState().columnFilters.length > 0; | ||
|
||
return ( | ||
<div className="flex w-full items-center justify-between"> | ||
<div className="flex flex-col gap-2 sm:flex-1 sm:flex-row sm:items-center sm:gap-0 sm:space-x-2"> | ||
<Input | ||
placeholder="Search by stakeholder name..." | ||
value={ | ||
(table.getColumn("stakeholderName")?.getFilterValue() as string) ?? | ||
"" | ||
} | ||
onChange={(event) => | ||
table | ||
.getColumn("stakeholderName") | ||
?.setFilterValue(event.target.value) | ||
} | ||
className="h-8 w-64" | ||
/> | ||
<div className="space-x-2"> | ||
{table.getColumn("status") && ( | ||
<DataTableFacetedFilter | ||
column={table.getColumn("status")} | ||
title="Status" | ||
options={statusValues} | ||
/> | ||
)} | ||
|
||
{isFiltered && ( | ||
<ResetButton | ||
className="p-1" | ||
onClick={() => table.resetColumnFilters()} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
<DataTableViewOptions /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.