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

Johnny/add file date change #179

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ model Senior {

model File {
id String @id @default(auto()) @map("_id") @db.ObjectId
date DateTime // will zero out the hours
date DateTime @db.Date // will zero out the hours
filetype String

// Use with Google API
Expand Down
5 changes: 3 additions & 2 deletions src/components/user/AddFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ const AddFile = ({
}: AddFileProps) => {
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 @@ -105,7 +107,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 @@ -173,7 +174,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"
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
Loading