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

changed date field to store ISOstring and date format #179

Merged
merged 6 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
4 changes: 1 addition & 3 deletions src/components/user/AddFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const AddFile = ({
const currFiles = Object.values(files);
const excludeDates = currFiles.map((fileObj) => fileObj.date);

console.log(excludeDates);
const excludedDatesString = excludeDates
.map((dateObj) => dateObj.toDateString())
.filter((date) => editFile?.date.toDateString() !== date ?? true);
Expand All @@ -107,7 +106,6 @@ const AddFile = ({
const router = useRouter();
const [error, setError] = useState<boolean>(false);
const [selectedTags, setSelectedTags] = useState<TagProps[]>([]);

const handleResetState = () => {
setStartDate(new Date());
setSelectedTags([]);
Expand Down Expand Up @@ -175,7 +173,7 @@ const AddFile = ({
className="mb-4 h-12 w-full cursor-pointer rounded-lg pl-4"
selected={startDate}
onChange={(date) => date && setStartDate(date)}
dateFormat="dd MMMM yyyy"
dateFormat="YYYY-MM-dd"
johnny-t06 marked this conversation as resolved.
Show resolved Hide resolved
excludeDates={excludeDates}
/>
{excludedDatesString.includes(startDate.toDateString()) ? (
Expand Down
1 change: 1 addition & 0 deletions src/server/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const File = z.object({
date: z.string().transform((val) => {
const date = new Date(val);
date.setHours(0, 0, 0, 0);
date.toISOString();
return date;
}),
filetype: z.string(),
Expand Down