Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signing templates #618

Draft
wants to merge 63 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
157bb20
feat: added templates feature
rajdip-b Nov 29, 2023
8e6a108
feat: added templates feature
rajdip-b Nov 29, 2023
5845d64
Merge branch 'main' into feat/template
rajdip-b Nov 29, 2023
fd57462
Merge branch 'main' into feat/template
DonKoko Dec 4, 2023
c02ebec
fix: fix migration name
rajdip-b Dec 4, 2023
eae6e41
fix: template form signature toggle fixed
rajdip-b Dec 4, 2023
0b65cb4
fix: fixed file size not uploading and file naming convention
rajdip-b Dec 5, 2023
c22afc8
Merge branch 'main' into feat/template
rajdip-b Dec 6, 2023
2e8c271
patch: update new template file name and related routes
rajdip-b Dec 6, 2023
cfa9b18
Merge branch 'feat/template' of github.com:rajdip-b/shelf.nu into fea…
rajdip-b Dec 6, 2023
ac1f2d5
fix: fixed code styles and bugs in template module
rajdip-b Dec 6, 2023
4dad1a1
patch: update migration of template
rajdip-b Dec 7, 2023
4ba5a61
patch: refactor crop image function
rajdip-b Dec 7, 2023
ac54838
feat: add tier limit migration and template form validation
rajdip-b Dec 7, 2023
90d8d87
fix: fix template form
rajdip-b Dec 7, 2023
87c75e9
patch: update logo of pdf, deactivate and update template badge color
rajdip-b Dec 8, 2023
aa820e6
Merge branch 'main' into feat/template
DonKoko Dec 11, 2023
d989f71
fix: fixed asset, profile picture accepted size error
rajdip-b Dec 11, 2023
4da15b2
fix: add check before uploading file to bucket
rajdip-b Dec 12, 2023
7cfa064
docs: update get-started.md for templates
rajdip-b Dec 12, 2023
7984031
fixing broken svg props + adjusting some exports to follow our standards
DonKoko Dec 12, 2023
4de916b
syntax
DonKoko Dec 12, 2023
3419b0d
adjusting db structure
DonKoko Dec 12, 2023
f846e44
more small improvements
DonKoko Dec 12, 2023
b4764c4
Merge pull request #577 from rajdip-b/feat/template
DonKoko Dec 12, 2023
27da50a
Merge branch 'main' into signing-templates
DonKoko Dec 20, 2023
951ffca
Merge branch 'main' into signing-templates
DonKoko Dec 20, 2023
6a88b23
Merge branch 'main' into signing-templates
rajdip-b Dec 27, 2023
f2de0eb
Merge branch 'main' into signing-templates
DonKoko Dec 27, 2023
b51ef94
Merge branch 'signing-templates' into signing-templates
DonKoko Dec 27, 2023
18c34f6
feat: add template signing
rajdip-b Jan 18, 2024
7142316
Merge pull request #629 from rajdip-b/signing-templates
DonKoko Jan 30, 2024
3248f51
merging with main and fixing conflicts
DonKoko Jan 30, 2024
4b63a7a
minor adjustments and fixes related to front-end
DonKoko Jan 30, 2024
da7cc83
merged with main and fixed conflicts
DonKoko Feb 6, 2024
f06959b
Merge branch 'main' into signing-templates
DonKoko Feb 6, 2024
8c7d913
Merge branch 'main' into signing-templates
DonKoko Feb 6, 2024
852dbd3
Merge branch 'main' into signing-templates
DonKoko Feb 19, 2024
95f74ce
update with main and fix conflicts
DonKoko Apr 5, 2024
e0af62c
merge with main
DonKoko Apr 16, 2024
6009222
logic fixes
rajdip-b Apr 17, 2024
4f610d0
updated branch and fixed conflicts, added lots of @TODO and comments
DonKoko Apr 17, 2024
8257392
Merge branch 'main' into signing-templates
DonKoko Apr 23, 2024
8937613
Merge branch 'signing-templates' into signing-templates
rajdip-b Apr 24, 2024
c0b7edd
minor changes on template fetch function
rajdip-b Apr 24, 2024
4de77d0
Merge branch 'main' into signing-templates
DonKoko Apr 26, 2024
2a9ece3
Merge branch 'main' into signing-templates
DonKoko Apr 29, 2024
ee57689
updated with main and fixed conflicts
DonKoko May 9, 2024
c8d0c5f
fixed todos
rajdip-b May 13, 2024
a5dab0d
Merge branch 'signing-templates' of github.com:Shelf-nu/shelf.nu into…
rajdip-b May 13, 2024
ef06537
Merge branch 'main' into signing-templates
DonKoko May 14, 2024
8eed038
Merge branch 'signing-templates' of github.com:Shelf-nu/shelf.nu into…
rajdip-b May 16, 2024
dadbe79
updated template creation and updation functionality
rajdip-b May 16, 2024
53eb4e4
tapped into pdf version in sign component
rajdip-b May 16, 2024
49e31a9
Merge pull request #915 from rajdip-b/signing-templates
DonKoko May 21, 2024
031d4e7
merge with main, fix conflicts, remove vulnurable packages
DonKoko May 21, 2024
c9dbad9
Merge branch 'main' into signing-templates
DonKoko May 21, 2024
6c1260a
Multiple small updates:
DonKoko May 21, 2024
9b17115
working on assign custody flow including template
DonKoko May 21, 2024
4248a4c
some fixes to check-out modal and selects
DonKoko May 22, 2024
32c17c9
fixed bugs with custody assignment
rajdip-b May 31, 2024
7bd5d8e
updated zod schema
rajdip-b May 31, 2024
d65c110
Merge pull request #1007 from rajdip-b/signing-templates
DonKoko May 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/atoms/assign-custody-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { atom } from "jotai";

