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

[update]: refactoring some files #139

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions apps/web/src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const isAllowedUser = (email: string | undefined | null) => {
if (!email) {
return null
}
const userEmailname = email.split('@')[0]
if (!userEmailname) {
const userEmailName = email.split('@')[0]
if (!userEmailName) {
return null
}
console.log('your username ->', userEmailname)
return ALLOWED_USER.includes(userEmailname)
console.log('your username ->', userEmailName)
return ALLOWED_USER.includes(userEmailName)
} // Todo: Currently in dev mode will be removed

export const authOptions = {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/crons/invoices/update-status/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function GET(request: Request) {
)
return Response.json({
ok: true,
data: 'Your cron job for updating overdue payment is successful done',
data: 'Your cron job for updating overdue payments has been successfully completed.',
status: 200
})
} catch (error) {
Expand Down
12 changes: 9 additions & 3 deletions apps/web/src/app/api/customer/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export async function GET() {

const response = await db.customerInfo.findMany({
where: {
organisationId: orgId
organization: {
id: orgId
}
},
select: {
id: true,
Expand All @@ -31,7 +33,7 @@ export async function GET() {
}
})

return Response.json({ ok: true, data: response, staus: 200 })
return Response.json({ ok: true, data: response, status: 200 })
} catch (error) {
console.error('Error:', error)
return Response.json({ ok: false, data: null, status: 500 })
Expand All @@ -56,7 +58,11 @@ export async function POST(request: Request) {
const data: Customer = await request.json()
const customerRes = await db.customerInfo.create({
data: {
organisationId: orgId,
organization: {
connect: {
id: orgId
}
},
legalName: data.legalName,
email: data.email,
whatsAppNumber: data.whatsAppNumber
Expand Down
10 changes: 6 additions & 4 deletions apps/web/src/app/api/customer/search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ export async function GET(request: Request) {
const query = searchParams.get('query')
const response = await db.customerInfo.findMany({
where: {
organisationId: orgId,
organization: {
id: orgId
},
OR: [
{ legalName: { contains: query || '', mode: 'insensitive' } },
{ email: { contains: query || '', mode: 'insensitive' } }
{ legalName: { contains: query ?? '', mode: 'insensitive' } },
{ email: { contains: query ?? '', mode: 'insensitive' } }
]
},
select: {
Expand All @@ -37,7 +39,7 @@ export async function GET(request: Request) {
}
})

return Response.json({ ok: true, data: response, staus: 200 })
return Response.json({ ok: true, data: response, status: 200 })
} catch (error) {
console.error('Error:', error)
return Response.json({ ok: false, data: null, status: 500 })
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/events/invoice/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async function handler(req: NextRequest) {
await Processor.handleMessage(body)
return NextResponse.json({
ok: true,
data: 'job received successfully',
data: 'Job received successfully',
status: 200
})
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/invoice/[id]/approval/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function PATCH(
return Response.json({
ok: true,
data:
'Congratulation you have approved the invoice. Your Invoice no. is INV-' +
'Congratulations you have approved the invoice. Your Invoice no. is INV-' +
response.invoiceNumber +
'. Pay the invoice before due date.',
status: 200
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/app/api/invoice/[id]/og/route.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { db } from '@/lib/db'
import { ImageResponse } from '@vercel/og'
import { formatAmountWithRs, formatDate, numTowords } from 'helper/format'
import { formatAmountWithRs, formatDate, numToWords } from 'helper/format'
// export const runtime = 'edge'

export async function GET(
Expand Down Expand Up @@ -184,7 +184,7 @@ export async function GET(
<div tw='mt-4 w-full flex justify-center mt-2'>
<p tw='text-[#718096] text-xs px-4 w-full'>
Total Amount (in words) :
{numTowords.convert(invoice?.totalAmount || 0, {
{numToWords.convert(invoice?.totalAmount || 0, {
currency: true
})}
</p>
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/app/api/invoice/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export async function PATCH(
)
return Response.json({
ok: false,
data: 'Invalid data, please check data',
data: 'Invalid data, please check the data you are sending.',
status: 409
})
}
Expand Down Expand Up @@ -143,8 +143,8 @@ export async function PATCH(
title: 'Invoice Approval Status Change',
description:
approvalStatus === 'APPROVED'
? 'You approved the invoice.'
: 'You reject the invoice.',
? 'You have approved the invoice.'
: 'You have rejected the invoice.',
oldStatus: 'UNAPPROVED',
newStatus: approvalStatus
}
Expand All @@ -160,7 +160,7 @@ export async function PATCH(
invoiceId: invoiceId,
actionType: 'APPROVAL_ACTION',
title: 'Invoice Approval Status Change',
description: 'You approved the invoice.',
description: 'You have approved the invoice.',
oldStatus: 'REJECTED',
newStatus: 'APPROVED'
}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/app/api/invoice/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export async function POST(request: Request) {
auditTrailEntries: {
create: {
actionType: 'MANUAL_CREATION',
title: 'Invoice Manually Created',
description: 'You manually created a new invoice.',
title: 'Invoice Created Manually',
description: 'You have manually created a new invoice.',
oldStatus: 'N/A',
newStatus: 'CREATED'
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/magiclinks/invoice/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import jwt from 'jsonwebtoken'
export const dynamic = 'force-dynamic'
export async function GET(request: Request) {
try {
const secret = process.env.INVOICE_APPROVAL_SECRET_KEY || ''
const secret = process.env.INVOICE_APPROVAL_SECRET_KEY ?? ''

const { searchParams } = new URL(request.url)
const token = searchParams.get('token')
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/organization/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export async function POST(request: Request) {
return Response.json({
ok: true,
data: { orgName: orgResponse.orgName, state: orgResponse.state },
staus: 200
status: 200
})
} catch (error) {
console.error('Error:', error)
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/app/manual/invoice/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ const createInvoice = () => {
<div className='w-full text-center'>
<h1 className='text-2xl font-semibold'>New Invoice</h1>
<p className='text-xs font-medium mt-2'>
Fill in the fields, preview invoice and send it emailed or
whatsapp directly to client.
Complete the fields, preview the invoice, and then send it
directly to the client via email or WhatsApp.
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/helpers/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const formatDate = (inputDate: Date | undefined) => {
return formattedDate
}

export const numTowords = new ToWords({
export const numToWords = new ToWords({
localeCode: 'en-IN',
converterOptions: {
currency: true,
Expand Down