Skip to content

Conversation

@0oM4R
Copy link
Contributor

@0oM4R 0oM4R commented Aug 13, 2025

Description

add mail card, admin can send an email with attachments to all system users

Changes

  • in api, i added content type and support for form data body
  • added admin card and added sendSystem email to all

Related Issues

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring

@0oM4R 0oM4R marked this pull request as ready for review August 13, 2025 11:57
@0oM4R 0oM4R requested a review from zaelgohary August 13, 2025 11:57
@zaelgohary
Copy link
Contributor

Subject should not ba part of the mail body.

image

Comment on lines +61 to +74
const attachmentRules = [
(files: File[]) => {
if (!files || files.length === 0) return true
const maxSize = 10 * 1024 * 1024 // 10MB
const oversized = files.find(file => file.size > maxSize)
if (oversized) return `File "${oversized.name}" is too large. Maximum size is 10MB.`
return true
},
(files: File[]) => {
if (!files || files.length === 0) return true
if (files.length > 5) return 'Maximum 5 files allowed'
return true
}
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attachment rules allow multi attachment files but this is not supported from UI. Only one attachement is enabled per mail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image It is supported

method,
headers: requestHeaders,
body: body ? JSON.stringify(body) : undefined,
body: body instanceof FormData ? body : (body ? JSON.stringify(body) : undefined),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body: body instanceof FormData ? body : (body ? JSON.stringify(body) : undefined),
body: body instanceof FormData ? body : JSON.stringify(body),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body is optional, this was for handling that to avoid passing an undefined body to stringify

method,
headers: requestHeaders,
body: body ? JSON.stringify(body) : undefined,
body: body instanceof FormData ? body : (body ? JSON.stringify(body) : undefined),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body: body instanceof FormData ? body : (body ? JSON.stringify(body) : undefined),
body: body instanceof FormData ? body : JSON.stringify(body),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body is optional; this was for handling that to avoid passing an undefined body to stringify

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extracted this to another variable to be reusable but the logic still the same

      const bodyData = body instanceof FormData ? body : (body ? JSON.stringify(body) : undefined)

</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused computed prop

const message = ref('')
const attachments = ref<File[]>([])
const sending = ref(false)
const result = ref<{ success: boolean; message: string } | null>(null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const result = ref<{ success: boolean; message: string } | null>(null)

Only used in catch and not needed. you can use console.error instead.

@zaelgohary
Copy link
Contributor

Please remove all unnecessary new lines.

@0oM4R
Copy link
Contributor Author

0oM4R commented Aug 14, 2025

image

result email
image

@0oM4R 0oM4R requested a review from zaelgohary August 14, 2025 11:18
@xmonader xmonader merged commit 8655c2b into master Aug 14, 2025
2 checks passed
@xmonader xmonader deleted the master_users_email branch August 14, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants