This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat-history-page
- Loading branch information
Showing
65 changed files
with
13,790 additions
and
11,417 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 React, { type ReactNode } from "react" | ||
|
||
interface ButtonProps | ||
extends React.PropsWithChildren<React.ButtonHTMLAttributes<HTMLButtonElement>> { | ||
icon?: ReactNode | ||
} | ||
|
||
export default function Button({ icon, children, ...delegated }: ButtonProps) { | ||
return ( | ||
<button className="bg-primary-500" {...delegated}> | ||
{icon} | ||
<span>{children}</span> | ||
</button> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,20 +1,46 @@ | ||
import React from "react" | ||
import * as Form from "@radix-ui/react-form" | ||
import type { UseFormRegister } from "react-hook-form" | ||
import type { Inputs } from "./DownloadModal.tsx" | ||
|
||
interface CustomInputProps { | ||
label: string | ||
placeholder: string | ||
} | ||
|
||
export const CustomInput: React.FC<CustomInputProps> = ({ label, placeholder }) => { | ||
return ( | ||
<> | ||
export const CustomInput = React.forwardRef< | ||
HTMLInputElement, | ||
{ | ||
label: string | ||
placeholder: string | ||
errorMessage?: string | ||
match?: | ||
| "valueMissing" | ||
| "badInput" | ||
| "patternMismatch" | ||
| "rangeOverflow" | ||
| "rangeUnderflow" | ||
| "stepMismatch" | ||
| "tooLong" | ||
| "tooShort" | ||
| "typeMismatch" | ||
| "valid" | ||
} & ReturnType<UseFormRegister<Inputs>> | ||
>(({ onChange, onBlur, name, label, placeholder, match, errorMessage }, ref) => ( | ||
<Form.Field name={name} className="flex flex-col gap-2"> | ||
<Form.Label>{label}</Form.Label> | ||
<Form.Control asChild> | ||
<input | ||
name={label} | ||
id={label} | ||
className="text-gray-400 text-sm font-medium outline-none border-b-2 py-2 w-full my-4 mx-2" | ||
name={name} | ||
onChange={onChange} | ||
onBlur={onBlur} | ||
placeholder={placeholder} | ||
ref={ref} | ||
required | ||
/> | ||
</> | ||
) | ||
} | ||
</Form.Control> | ||
<Form.Message className="text-primary-300" match="valueMissing"> | ||
Please enter your {label} | ||
</Form.Message> | ||
{match !== undefined && ( | ||
<> | ||
<Form.Message match={match}>{errorMessage}</Form.Message> | ||
</> | ||
)} | ||
</Form.Field> | ||
)) |
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 |
---|---|---|
@@ -1,19 +1,31 @@ | ||
import React from "react" | ||
import * as Form from "@radix-ui/react-form" | ||
import type { UseFormRegister } from "react-hook-form" | ||
import type { Inputs } from "./DownloadModal.tsx" | ||
|
||
interface CustomTextareaProps { | ||
label: string | ||
placeholder: string | ||
} | ||
|
||
export const CustomTextarea: React.FC<CustomTextareaProps> = ({ label, placeholder }) => { | ||
return ( | ||
<> | ||
export const CustomTextarea = React.forwardRef< | ||
HTMLTextAreaElement, | ||
{ | ||
label: string | ||
placeholder: string | ||
} & ReturnType<UseFormRegister<Inputs>> | ||
>(({ onChange, onBlur, name, label, placeholder }, ref) => ( | ||
<Form.Field name={name} className="flex flex-col gap-2"> | ||
<Form.Label>{label}</Form.Label> | ||
<Form.Control asChild> | ||
<textarea | ||
rows={4} | ||
id={label} | ||
className="text-gray-400 text-sm font-medium outline-none border-b-2 py-2 w-full my-4 mx-2" | ||
name={name} | ||
ref={ref} | ||
onChange={onChange} | ||
onBlur={onBlur} | ||
className="text-gray-400 text-sm font-medium outline-none border-b-2 w-full" | ||
placeholder={placeholder} | ||
required | ||
/> | ||
</> | ||
) | ||
} | ||
</Form.Control> | ||
<Form.Message className="text-primary-300" match="valueMissing"> | ||
Please enter your {label} | ||
</Form.Message> | ||
</Form.Field> | ||
)) |
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,52 @@ | ||
import React, { useState } from "react" | ||
import DataTable from "../components/DataTable" | ||
import DownloadModal from "../components/DownloadModal" | ||
|
||
export interface FileItem { | ||
title: string | ||
cat: string | ||
file: string | ||
description?: string | ||
selected: boolean | ||
} | ||
|
||
interface DataFormProps { | ||
allFiles: { | ||
data: { | ||
title: string | ||
cat: string | ||
file: string | ||
description?: string | ||
} | ||
}[] | ||
} | ||
|
||
const DataForm: React.FC<DataFormProps> = ({ allFiles }) => { | ||
const [files, setFiles] = useState( | ||
allFiles.map((file) => { | ||
return { ...file.data, selected: false } | ||
}) | ||
) | ||
|
||
/** | ||
* Given a target file name and new `selected` field for that file, update the matching file object in{@link files} | ||
* with the new value for `selected`. | ||
*/ | ||
const updateFileList = ({ file: targetFile }: FileItem, selection: boolean) => { | ||
const updatedFiles = files.map(({ file, selected, ...rest }) => { | ||
return file === targetFile | ||
? { file, selected: selection, ...rest } | ||
: { file, selected, ...rest } | ||
}) | ||
|
||
setFiles(updatedFiles) | ||
} | ||
|
||
return ( | ||
<div className="space-y-4"> | ||
<DownloadModal filesToDownload={files.map((file) => file.file)} /> | ||
<DataTable allFiles={files} updateFileList={updateFileList} /> | ||
</div> | ||
) | ||
} | ||
export default DataForm |
Oops, something went wrong.