adding new billing location completed
This commit is contained in:
@@ -30,7 +30,7 @@ const UpdateLocation = FormSchema.omit({ _id: true });
|
||||
* @param formData form data
|
||||
* @returns
|
||||
*/
|
||||
export async function updateOrAddLocation(locationId?: string, prevState:State, formData: FormData) {
|
||||
export async function updateOrAddLocation(locationId?: string, yearMonth?: string, prevState:State, formData: FormData) {
|
||||
|
||||
const validatedFields = UpdateLocation.safeParse({
|
||||
locationName: formData.get('locationName'),
|
||||
@@ -65,12 +65,12 @@ export async function updateOrAddLocation(locationId?: string, prevState:State,
|
||||
notes: locationNotes,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
} else if(yearMonth) {
|
||||
await db.collection<BillingLocation>("lokacije").insertOne({
|
||||
_id: (new ObjectId()).toHexString(),
|
||||
name: locationName,
|
||||
notes: locationNotes,
|
||||
yearMonth: 202101, // ToDo: get the current year and month
|
||||
yearMonth: parseInt(yearMonth), // ToDo: get the current year and month
|
||||
bills: [],
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user