export const assignCustodyUser = atom<User | null>(null);

type User = {
id: string;
name: string;
userId: string;
};

assignCustodyUser.onMount = (setAtom) => {
setAtom(null);
};

export const updateSelectedCustodyUserAtom = atom(
null,
(_get, set, event: User | null) => set(assignCustodyUser, event)
);
14 changes: 10 additions & 4 deletions app/atoms/file.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import type { ChangeEvent } from "react";
import { atom } from "jotai";
import { verifyAccept } from "~/utils";
import { formatBytes, verifyAccept } from "~/utils";

export const fileErrorAtom = atom<string | undefined>(undefined);
fileErrorAtom.onMount = (setAtom) => {
setAtom("");
};
export const MAX_SIZE = 4_000_000; // 4MB
DonKoko marked this conversation as resolved.
Show resolved Hide resolved

/** Validates the file atom */
export const validateFileAtom = atom(
Expand All @@ -12,17 +16,19 @@ export const validateFileAtom = atom(
const file = event?.target?.files?.[0];
if (file) {
const allowedType = verifyAccept(file.type, event.target.accept);
const allowedSize = file.size < 4_000_000;
const allowedSize = file.size < MAX_SIZE;

if (!allowedType) {
event.target.value = "";
return `Allowed file types are: PNG, JPG or JPEG`;
return `Allowed file types are: ${
event.target.accept === "pdf" ? "PDF" : "PNG, JPG or JPEG"
}`;
}

if (!allowedSize) {
/** Clean the field */
event.target.value = "";
return "Max file size is 4MB";
return `Max file size is ${formatBytes(MAX_SIZE)}`;
}

return undefined;
Expand Down
6 changes: 3 additions & 3 deletions app/components/assets/actions-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Button } from "../shared";
const ConditionalActionsDropdown = () => {
const { asset } = useLoaderData<typeof loader>();
const assetCanBeReleased = asset.custody;

let [searchParams] = useSearchParams();
const refIsQrScan = searchParams.get("ref") === "qr";
const defaultOpen = window.innerWidth <= 640 && refIsQrScan;
Expand Down Expand Up @@ -85,8 +86,7 @@ const ConditionalActionsDropdown = () => {
to="release-custody"
role="link"
variant="link"
className="justify-start whitespace-nowrap
px-4 py-3 text-gray-700 hover:text-gray-700"
className="justify-start whitespace-nowrap px-4 py-3 text-gray-700 hover:text-gray-700"
width="full"
onClick={() => setOpen(false)}
>
Expand All @@ -99,7 +99,7 @@ const ConditionalActionsDropdown = () => {
to="give-custody"
role="link"
variant="link"
className="justify-start px-4 py-3 text-gray-700 hover:text-gray-700"
className="justify-start px-4 py-3 text-gray-700 hover:text-gray-700"
width="full"
onClick={() => setOpen(false)}
>
Expand Down
18 changes: 15 additions & 3 deletions app/components/custody/custodian-select.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useLoaderData } from "@remix-run/react";
import { useAtom } from "jotai";
import type { loader } from "~/routes/_layout+/assets.$assetId.give-custody";
import { tw } from "~/utils";
import { updateSelectedCustodyUserAtom } from "../../atoms/assign-custody-user";
import {
Select,
SelectTrigger,
Expand Down Expand Up @@ -32,6 +34,7 @@ export default function CustodianSelect(
}
) {
const { teamMembers } = useLoaderData<typeof loader>();
const [, updateSelectedCustodyUser] = useAtom(updateSelectedCustodyUserAtom);

let defaultValue = undefined;

Expand All @@ -43,6 +46,7 @@ export default function CustodianSelect(
?.name,
userId: teamMembers.find((member) => member.id === defaultCustodianId)
?.userId,
email: null,
});
} else if (defaultTeamMemberId) {
// In the case of team member id passed, we set that to id and find the rest in the teamMembers array
Expand All @@ -52,12 +56,19 @@ export default function CustodianSelect(
name: teamMembers.find((member) => member.userId === defaultTeamMemberId)
?.name,
userId: defaultTeamMemberId,
email: teamMembers.find((member) => member.userId === defaultTeamMemberId)
?.user?.email,
});
}

return (
<div className="relative w-full">
<Select name="custodian" defaultValue={defaultValue} disabled={disabled}>
<Select
onValueChange={(value) => updateSelectedCustodyUser(JSON.parse(value))}
name="custodian"
disabled={disabled}
defaultValue={defaultValue}
>
<SelectTrigger
className={tw(disabled ? "cursor-not-allowed" : "", className)}
>
Expand All @@ -77,11 +88,12 @@ export default function CustodianSelect(
{teamMembers.map((member) => (
<SelectItem
key={member.id}
value={`${JSON.stringify({
value={JSON.stringify({
id: member.id,
name: member.name,
userId: member?.userId,
})}`}
email: member.user?.email,
})}
>
{member.user ? (
<div className="flex items-center gap-3 truncate py-3.5 pr-1">
Expand Down
64 changes: 64 additions & 0 deletions app/components/custody/template-select.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Link, useLoaderData } from "@remix-run/react";
import type { loader } from "~/routes/_layout+/assets.$assetId.give-custody";
import {
Select,
SelectTrigger,
SelectValue,
SelectContent,
SelectItem,
} from "../forms";
import { Button } from "../shared";

export default function TemplateSelect() {
const { templates } = useLoaderData<typeof loader>();
return (
<div className="relative w-full">
<Select name="template">
<SelectTrigger>
<SelectValue placeholder="Select a PDF template" />
</SelectTrigger>
<div>
<SelectContent
className="w-[352px]"
position="popper"
align="start"
ref={(ref) =>
ref?.addEventListener("touchend", (e) => e.preventDefault())
}
>
{templates.length > 0 ? (
<div className=" max-h-[320px] overflow-auto">
{templates.map((template) => (
<SelectItem
key={template.id}
value={JSON.stringify({
id: template.id,
name: template.name,
})}
>
<span className=" flex-1 font-medium text-gray-900">
{template.name}
</span>
</SelectItem>
))}
</div>
) : (
<div>
No team PDF templates found.{" "}
<Button to={"/settings/template"} variant="link">
Create PDF template
</Button>
</div>
)}
</SelectContent>
</div>
</Select>
<div className="mt-2 text-sm text-gray-500">
Manage PDF templates in{" "}
<Link className="text-gray-800 underline" to={"/settings/template"}>
settings
</Link>
</div>
</div>
);
}
Loading
Loading