Compare commits
12 Commits
ajuste-nas
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c633f57fd | |||
| 17a69ed57b | |||
| 94c0dd13dc | |||
| 7a9f2b3da2 | |||
| cfd4790bf1 | |||
| eff11fc075 | |||
| 6f3a49575c | |||
| 07ed113291 | |||
| 0de772457e | |||
| c736f44604 | |||
| 3b8e73535b | |||
| e5f260e7c3 |
96
package-lock.json
generated
96
package-lock.json
generated
@ -19,6 +19,7 @@
|
|||||||
"@fullcalendar/react": "^6.1.19",
|
"@fullcalendar/react": "^6.1.19",
|
||||||
"@fullcalendar/timegrid": "^6.1.19",
|
"@fullcalendar/timegrid": "^6.1.19",
|
||||||
"@jitsi/react-sdk": "^1.4.0",
|
"@jitsi/react-sdk": "^1.4.0",
|
||||||
|
"@supabase/supabase-js": "^2.86.0",
|
||||||
"@sweetalert2/theme-dark": "^5.0.27",
|
"@sweetalert2/theme-dark": "^5.0.27",
|
||||||
"@testing-library/dom": "^10.4.1",
|
"@testing-library/dom": "^10.4.1",
|
||||||
"@testing-library/jest-dom": "^6.8.0",
|
"@testing-library/jest-dom": "^6.8.0",
|
||||||
@ -18260,6 +18261,86 @@
|
|||||||
"integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==",
|
"integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@supabase/auth-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-3xPqMvBWC6Haqpr6hEWmSUqDq+6SA1BAEdbiaHdAZM9QjZ5uiQJ+6iD9pZOzOa6MVXZh4GmwjhC9ObIG0K1NcA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "2.8.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@supabase/functions-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-AlOoVfeaq9XGlBFIyXTmb+y+CZzxNO4wWbfgRM6iPpNU5WCXKawtQYSnhivi3UVxS7GA0rWovY4d6cIAxZAojA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "2.8.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@supabase/postgrest-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-QVf+wIXILcZJ7IhWhWn+ozdf8B+oO0Ulizh2AAPxD/6nQL+x3r9lJ47a+fpc/jvAOGXMbkeW534Kw6jz7e8iIA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "2.8.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@supabase/realtime-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-dyS8bFoP29R/sj5zLi0AP3JfgG8ar1nuImcz5jxSx7UIW7fbFsXhUCVrSY2Ofo0+Ev6wiATiSdBOzBfWaiFyPA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/phoenix": "^1.6.6",
|
||||||
|
"@types/ws": "^8.18.1",
|
||||||
|
"tslib": "2.8.1",
|
||||||
|
"ws": "^8.18.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@supabase/storage-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-PM47jX/Mfobdtx7NNpoj9EvlrkapAVTQBZgGGslEXD6NS70EcGjhgRPBItwHdxZPM5GwqQ0cGMN06uhjeY2mHQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"iceberg-js": "^0.8.0",
|
||||||
|
"tslib": "2.8.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@supabase/supabase-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-BaC9sv5+HGNy1ulZwY8/Ev7EjfYYmWD4fOMw9bDBqTawEj6JHAiOHeTwXLRzVaeSay4p17xYLN2NSCoGgXMQnw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@supabase/auth-js": "2.86.0",
|
||||||
|
"@supabase/functions-js": "2.86.0",
|
||||||
|
"@supabase/postgrest-js": "2.86.0",
|
||||||
|
"@supabase/realtime-js": "2.86.0",
|
||||||
|
"@supabase/storage-js": "2.86.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@surma/rollup-plugin-off-main-thread": {
|
"node_modules/@surma/rollup-plugin-off-main-thread": {
|
||||||
"version": "2.2.3",
|
"version": "2.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz",
|
||||||
@ -19505,6 +19586,12 @@
|
|||||||
"integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==",
|
"integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/phoenix": {
|
||||||
|
"version": "1.6.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.6.6.tgz",
|
||||||
|
"integrity": "sha512-PIzZZlEppgrpoT2QgbnDU+MMzuR6BbCjllj0bM70lWoejMeNJAxCchxnv7J3XFkI8MpygtRpzXrIlmWUBclP5A==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/prettier": {
|
"node_modules/@types/prettier": {
|
||||||
"version": "2.7.3",
|
"version": "2.7.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz",
|
||||||
@ -26324,6 +26411,15 @@
|
|||||||
"node": ">=10.17.0"
|
"node": ">=10.17.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/iceberg-js": {
|
||||||
|
"version": "0.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/iceberg-js/-/iceberg-js-0.8.0.tgz",
|
||||||
|
"integrity": "sha512-kmgmea2nguZEvRqW79gDqNXyxA3OS5WIgMVffrHpqXV4F/J4UmNIw2vstixioLTNSkd5rFB8G0s3Lwzogm6OFw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/iconv-lite": {
|
"node_modules/iconv-lite": {
|
||||||
"version": "0.6.3",
|
"version": "0.6.3",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
"@fullcalendar/react": "^6.1.19",
|
"@fullcalendar/react": "^6.1.19",
|
||||||
"@fullcalendar/timegrid": "^6.1.19",
|
"@fullcalendar/timegrid": "^6.1.19",
|
||||||
"@jitsi/react-sdk": "^1.4.0",
|
"@jitsi/react-sdk": "^1.4.0",
|
||||||
|
"@supabase/supabase-js": "^2.86.0",
|
||||||
"@sweetalert2/theme-dark": "^5.0.27",
|
"@sweetalert2/theme-dark": "^5.0.27",
|
||||||
"@testing-library/dom": "^10.4.1",
|
"@testing-library/dom": "^10.4.1",
|
||||||
"@testing-library/jest-dom": "^6.8.0",
|
"@testing-library/jest-dom": "^6.8.0",
|
||||||
|
|||||||
@ -1,26 +1,3 @@
|
|||||||
:root {
|
|
||||||
--primary-blue: #1e3a8a;
|
|
||||||
--light-blue: #E6F2FF;
|
|
||||||
--medium-blue: #D1E7FF;
|
|
||||||
--border-blue: #B8D4F0;
|
|
||||||
--warning-light: #FFF3CD;
|
|
||||||
--warning-dark: #856404;
|
|
||||||
--warning-border: #FFEAA7;
|
|
||||||
--danger-light: #F8D7DA;
|
|
||||||
--danger-dark: #721C24;
|
|
||||||
--danger-border: #F5C6CB;
|
|
||||||
--bg-light: #f8f9fa;
|
|
||||||
--border-light: #dee2e6;
|
|
||||||
--text-muted: #6c757d;
|
|
||||||
--text-dark: #495057;
|
|
||||||
--spacing-xs: 0.25rem;
|
|
||||||
--spacing-sm: 0.5rem;
|
|
||||||
--spacing-md: 1rem;
|
|
||||||
--spacing-lg: 1.5rem;
|
|
||||||
--border-radius: 0.375rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== ESTILOS EXISTENTES DO DASHBOARD ===== */
|
|
||||||
.dashboard-container {
|
.dashboard-container {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
font-family: 'Arial', sans-serif;
|
font-family: 'Arial', sans-serif;
|
||||||
@ -67,6 +44,68 @@
|
|||||||
box-shadow: 0 4px 12px rgba(30, 58, 138, 0.4);
|
box-shadow: 0 4px 12px rgba(30, 58, 138, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filters-container {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 1.2rem;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filters-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 0.3rem;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filters-subtitle {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filters-content {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.8rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filters-input {
|
||||||
|
flex: 1;
|
||||||
|
padding: 0.5rem 0.8rem;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: #333;
|
||||||
|
min-width: 200px;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filters-input:focus {
|
||||||
|
border-color: #1e3a8a;
|
||||||
|
box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.1);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filters-select {
|
||||||
|
padding: 0.5rem 0.8rem;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
background: #fff;
|
||||||
|
color: #333;
|
||||||
|
cursor: pointer;
|
||||||
|
min-width: 140px;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filters-select:focus {
|
||||||
|
border-color: #1e3a8a;
|
||||||
|
box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.1);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
.cards-container {
|
.cards-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
@ -117,396 +156,283 @@
|
|||||||
.user-table-container {
|
.user-table-container {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
padding: 1.5rem;
|
padding: 1.2rem;
|
||||||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||||||
margin-top: 1rem;
|
margin-top: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== ESTILOS DA TABELA AVANÇADA ===== */
|
.user-table-container h2 {
|
||||||
.table-paciente-filters {
|
font-size: 18px;
|
||||||
background-color: var(--bg-light);
|
font-weight: bold;
|
||||||
border: 1px solid var(--border-light);
|
margin-bottom: 0.3rem;
|
||||||
border-radius: var(--border-radius);
|
color: #333;
|
||||||
padding: var(--spacing-md);
|
|
||||||
margin-bottom: var(--spacing-md);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-paciente-filters h5 {
|
.user-table-container p {
|
||||||
color: var(--text-dark);
|
font-size: 0.9rem;
|
||||||
font-weight: 600;
|
color: #666;
|
||||||
font-size: 1.1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-paciente-table {
|
.user-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-paciente-table th {
|
.user-table th,
|
||||||
background-color: var(--bg-light);
|
.user-table td {
|
||||||
color: var(--text-dark);
|
padding: 10px 12px;
|
||||||
|
text-align: left;
|
||||||
|
border-bottom: 1px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-table th {
|
||||||
|
background-color: #f3f4f6;
|
||||||
|
color: #333;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
padding: 12px 8px;
|
|
||||||
border-bottom: 2px solid var(--border-light);
|
|
||||||
vertical-align: middle;
|
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-paciente-table td {
|
.user-table tr {
|
||||||
padding: 12px 8px;
|
transition: background-color 0.2s ease;
|
||||||
vertical-align: middle;
|
|
||||||
border-bottom: 1px solid var(--border-light);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-paciente-table tbody tr:hover {
|
.user-table tr:hover {
|
||||||
background-color: rgba(0, 0, 0, 0.025);
|
background-color: #f0f4ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.insurance-badge {
|
.profile-badge {
|
||||||
background-color: transparent !important;
|
background-color: #1e3a8a;
|
||||||
color: var(--text-dark) !important;
|
color: white;
|
||||||
padding: 0.35em 0.65em;
|
padding: 4px 10px;
|
||||||
font-size: 0.75em;
|
border-radius: 6px;
|
||||||
|
font-size: 0.8rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border: 1px solid var(--border-light);
|
display: inline-block;
|
||||||
border-radius: var(--border-radius);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-badge {
|
.status-badge {
|
||||||
padding: 0.35em 0.65em;
|
padding: 4px 10px;
|
||||||
font-size: 0.75em;
|
border-radius: 6px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #fff;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-radius: var(--border-radius);
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-badge.ativo {
|
.status-badge.ativo {
|
||||||
background-color: var(--primary-blue);
|
background-color: #1e3a8a;
|
||||||
color: white;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-badge.inativo {
|
.status-badge.inativo {
|
||||||
background-color: var(--text-muted);
|
background-color: #6c757d;
|
||||||
color: white;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.anniversary-badge {
|
.actions {
|
||||||
background-color: #ffc107;
|
display: flex;
|
||||||
color: #000;
|
gap: 8px;
|
||||||
padding: 0.35em 0.65em;
|
flex-wrap: wrap;
|
||||||
font-size: 0.75em;
|
|
||||||
border-radius: 50%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-view {
|
.action-btn {
|
||||||
background-color: var(--light-blue) !important;
|
border: none;
|
||||||
color: #004085 !important;
|
padding: 6px 12px;
|
||||||
border: 1px solid var(--border-blue);
|
|
||||||
padding: 0.375rem 0.75rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
transition: all 0.15s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-view:hover {
|
|
||||||
background-color: var(--medium-blue) !important;
|
|
||||||
border-color: #9EC5FE;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-edit {
|
|
||||||
background-color: var(--warning-light) !important;
|
|
||||||
color: var(--warning-dark) !important;
|
|
||||||
border: 1px solid var(--warning-border);
|
|
||||||
padding: 0.375rem 0.75rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
transition: all 0.15s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-edit:hover {
|
|
||||||
background-color: #FFEEBA !important;
|
|
||||||
border-color: #FFE087;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-delete {
|
|
||||||
background-color: var(--danger-light) !important;
|
|
||||||
color: var(--danger-dark) !important;
|
|
||||||
border: 1px solid var(--danger-border);
|
|
||||||
padding: 0.375rem 0.75rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
transition: all 0.15s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-delete:hover {
|
|
||||||
background-color: #F1B0B7 !important;
|
|
||||||
border-color: #ED969E;
|
|
||||||
}
|
|
||||||
|
|
||||||
.advanced-filters {
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.advanced-filters h6 {
|
|
||||||
color: var(--text-dark);
|
|
||||||
font-size: 0.9rem;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-label.fw-bold {
|
|
||||||
color: var(--text-dark);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.delete-modal .modal-header {
|
|
||||||
background-color: rgba(220, 53, 69, 0.1);
|
|
||||||
border-bottom: 1px solid rgba(220, 53, 69, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.delete-modal .modal-title {
|
|
||||||
color: #dc3545;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.contador-pacientes {
|
|
||||||
background-color: var(--primary-blue);
|
|
||||||
color: white;
|
|
||||||
padding: 0.5em 0.75em;
|
|
||||||
font-size: 0.875em;
|
|
||||||
font-weight: 500;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
text-align: center;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Paginação */
|
|
||||||
.pagination {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-link {
|
|
||||||
color: var(--text-dark);
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
padding: 0.375rem 0.75rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-link:hover {
|
|
||||||
color: var(--primary-blue);
|
|
||||||
background-color: #e9ecef;
|
|
||||||
border-color: var(--border-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-item.active .page-link {
|
|
||||||
background-color: var(--primary-blue);
|
|
||||||
border-color: var(--primary-blue);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-item.disabled .page-link {
|
|
||||||
color: var(--text-muted);
|
|
||||||
background-color: var(--bg-light);
|
|
||||||
border-color: var(--border-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== AJUSTES ESPECÍFICOS PARA OS FILTROS ===== */
|
|
||||||
.table-paciente-filters .form-select-sm {
|
|
||||||
font-size: 0.825rem;
|
|
||||||
padding: 0.35rem 0.5rem;
|
|
||||||
border-radius: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .form-label.small {
|
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #6c757d;
|
cursor: pointer;
|
||||||
min-width: auto;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Alinhamento dos grupos de filtro */
|
|
||||||
.table-paciente-filters .d-flex.align-items-center.gap-2 {
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ajuste do contador */
|
|
||||||
.contador-pacientes {
|
|
||||||
background-color: #1e3a8a;
|
|
||||||
color: white;
|
|
||||||
padding: 0.4rem 0.8rem;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
font-weight: 600;
|
|
||||||
border-radius: 0.375rem;
|
|
||||||
text-align: center;
|
|
||||||
display: inline-block;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Botão de filtros avançados */
|
|
||||||
.btn-link {
|
|
||||||
color: #1e3a8a !important;
|
|
||||||
font-weight: 500;
|
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
|
border-radius: 4px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-link:hover {
|
.action-btn.detalhes {
|
||||||
color: #162d6b !important;
|
background-color: #e6f2ff;
|
||||||
|
color: #004085;
|
||||||
|
border: 1px solid #b8d4ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-btn.detalhes:hover {
|
||||||
|
background-color: #cce4ff;
|
||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ajustes responsivos para mobile */
|
.action-btn.editar {
|
||||||
@media (max-width: 768px) {
|
background-color: #fff3cd;
|
||||||
.dashboard-container {
|
color: #856405;
|
||||||
padding: 1rem;
|
border: 1px solid #ffeaa7;
|
||||||
}
|
|
||||||
|
|
||||||
.dashboard-header {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1rem;
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .d-flex.flex-wrap.align-items-center.gap-3 {
|
|
||||||
gap: 1rem !important;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .d-flex.align-items-center.gap-2 {
|
|
||||||
width: 100%;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .form-select-sm.compact-select {
|
|
||||||
min-width: 100% !important;
|
|
||||||
margin-top: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vr.d-none.d-md-block {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-table {
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-table th,
|
|
||||||
.table-paciente-table td {
|
|
||||||
padding: 10px 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-view,
|
|
||||||
.btn-edit,
|
|
||||||
.btn-delete {
|
|
||||||
padding: 0.25rem 0.5rem;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .d-flex {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .form-select {
|
|
||||||
min-width: 100% !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.patient-name-container {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start !important;
|
|
||||||
gap: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.d-flex.justify-content-between.align-items-center {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1rem;
|
|
||||||
align-items: stretch !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-table thead th:nth-child(6),
|
|
||||||
.table-paciente-table tbody td:nth-child(6) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Estilo para os selects quando estão ativos */
|
.action-btn.editar:hover {
|
||||||
.form-select-sm:focus {
|
background-color: #ffeaa7;
|
||||||
border-color: #1e3a8a;
|
transform: translateY(-1px);
|
||||||
box-shadow: 0 0 0 0.2rem rgba(30, 58, 138, 0.25);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ajuste do botão limpar filtros */
|
.action-btn.excluir {
|
||||||
.btn-outline-secondary.btn-sm {
|
background-color: #f8d7da;
|
||||||
border-color: #6c757d;
|
color: #721c24;
|
||||||
color: #6c757d;
|
border: 1px solid #f1b0b7;
|
||||||
font-size: 0.8rem;
|
|
||||||
padding: 0.35rem 0.75rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-outline-secondary.btn-sm:hover {
|
.action-btn.excluir:hover {
|
||||||
background-color: #6c757d;
|
background-color: #f1b0b7;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.save-btn {
|
||||||
|
background-color: #1e3a8a;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
border: none;
|
||||||
|
padding: 8px 16px;
|
||||||
/* Melhoria na aparência dos filtros avançados */
|
border-radius: 6px;
|
||||||
.advanced-filters {
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
border: 1px solid #dee2e6 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.advanced-filters .form-control-sm {
|
|
||||||
font-size: 0.825rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.advanced-filters h6 {
|
|
||||||
color: #495057;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.compact-select {
|
.save-btn:hover {
|
||||||
font-size: 0.9rem;
|
background-color: #162d6b;
|
||||||
padding: 0.45rem 0.5rem;
|
transform: translateY(-1px);
|
||||||
min-width: 150px;
|
box-shadow: 0 4px 8px rgba(30, 58, 138, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Badge de Perfil */
|
.edit-btn {
|
||||||
.badge-medico {
|
background-color: #fff3cd;
|
||||||
|
color: #856405;
|
||||||
|
border: 1px solid #ffeaa7;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-btn:hover {
|
||||||
|
background-color: #ffeaa7;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .dashboard-container {
|
||||||
|
background-color: #121212;
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .dashboard-header,
|
||||||
|
html[data-bs-theme="dark"] .dashboard-title,
|
||||||
|
html[data-bs-theme="dark"] .dashboard-subtitle {
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .new-user-btn {
|
||||||
background-color: #1e3a8a;
|
background-color: #1e3a8a;
|
||||||
color: white;
|
|
||||||
padding: 0.35rem 0.75rem;
|
|
||||||
border-radius: 0.375rem;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge-paciente {
|
html[data-bs-theme="dark"] .new-user-btn:hover {
|
||||||
|
background-color: #162d6b;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .filters-container,
|
||||||
|
html[data-bs-theme="dark"] .user-table-container {
|
||||||
|
background: #1a1a1a;
|
||||||
|
box-shadow: 0 2px 8px rgba(0,0,0,0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .filters-title,
|
||||||
|
html[data-bs-theme="dark"] .user-table-container h2 {
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .filters-subtitle,
|
||||||
|
html[data-bs-theme="dark"] .user-table-container p {
|
||||||
|
color: #bdbdbd;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .filters-input,
|
||||||
|
html[data-bs-theme="dark"] .filters-select {
|
||||||
|
background: #232323;
|
||||||
|
color: #e0e0e0;
|
||||||
|
border-color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .filters-input:focus,
|
||||||
|
html[data-bs-theme="dark"] .filters-select:focus {
|
||||||
|
border-color: #1e3a8a;
|
||||||
|
box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .cards-container .card {
|
||||||
|
background-color: #181818;
|
||||||
|
color: #e0e0e0;
|
||||||
|
box-shadow: 0 2px 6px rgba(0,0,0,0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .highlight:hover {
|
||||||
|
background: #1a1f2e;
|
||||||
|
border: 1px solid #1e3a8a33;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .card-label {
|
||||||
|
color: #888;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .card-value {
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .card-extra {
|
||||||
|
color: #bdbdbd;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .card-extra.positive {
|
||||||
|
color: #1e3a8a;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .user-table th {
|
||||||
|
background-color: #232323;
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .user-table td {
|
||||||
|
color: #e0e0e0;
|
||||||
|
border-bottom: 1px solid #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .user-table tr:hover {
|
||||||
|
background-color: #1a1f2e;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .profile-badge {
|
||||||
background-color: #1e3a8a;
|
background-color: #1e3a8a;
|
||||||
color: white;
|
|
||||||
padding: 0.35rem 0.75rem;
|
|
||||||
border-radius: 0.375rem;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 576px) {
|
html[data-bs-theme="dark"] .action-btn.detalhes {
|
||||||
.cards-container {
|
background-color: #e6f2ff;
|
||||||
grid-template-columns: 1fr;
|
color: #004085;
|
||||||
}
|
border: 1px solid #b8d4ff;
|
||||||
|
}
|
||||||
.table-paciente-table thead th:nth-child(3),
|
|
||||||
.table-paciente-table thead th:nth-child(4),
|
html[data-bs-theme="dark"] .action-btn.detalhes:hover {
|
||||||
.table-paciente-table tbody td:nth-child(3),
|
background-color: #cce4ff;
|
||||||
.table-paciente-table tbody td:nth-child(4) {
|
}
|
||||||
display: none;
|
|
||||||
}
|
html[data-bs-theme="dark"] .action-btn.editar {
|
||||||
|
background-color: #fff3cd;
|
||||||
.user-table-container {
|
color: #856405;
|
||||||
padding: 1rem;
|
border: 1px solid #ffeaa7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .action-btn.editar:hover {
|
||||||
|
background-color: #ffeaa7;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .action-btn.excluir {
|
||||||
|
background-color: #f8d7da;
|
||||||
|
color: #721c24;
|
||||||
|
border: 1px solid #f1b0b7;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-bs-theme="dark"] .action-btn.excluir:hover {
|
||||||
|
background-color: #f1b0b7;
|
||||||
}
|
}
|
||||||
@ -1,186 +1,9 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React from "react";
|
||||||
import "./gestao.css";
|
import "./gestao.css";
|
||||||
import { GetAllDoctors } from "../components/utils/Functions-Endpoints/Doctor";
|
|
||||||
import { GetAllPatients } from "../components/utils/Functions-Endpoints/Patient";
|
|
||||||
import API_KEY from "../components/utils/apiKeys";
|
|
||||||
|
|
||||||
function UserDashboard() {
|
function UserDashboard() {
|
||||||
// Estados principais
|
|
||||||
const [usuarios, setUsuarios] = useState([]);
|
|
||||||
const [busca, setBusca] = useState("");
|
|
||||||
const [filtroPerfil, setFiltroPerfil] = useState("Todos");
|
|
||||||
const [filtroStatus, setFiltroStatus] = useState("Todos");
|
|
||||||
const [filtroDepartamento, setFiltroDepartamento] = useState("Todos");
|
|
||||||
const [showFiltrosAvancados, setShowFiltrosAvancados] = useState(false);
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
|
|
||||||
// Estados de paginação
|
|
||||||
const [paginaAtual, setPaginaAtual] = useState(1);
|
|
||||||
const [itensPorPagina, setItensPorPagina] = useState(10);
|
|
||||||
|
|
||||||
// Estados de ordenação
|
|
||||||
const [sortKey, setSortKey] = useState(null);
|
|
||||||
const [sortDir, setSortDir] = useState('asc');
|
|
||||||
|
|
||||||
// Estados para modais
|
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
||||||
const [selectedUserId, setSelectedUserId] = useState(null);
|
|
||||||
|
|
||||||
// Buscar dados reais da API
|
|
||||||
useEffect(() => {
|
|
||||||
const fetchUsuarios = async () => {
|
|
||||||
try {
|
|
||||||
setLoading(true);
|
|
||||||
const access_token = localStorage.getItem("access_token");
|
|
||||||
const authHeader = access_token ? `Bearer ${access_token}` : null;
|
|
||||||
|
|
||||||
// Buscar médicos e pacientes em paralelo
|
|
||||||
const [medicos, pacientes] = await Promise.all([
|
|
||||||
GetAllDoctors(authHeader),
|
|
||||||
GetAllPatients(authHeader)
|
|
||||||
]);
|
|
||||||
|
|
||||||
console.log("Médicos:", medicos);
|
|
||||||
console.log("Pacientes:", pacientes);
|
|
||||||
|
|
||||||
// Transformar médicos
|
|
||||||
const usuariosMedicos = medicos.map(medico => ({
|
|
||||||
id: `doctor-${medico.id}`,
|
|
||||||
nome: medico.full_name || "Nome não informado",
|
|
||||||
email: medico.email || "Email não informado",
|
|
||||||
perfil: "Médico",
|
|
||||||
departamento: medico.specialization || "Não informado",
|
|
||||||
status: "ativo",
|
|
||||||
ultimoAcesso: medico.updated_at || medico.created_at || new Date().toISOString(),
|
|
||||||
dataCadastro: medico.created_at || new Date().toISOString(),
|
|
||||||
telefone: medico.phone || "Não informado",
|
|
||||||
crm: medico.crm
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Transformar pacientes
|
|
||||||
const usuariosPacientes = pacientes.map(paciente => ({
|
|
||||||
id: `patient-${paciente.id}`,
|
|
||||||
nome: paciente.full_name || "Nome não informado",
|
|
||||||
email: paciente.email || "Email não informado",
|
|
||||||
perfil: "Paciente",
|
|
||||||
departamento: "Pacientes",
|
|
||||||
status: "ativo",
|
|
||||||
ultimoAcesso: paciente.updated_at || paciente.created_at || new Date().toISOString(),
|
|
||||||
dataCadastro: paciente.created_at || new Date().toISOString(),
|
|
||||||
telefone: paciente.phone || "Não informado",
|
|
||||||
cpf: paciente.cpf
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Combinar todos os usuários
|
|
||||||
const todosUsuarios = [...usuariosMedicos, ...usuariosPacientes];
|
|
||||||
setUsuarios(todosUsuarios);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Erro ao buscar usuários:", error);
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchUsuarios();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Funções auxiliares
|
|
||||||
const formatarData = (dataString) => {
|
|
||||||
const data = new Date(dataString);
|
|
||||||
return data.toLocaleDateString('pt-BR', {
|
|
||||||
day: '2-digit',
|
|
||||||
month: '2-digit',
|
|
||||||
year: 'numeric',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const calcularDiasDesdeUltimoAcesso = (dataString) => {
|
|
||||||
const ultimoAcesso = new Date(dataString);
|
|
||||||
const hoje = new Date();
|
|
||||||
const diffTime = Math.abs(hoje - ultimoAcesso);
|
|
||||||
return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
||||||
};
|
|
||||||
|
|
||||||
// Filtragem
|
|
||||||
const usuariosFiltrados = usuarios.filter(usuario => {
|
|
||||||
const passaBusca = busca === "" ||
|
|
||||||
usuario.nome.toLowerCase().includes(busca.toLowerCase()) ||
|
|
||||||
usuario.email.toLowerCase().includes(busca.toLowerCase());
|
|
||||||
|
|
||||||
const passaPerfil = filtroPerfil === "Todos" || usuario.perfil === filtroPerfil;
|
|
||||||
const passaStatus = filtroStatus === "Todos" || usuario.status === filtroStatus;
|
|
||||||
const passaDepartamento = filtroDepartamento === "Todos" || usuario.departamento === filtroDepartamento;
|
|
||||||
|
|
||||||
return passaBusca && passaPerfil && passaStatus && passaDepartamento;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Ordenação
|
|
||||||
const aplicarOrdenacao = (arr) => {
|
|
||||||
if (!sortKey) return arr;
|
|
||||||
|
|
||||||
const copia = [...arr];
|
|
||||||
copia.sort((a, b) => {
|
|
||||||
if (sortKey === 'nome') {
|
|
||||||
return a.nome.localeCompare(b.nome);
|
|
||||||
} else if (sortKey === 'dataCadastro') {
|
|
||||||
return new Date(a.dataCadastro) - new Date(b.dataCadastro);
|
|
||||||
} else if (sortKey === 'ultimoAcesso') {
|
|
||||||
return new Date(a.ultimoAcesso) - new Date(b.ultimoAcesso);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
return sortDir === 'desc' ? copia.reverse() : copia;
|
|
||||||
};
|
|
||||||
|
|
||||||
const usuariosOrdenados = aplicarOrdenacao(usuariosFiltrados);
|
|
||||||
|
|
||||||
// Paginação
|
|
||||||
const totalPaginas = Math.ceil(usuariosFiltrados.length / itensPorPagina);
|
|
||||||
const indiceInicial = (paginaAtual - 1) * itensPorPagina;
|
|
||||||
const indiceFinal = indiceInicial + itensPorPagina;
|
|
||||||
const usuariosPaginados = usuariosOrdenados.slice(indiceInicial, indiceFinal);
|
|
||||||
|
|
||||||
// Navegação de páginas
|
|
||||||
const irParaPagina = (pagina) => setPaginaAtual(pagina);
|
|
||||||
const avancarPagina = () => paginaAtual < totalPaginas && setPaginaAtual(p => p + 1);
|
|
||||||
const voltarPagina = () => paginaAtual > 1 && setPaginaAtual(p => p - 1);
|
|
||||||
|
|
||||||
const gerarNumerosPaginas = () => {
|
|
||||||
const paginas = [];
|
|
||||||
const paginasParaMostrar = 5;
|
|
||||||
let inicio = Math.max(1, paginaAtual - Math.floor(paginasParaMostrar / 2));
|
|
||||||
let fim = Math.min(totalPaginas, inicio + paginasParaMostrar - 1);
|
|
||||||
inicio = Math.max(1, fim - paginasParaMostrar + 1);
|
|
||||||
|
|
||||||
for (let i = inicio; i <= fim; i++) paginas.push(i);
|
|
||||||
return paginas;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Funções de ação
|
|
||||||
const limparFiltros = () => {
|
|
||||||
setBusca("");
|
|
||||||
setFiltroPerfil("Todos");
|
|
||||||
setFiltroStatus("Todos");
|
|
||||||
setFiltroDepartamento("Todos");
|
|
||||||
setPaginaAtual(1);
|
|
||||||
};
|
|
||||||
|
|
||||||
const excluirUsuario = (id) => {
|
|
||||||
setUsuarios(prev => prev.filter(u => u.id !== id));
|
|
||||||
setShowDeleteModal(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Resetar paginação quando filtros mudarem
|
|
||||||
useEffect(() => {
|
|
||||||
setPaginaAtual(1);
|
|
||||||
}, [busca, filtroPerfil, filtroStatus, filtroDepartamento, sortKey, sortDir]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="dashboard-container">
|
<div className="dashboard-container">
|
||||||
{/* Header */}
|
|
||||||
<div className="dashboard-header">
|
<div className="dashboard-header">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="dashboard-title">Gestão de Usuários</h1>
|
<h1 className="dashboard-title">Gestão de Usuários</h1>
|
||||||
@ -191,363 +14,125 @@ function UserDashboard() {
|
|||||||
<button className="new-user-btn">+ Novo Usuário</button>
|
<button className="new-user-btn">+ Novo Usuário</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Cards de Estatísticas */}
|
|
||||||
<div className="cards-container">
|
<div className="cards-container">
|
||||||
<div className="card highlight">
|
<div className="card highlight">
|
||||||
<p className="card-label">Total de Usuários</p>
|
<p className="card-label">Total de Usuários</p>
|
||||||
<p className="card-value">{loading ? "..." : usuarios.length}</p>
|
<p className="card-value">15</p>
|
||||||
<p className="card-extra positive">Médicos e Pacientes</p>
|
<p className="card-extra positive">+3 este mês</p>
|
||||||
</div>
|
|
||||||
<div className="card highlight">
|
|
||||||
<p className="card-label">Médicos</p>
|
|
||||||
<p className="card-value">{loading ? "..." : usuarios.filter(u => u.perfil === 'Médico').length}</p>
|
|
||||||
<p className="card-extra">Profissionais cadastrados</p>
|
|
||||||
</div>
|
|
||||||
<div className="card highlight">
|
|
||||||
<p className="card-label">Pacientes</p>
|
|
||||||
<p className="card-value">{loading ? "..." : usuarios.filter(u => u.perfil === 'Paciente').length}</p>
|
|
||||||
<p className="card-extra">Pacientes cadastrados</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="card highlight">
|
<div className="card highlight">
|
||||||
<p className="card-label">Usuários Ativos</p>
|
<p className="card-label">Usuários Ativos</p>
|
||||||
<p className="card-value">{loading ? "..." : usuarios.filter(u => u.status === 'ativo').length}</p>
|
<p className="card-value">12</p>
|
||||||
<p className="card-extra">{usuarios.length > 0 ? ((usuarios.filter(u => u.status === 'ativo').length / usuarios.length) * 100).toFixed(1) : 0}% do total</p>
|
<p className="card-extra">80.0% do total</p>
|
||||||
|
</div>
|
||||||
|
<div className="card highlight">
|
||||||
|
<p className="card-label">Tempo Médio Sessão</p>
|
||||||
|
<p className="card-value">2h 30min</p>
|
||||||
|
<p className="card-extra">Última semana</p>
|
||||||
|
</div>
|
||||||
|
<div className="card highlight">
|
||||||
|
<p className="card-label">Usuários Hoje</p>
|
||||||
|
<p className="card-value">10</p>
|
||||||
|
<p className="card-extra positive">+2 desde ontem</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="filters-container">
|
||||||
|
<p className="filters-title">Filtros</p>
|
||||||
|
<p className="filters-subtitle">
|
||||||
|
Use os filtros abaixo para encontrar usuários específicos
|
||||||
|
</p>
|
||||||
|
<div className="filters-content">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="filters-input"
|
||||||
|
placeholder="Buscar por nome ou email..."
|
||||||
|
/>
|
||||||
|
<select className="filters-select">
|
||||||
|
<option>Todos os perfis</option>
|
||||||
|
<option>Médico</option>
|
||||||
|
<option>Secretaria</option>
|
||||||
|
<option>Gestão</option>
|
||||||
|
</select>
|
||||||
|
<select className="filters-select">
|
||||||
|
<option>Todos</option>
|
||||||
|
<option>Ativos</option>
|
||||||
|
<option>Inativos</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Container Principal da Tabela */}
|
|
||||||
<div className="user-table-container">
|
<div className="user-table-container">
|
||||||
|
<h2>Usuários do Sistema</h2>
|
||||||
{/* Filtros Avançados - FORMATADO */}
|
<p>Lista completa de usuários e suas permissões</p>
|
||||||
<div className="table-paciente-filters">
|
<table className="user-table">
|
||||||
<h5 className="mb-3">
|
<thead>
|
||||||
<i className="bi bi-funnel-fill me-2 text-primary"></i> Filtros
|
<tr>
|
||||||
</h5>
|
<th>Nome</th>
|
||||||
|
<th>Email</th>
|
||||||
{/* Busca */}
|
<th>Perfil</th>
|
||||||
<div className="mb-3">
|
<th>Departamento</th>
|
||||||
<input
|
<th>Status</th>
|
||||||
type="text"
|
<th>Último Acesso</th>
|
||||||
className="form-control"
|
<th>Ações</th>
|
||||||
placeholder="Buscar por nome ou email..."
|
</tr>
|
||||||
value={busca}
|
</thead>
|
||||||
onChange={(e) => setBusca(e.target.value)}
|
<tbody>
|
||||||
/>
|
<tr>
|
||||||
</div>
|
<td>Ana Silva</td>
|
||||||
|
<td>ana.silva@mediconnect.com</td>
|
||||||
{/* Linha de Filtros Básicos */}
|
<td><span className="profile-badge">Gestão / Coordenação</span></td>
|
||||||
<div className="d-flex flex-wrap align-items-center gap-3 mb-3">
|
<td>Administração</td>
|
||||||
{/* Perfil */}
|
<td><span className="status-badge ativo">Ativo</span></td>
|
||||||
<div className="d-flex align-items-center gap-2">
|
<td>20/12/2024, 08:30</td>
|
||||||
<label className="form-label mb-0 text-muted small">Perfil:</label>
|
<td className="actions">
|
||||||
<select
|
<button className="action-btn detalhes">Ver Detalhes</button>
|
||||||
className="form-select form-select-sm compact-select"
|
<button className="action-btn editar">Editar</button>
|
||||||
value={filtroPerfil}
|
<button className="action-btn excluir">Excluir</button>
|
||||||
onChange={(e) => setFiltroPerfil(e.target.value)}
|
</td>
|
||||||
style={{ minWidth: "160px" }}
|
</tr>
|
||||||
>
|
<tr>
|
||||||
<option value="Todos">Todos os Perfis</option>
|
<td>Dr. Carlos Santos</td>
|
||||||
<option value="Médico">Médico</option>
|
<td>carlos.santos@mediconnect.com</td>
|
||||||
<option value="Paciente">Paciente</option>
|
<td><span className="profile-badge">Médico</span></td>
|
||||||
</select>
|
<td>Cardiologia</td>
|
||||||
</div>
|
<td><span className="status-badge ativo">Ativo</span></td>
|
||||||
|
<td>19/12/2024, 14:20</td>
|
||||||
{/* Status */}
|
<td className="actions">
|
||||||
<div className="d-flex align-items-center gap-2">
|
<button className="action-btn detalhes">Ver Detalhes</button>
|
||||||
<label className="form-label mb-0 text-muted small">Status:</label>
|
<button className="action-btn editar">Editar</button>
|
||||||
<select
|
<button className="action-btn excluir">Excluir</button>
|
||||||
className="form-select form-select-sm compact-select"
|
</td>
|
||||||
value={filtroStatus}
|
</tr>
|
||||||
onChange={(e) => setFiltroStatus(e.target.value)}
|
<tr>
|
||||||
style={{ minWidth: "140px" }}
|
<td>Maria Oliveira</td>
|
||||||
>
|
<td>maria.oliveira@mediconnect.com</td>
|
||||||
<option value="Todos">Todos os Status</option>
|
<td><span className="profile-badge">Secretária</span></td>
|
||||||
<option value="ativo">Ativos</option>
|
<td>Recepção</td>
|
||||||
<option value="inativo">Inativos</option>
|
<td><span className="status-badge ativo">Ativo</span></td>
|
||||||
</select>
|
<td>20/12/2024, 07:45</td>
|
||||||
</div>
|
<td className="actions">
|
||||||
|
<button className="action-btn detalhes">Ver Detalhes</button>
|
||||||
{/* Departamento */}
|
<button className="action-btn editar">Editar</button>
|
||||||
<div className="d-flex align-items-center gap-2">
|
<button className="action-btn excluir">Excluir</button>
|
||||||
<label className="form-label mb-0 text-muted small">Especialização:</label>
|
</td>
|
||||||
<input
|
</tr>
|
||||||
type="text"
|
<tr>
|
||||||
className="form-control form-control-sm"
|
<td>Dr. João Pereira</td>
|
||||||
placeholder="Filtrar por especialização..."
|
<td>joao.pereira@mediconnect.com</td>
|
||||||
value={filtroDepartamento === 'Todos' ? '' : filtroDepartamento}
|
<td><span className="profile-badge">Médico</span></td>
|
||||||
onChange={(e) => setFiltroDepartamento(e.target.value || 'Todos')}
|
<td>Ortopedia</td>
|
||||||
style={{ minWidth: "180px" }}
|
<td><span className="status-badge inativo">Inativo</span></td>
|
||||||
/>
|
<td>15/12/2024, 16:30</td>
|
||||||
</div>
|
<td className="actions">
|
||||||
|
<button className="action-btn detalhes">Ver Detalhes</button>
|
||||||
{/* Separador */}
|
<button className="action-btn editar">Editar</button>
|
||||||
<div className="vr d-none d-md-block" style={{ height: "30px" }} />
|
<button className="action-btn excluir">Excluir</button>
|
||||||
|
</td>
|
||||||
{/* Ordenação */}
|
</tr>
|
||||||
<div className="d-flex align-items-center gap-2">
|
</tbody>
|
||||||
<label className="form-label mb-0 text-muted small">Ordenar por:</label>
|
</table>
|
||||||
<select
|
|
||||||
className="form-select form-select-sm compact-select sort-select"
|
|
||||||
value={sortKey ? `${sortKey}-${sortDir}` : ''}
|
|
||||||
onChange={(e) => {
|
|
||||||
const v = e.target.value;
|
|
||||||
if (!v) { setSortKey(null); setSortDir('asc'); return; }
|
|
||||||
const [k, d] = v.split('-');
|
|
||||||
setSortKey(k);
|
|
||||||
setSortDir(d);
|
|
||||||
}}
|
|
||||||
style={{ minWidth: "160px" }}
|
|
||||||
>
|
|
||||||
<option value="">Sem ordenação</option>
|
|
||||||
<option value="nome-asc">Nome (A-Z)</option>
|
|
||||||
<option value="nome-desc">Nome (Z-A)</option>
|
|
||||||
<option value="dataCadastro-asc">Data Cadastro (mais antigo)</option>
|
|
||||||
<option value="dataCadastro-desc">Data Cadastro (mais recente)</option>
|
|
||||||
<option value="ultimoAcesso-asc">Último Acesso (mais antigo)</option>
|
|
||||||
<option value="ultimoAcesso-desc">Último Acesso (mais recente)</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Linha de Ações */}
|
|
||||||
<div className="d-flex justify-content-between align-items-center">
|
|
||||||
<button
|
|
||||||
className="btn btn-link p-0 text-decoration-none d-flex align-items-center"
|
|
||||||
onClick={() => setShowFiltrosAvancados(!showFiltrosAvancados)}
|
|
||||||
style={{ fontSize: "0.9rem" }}
|
|
||||||
>
|
|
||||||
<i className={`bi bi-chevron-${showFiltrosAvancados ? 'up' : 'down'} me-1`}></i>
|
|
||||||
Filtros Avançados
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
className="btn btn-outline-secondary btn-sm d-flex align-items-center"
|
|
||||||
onClick={limparFiltros}
|
|
||||||
>
|
|
||||||
<i className="bi bi-arrow-clockwise me-1"></i> Limpar Filtros
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Filtros Avançados (Ocultos por padrão) */}
|
|
||||||
{showFiltrosAvancados && (
|
|
||||||
<div className="mt-3 p-3 border rounded advanced-filters">
|
|
||||||
<h6 className="mb-3">Filtros Avançados</h6>
|
|
||||||
<div className="row g-3">
|
|
||||||
<div className="col-md-6">
|
|
||||||
<label className="form-label fw-bold">Departamento</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
placeholder="Digite o departamento..."
|
|
||||||
value={filtroDepartamento === 'Todos' ? '' : filtroDepartamento}
|
|
||||||
onChange={(e) => setFiltroDepartamento(e.target.value || 'Todos')}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="col-md-6">
|
|
||||||
<label className="form-label fw-bold">Perfil</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
placeholder="Digite o perfil..."
|
|
||||||
value={filtroPerfil === 'Todos' ? '' : filtroPerfil}
|
|
||||||
onChange={(e) => setFiltroPerfil(e.target.value || 'Todos')}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Contador */}
|
|
||||||
<div className="mt-3">
|
|
||||||
<div className="contador-pacientes">
|
|
||||||
{usuariosFiltrados.length} DE {usuarios.length} USUÁRIOS ENCONTRADOS
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Tabela de Usuários */}
|
|
||||||
<div className="table-responsive mt-4">
|
|
||||||
{loading ? (
|
|
||||||
<div className="text-center py-5">
|
|
||||||
<div className="spinner-border text-primary" role="status">
|
|
||||||
<span className="visually-hidden">Carregando...</span>
|
|
||||||
</div>
|
|
||||||
<p className="mt-3 text-muted">Carregando usuários...</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<table className="table table-striped table-hover table-paciente-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Nome</th>
|
|
||||||
<th>Email</th>
|
|
||||||
<th>Perfil</th>
|
|
||||||
<th>Especialização/Categoria</th>
|
|
||||||
<th>Ações</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{usuariosPaginados.length > 0 ? (
|
|
||||||
usuariosPaginados.map((usuario) => (
|
|
||||||
<tr key={usuario.id}>
|
|
||||||
<td>
|
|
||||||
<div className="d-flex align-items-center patient-name-container">
|
|
||||||
{usuario.nome}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>{usuario.email}</td>
|
|
||||||
<td>
|
|
||||||
<span className={usuario.perfil === 'Médico' ? 'badge-medico' : 'badge-paciente'}>
|
|
||||||
{usuario.perfil}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>{usuario.departamento}</td>
|
|
||||||
<td>
|
|
||||||
<div className="d-flex gap-2">
|
|
||||||
<button className="btn btn-sm btn-view" title="Ver detalhes">
|
|
||||||
<i className="bi bi-eye"></i>
|
|
||||||
</button>
|
|
||||||
<button className="btn btn-sm btn-edit" title="Editar">
|
|
||||||
<i className="bi bi-pencil"></i>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-delete"
|
|
||||||
title="Excluir"
|
|
||||||
onClick={() => {
|
|
||||||
setSelectedUserId(usuario.id);
|
|
||||||
setShowDeleteModal(true);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<i className="bi bi-trash"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<tr>
|
|
||||||
<td colSpan="5" className="text-center py-4">
|
|
||||||
<div className="text-muted">
|
|
||||||
<i className="bi bi-search display-4"></i>
|
|
||||||
<p className="mt-2">Nenhum usuário encontrado com os filtros aplicados.</p>
|
|
||||||
{(busca || filtroPerfil !== "Todos" || filtroStatus !== "Todos" || filtroDepartamento !== "Todos") && (
|
|
||||||
<button className="btn btn-outline-primary btn-sm mt-2" onClick={limparFiltros}>
|
|
||||||
Limpar filtros
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Paginação */}
|
|
||||||
{usuariosFiltrados.length > 0 && (
|
|
||||||
<div className="d-flex justify-content-between align-items-center mt-3">
|
|
||||||
<div className="d-flex align-items-center">
|
|
||||||
<span className="me-2 text-muted">Itens por página:</span>
|
|
||||||
<select
|
|
||||||
className="form-select form-select-sm w-auto"
|
|
||||||
value={itensPorPagina}
|
|
||||||
onChange={(e) => {
|
|
||||||
setItensPorPagina(Number(e.target.value));
|
|
||||||
setPaginaAtual(1);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<option value={5}>5</option>
|
|
||||||
<option value={10}>10</option>
|
|
||||||
<option value={25}>25</option>
|
|
||||||
<option value={50}>50</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex align-items-center">
|
|
||||||
<span className="me-3 text-muted">
|
|
||||||
Página {paginaAtual} de {totalPaginas} •
|
|
||||||
Mostrando {indiceInicial + 1}-{Math.min(indiceFinal, usuariosFiltrados.length)} de {usuariosFiltrados.length} usuários
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<nav>
|
|
||||||
<ul className="pagination pagination-sm mb-0">
|
|
||||||
<li className={`page-item ${paginaAtual === 1 ? 'disabled' : ''}`}>
|
|
||||||
<button className="page-link" onClick={voltarPagina}>
|
|
||||||
<i className="bi bi-chevron-left"></i>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{gerarNumerosPaginas().map(pagina => (
|
|
||||||
<li key={pagina} className={`page-item ${pagina === paginaAtual ? 'active' : ''}`}>
|
|
||||||
<button className="page-link" onClick={() => irParaPagina(pagina)}>
|
|
||||||
{pagina}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<li className={`page-item ${paginaAtual === totalPaginas ? 'disabled' : ''}`}>
|
|
||||||
<button className="page-link" onClick={avancarPagina}>
|
|
||||||
<i className="bi bi-chevron-right"></i>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Modal de Confirmação de Exclusão */}
|
|
||||||
{showDeleteModal && (
|
|
||||||
<div
|
|
||||||
className="modal fade show delete-modal"
|
|
||||||
style={{
|
|
||||||
display: "block",
|
|
||||||
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
||||||
}}
|
|
||||||
tabIndex="-1"
|
|
||||||
onClick={(e) =>
|
|
||||||
e.target.classList.contains("modal") && setShowDeleteModal(false)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className="modal-dialog modal-dialog-centered">
|
|
||||||
<div className="modal-content">
|
|
||||||
<div className="modal-header" style={{ backgroundColor: '#dc3545', color: 'white' }}>
|
|
||||||
<h5 className="modal-title">
|
|
||||||
Confirmação de Exclusão
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="modal-body">
|
|
||||||
<p className="mb-0 fs-5">
|
|
||||||
Tem certeza que deseja excluir este usuário?
|
|
||||||
</p>
|
|
||||||
<p className="text-muted mt-2">
|
|
||||||
Esta ação não pode ser desfeita.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="modal-footer">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-primary"
|
|
||||||
onClick={() => setShowDeleteModal(false)}
|
|
||||||
>
|
|
||||||
Cancelar
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-danger"
|
|
||||||
onClick={() => excluirUsuario(selectedUserId)}
|
|
||||||
>
|
|
||||||
<i className="bi bi-trash me-1"></i> Excluir
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,10 +15,10 @@ import {
|
|||||||
Edit,
|
Edit,
|
||||||
Trash2,
|
Trash2,
|
||||||
CheckCircle,
|
CheckCircle,
|
||||||
|
FileText,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import "../pages/style/Agendamento.css";
|
import "../pages/style/Agendamento.css";
|
||||||
import "../pages/style/FilaEspera.css";
|
import "../pages/style/FilaEspera.css";
|
||||||
import "../pages/style/TableDoctor.css";
|
|
||||||
import Spinner from "../components/Spinner.jsx";
|
import Spinner from "../components/Spinner.jsx";
|
||||||
|
|
||||||
dayjs.locale("pt-br");
|
dayjs.locale("pt-br");
|
||||||
@ -30,7 +30,8 @@ const Agendamento = () => {
|
|||||||
const { getAuthorizationHeader, user } = useAuth();
|
const { getAuthorizationHeader, user } = useAuth();
|
||||||
const authHeader = getAuthorizationHeader();
|
const authHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
const ID_MEDICO_ESPECIFICO = "078d2a67-b4c1-43c8-ae32-c1e75bb5b3df";
|
const ID_MEDICO_ESPECIFICO = "31689310-b76c-4ecb-9027-ef6deb71b08d";
|
||||||
|
|
||||||
|
|
||||||
const [listaTodosAgendamentos, setListaTodosAgendamentos] = useState([]);
|
const [listaTodosAgendamentos, setListaTodosAgendamentos] = useState([]);
|
||||||
const [selectedID, setSelectedId] = useState("0");
|
const [selectedID, setSelectedId] = useState("0");
|
||||||
@ -40,12 +41,16 @@ const Agendamento = () => {
|
|||||||
const [DictAgendamentosOrganizados, setAgendamentosOrganizados] = useState(
|
const [DictAgendamentosOrganizados, setAgendamentosOrganizados] = useState(
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||||
const [ListaDeMedicos, setListaDeMedicos] = useState([]);
|
const [ListaDeMedicos, setListaDeMedicos] = useState([]);
|
||||||
const [FiltredTodosMedicos, setFiltredTodosMedicos] = useState([]);
|
const [FiltredTodosMedicos, setFiltredTodosMedicos] = useState([]);
|
||||||
const [searchTermDoctor, setSearchTermDoctor] = useState("");
|
const [searchTermDoctor, setSearchTermDoctor] = useState("");
|
||||||
const [MedicoFiltrado, setMedicoFiltrado] = useState({ id: "vazio" });
|
const [MedicoFiltrado, setMedicoFiltrado] = useState({ id: "vazio" });
|
||||||
const [motivoCancelamento, setMotivoCancelamento] = useState("");
|
const [motivoCancelamento, setMotivoCancelamento] = useState("");
|
||||||
|
const [searchTermPatient, setSearchTermPatient] = useState("");
|
||||||
|
const [patientDropdownOpen, setPatientDropdownOpen] = useState(false);
|
||||||
const [showSpinner, setShowSpinner] = useState(true);
|
const [showSpinner, setShowSpinner] = useState(true);
|
||||||
const [waitlistSearch, setWaitlistSearch] = useState("");
|
const [waitlistSearch, setWaitlistSearch] = useState("");
|
||||||
const [waitSortKey, setWaitSortKey] = useState(null);
|
const [waitSortKey, setWaitSortKey] = useState(null);
|
||||||
@ -291,6 +296,18 @@ const Agendamento = () => {
|
|||||||
setPageConsulta(true);
|
setPageConsulta(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCreateReport = (appointment) => {
|
||||||
|
navigate("/medico/novo-relatorio", {
|
||||||
|
state: {
|
||||||
|
appointment,
|
||||||
|
patient_id: appointment.patient_id,
|
||||||
|
doctor_id: appointment.doctor_id,
|
||||||
|
paciente_nome: appointment.paciente_nome,
|
||||||
|
medico_nome: appointment.medico_nome,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleSearchMedicos = (term) => {
|
const handleSearchMedicos = (term) => {
|
||||||
setSearchTermDoctor(term);
|
setSearchTermDoctor(term);
|
||||||
if (term.trim()) {
|
if (term.trim()) {
|
||||||
@ -304,6 +321,14 @@ const Agendamento = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const filtrarPorPaciente = (appointments) => {
|
||||||
|
if (!searchTermPatient.trim()) return appointments;
|
||||||
|
const term = searchTermPatient.toLowerCase();
|
||||||
|
return appointments.filter((app) =>
|
||||||
|
app.paciente_nome?.toLowerCase().includes(term)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const generateDateGrid = () => {
|
const generateDateGrid = () => {
|
||||||
const grid = [];
|
const grid = [];
|
||||||
const startOfMonth = currentDate.startOf("month");
|
const startOfMonth = currentDate.startOf("month");
|
||||||
@ -412,6 +437,13 @@ const Agendamento = () => {
|
|||||||
() => applySortingWaitlist(filaEsperaFiltrada),
|
() => applySortingWaitlist(filaEsperaFiltrada),
|
||||||
[filaEsperaFiltrada, applySortingWaitlist]
|
[filaEsperaFiltrada, applySortingWaitlist]
|
||||||
);
|
);
|
||||||
|
const listaPacientesUnicos = useMemo(() => {
|
||||||
|
const pacientes = Object.values(cachePacientes || {});
|
||||||
|
return pacientes.sort((a, b) =>
|
||||||
|
(a.full_name || "").localeCompare(b.full_name || "")
|
||||||
|
);
|
||||||
|
}, [cachePacientes]);
|
||||||
|
|
||||||
const waitTotalPages =
|
const waitTotalPages =
|
||||||
Math.ceil(filaEsperaOrdenada.length / waitPerPage) || 1;
|
Math.ceil(filaEsperaOrdenada.length / waitPerPage) || 1;
|
||||||
const waitIndiceInicial = (waitPage - 1) * waitPerPage;
|
const waitIndiceInicial = (waitPage - 1) * waitPerPage;
|
||||||
@ -450,27 +482,39 @@ const Agendamento = () => {
|
|||||||
<h1>Agendar nova consulta</h1>
|
<h1>Agendar nova consulta</h1>
|
||||||
{!PageNovaConsulta ? (
|
{!PageNovaConsulta ? (
|
||||||
<div className="atendimento-eprocura">
|
<div className="atendimento-eprocura">
|
||||||
|
|
||||||
<div className="container-btns-agenda-fila_esepera">
|
<div className="container-btns-agenda-fila_esepera">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className="tabs-agenda-fila">
|
<div className="tabs-agenda-fila">
|
||||||
<button
|
<button
|
||||||
className={`btn-agenda ${!FiladeEspera ? "opc-agenda-ativo" : ""}`}
|
className={`btn-agenda ${
|
||||||
onClick={() => setFiladeEspera(false)}
|
!FiladeEspera ? "opc-agenda-ativo" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => {
|
||||||
|
setFiladeEspera(false);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Agenda
|
Agenda
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`btn-fila-espera ${FiladeEspera ? "opc-filaespera-ativo" : ""}`}
|
className={`btn-fila-espera ${
|
||||||
onClick={() => setFiladeEspera(true)}
|
FiladeEspera ? "opc-filaespera-ativo" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => {
|
||||||
|
setFiladeEspera(true);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Fila de espera
|
Fila de espera
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="btns-gerenciamento-e-consulta"
|
className="btns-gerenciamento-e-consulta"
|
||||||
style={{ display: "flex", gap: "10px", marginBottom: "20px" }}
|
style={{ display: "flex", gap: "10px" }}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="manage-button btn"
|
className="btn btn-primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setAgendamentoParaEdicao(null);
|
setAgendamentoParaEdicao(null);
|
||||||
setPageConsulta(true);
|
setPageConsulta(true);
|
||||||
@ -504,95 +548,217 @@ const Agendamento = () => {
|
|||||||
<div className="info-details">
|
<div className="info-details">
|
||||||
<h3>{selectedDay.format("dddd")}</h3>
|
<h3>{selectedDay.format("dddd")}</h3>
|
||||||
<p>{selectedDay.format("D [de] MMMM [de] YYYY")}</p>
|
<p>{selectedDay.format("D [de] MMMM [de] YYYY")}</p>
|
||||||
|
<div className="calendar-legend">
|
||||||
|
<div className="legend-item" data-status="completed">Realizado</div>
|
||||||
|
<div className="legend-item" data-status="confirmed">Confirmado</div>
|
||||||
|
<div className="legend-item" data-status="agendado">Agendado</div>
|
||||||
|
<div className="legend-item" data-status="cancelled">Cancelado</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className="appointments-list">
|
<div className="appointments-list">
|
||||||
<h4>Consultas para {selectedDay.format("DD/MM")}</h4>
|
<h4>Consultas para {selectedDay.format("DD/MM")}</h4>
|
||||||
{showSpinner ? (
|
{showSpinner ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : DictAgendamentosOrganizados[selectedDay.format("YYYY-MM-DD")]
|
) : (() => {
|
||||||
?.filter(
|
const appointmentsForDay =
|
||||||
(app) =>
|
DictAgendamentosOrganizados[selectedDay.format("YYYY-MM-DD")] || [];
|
||||||
MedicoFiltrado.id === "vazio" ||
|
|
||||||
app.doctor_id === MedicoFiltrado.id
|
// 1º filtro: por médico (se tiver)
|
||||||
).length > 0 ? (
|
const filteredByDoctor = appointmentsForDay.filter(
|
||||||
DictAgendamentosOrganizados[selectedDay.format("YYYY-MM-DD")]
|
(app) =>
|
||||||
.filter(
|
MedicoFiltrado.id === "vazio" ||
|
||||||
(app) =>
|
app.doctor_id === MedicoFiltrado.id
|
||||||
MedicoFiltrado.id === "vazio" ||
|
);
|
||||||
app.doctor_id === MedicoFiltrado.id
|
|
||||||
)
|
// 2º filtro: por paciente (campo de cima)
|
||||||
.map((app) => (
|
const filteredByPatient = filtrarPorPaciente(filteredByDoctor);
|
||||||
<div
|
|
||||||
key={app.id}
|
if (filteredByPatient.length === 0) {
|
||||||
className="appointment-item"
|
return (
|
||||||
data-status={app.status}
|
<div className="no-appointments-info">
|
||||||
>
|
<p>
|
||||||
<div className="item-time">
|
{searchTermPatient
|
||||||
{dayjs(app.scheduled_at).format("HH:mm")}
|
? `Nenhuma consulta encontrada para "${searchTermPatient}".`
|
||||||
</div>
|
: "Nenhuma consulta agendada."}
|
||||||
<div className="item-details">
|
</p>
|
||||||
<span>{app.paciente_nome}</span>
|
</div>
|
||||||
<small>Dr(a). {app.medico_nome}</small>
|
);
|
||||||
</div>
|
}
|
||||||
<div className="appointment-actions">
|
|
||||||
{app.status === "cancelled" ? (
|
return filteredByPatient.map((app) => (
|
||||||
<button
|
<div
|
||||||
className="btn-action btn-edit"
|
key={app.id}
|
||||||
onClick={() => {
|
className="appointment-item"
|
||||||
setSelectedId(app.id);
|
data-status={app.status}
|
||||||
confirmConsulta(app.id);
|
>
|
||||||
}}
|
<div className="item-time">
|
||||||
>
|
{dayjs(app.scheduled_at).add(3, "hour").format("HH:mm")}
|
||||||
<CheckCircle size={16} title="Reverter Cancelamento" />
|
</div>
|
||||||
</button>
|
<div className="item-details">
|
||||||
) : (
|
<span>{app.paciente_nome}</span>
|
||||||
<button
|
<small>Dr(a). {app.medico_nome}</small>
|
||||||
className="btn-action btn-edit"
|
</div>
|
||||||
onClick={() => handleEditConsulta(app)}
|
<div className="appointment-actions">
|
||||||
title="Editar Agendamento"
|
{app.status === "cancelled" ? (
|
||||||
>
|
<button
|
||||||
<Edit size={16} />
|
className="btn-action btn-edit"
|
||||||
</button>
|
onClick={() => {
|
||||||
)}
|
setSelectedId(app.id);
|
||||||
{app.status !== "cancelled" && (
|
confirmConsulta(app.id);
|
||||||
<button
|
}}
|
||||||
className="btn-action btn-delete"
|
>
|
||||||
onClick={() => {
|
<CheckCircle
|
||||||
setSelectedId(app.id);
|
size={16}
|
||||||
setShowDeleteModal(true);
|
title="Reverter Cancelamento"
|
||||||
}}
|
/>
|
||||||
title="Cancelar Agendamento"
|
</button>
|
||||||
>
|
) : (
|
||||||
<Trash2 size={16} />
|
<button
|
||||||
</button>
|
className="btn-action btn-edit"
|
||||||
)}
|
onClick={() => handleEditConsulta(app)}
|
||||||
</div>
|
title="Editar Agendamento"
|
||||||
</div>
|
>
|
||||||
))
|
<Edit size={16} />
|
||||||
) : (
|
</button>
|
||||||
<div className="no-appointments-info">
|
)}
|
||||||
<p>Nenhuma consulta agendada.</p>
|
{app.status !== "cancelled" && (
|
||||||
</div>
|
<button
|
||||||
)}
|
className="btn-action btn-report-blue"
|
||||||
|
onClick={() => handleCreateReport(app)}
|
||||||
|
title="Criar Relatório / Laudo"
|
||||||
|
aria-label={`Criar relatório para ${app.paciente_nome}`}
|
||||||
|
>
|
||||||
|
<FileText size={16} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{app.status !== "cancelled" && (
|
||||||
|
<button
|
||||||
|
className="btn-action btn-delete"
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedId(app.id);
|
||||||
|
setShowDeleteModal(true);
|
||||||
|
}}
|
||||||
|
title="Cancelar Agendamento"
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
));
|
||||||
|
})()}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="calendar-main">
|
<div className="calendar-main">
|
||||||
|
<div className="patient-filter-container" style={{ marginBottom: "20px" }}>
|
||||||
|
<div className="card p-3">
|
||||||
|
<div className="filter-header d-flex align-items-center gap-2 mb-2">
|
||||||
|
<i className="bi bi-funnel-fill text-primary"></i>
|
||||||
|
<h5 className="mb-0">Filtrar por Paciente</h5>
|
||||||
|
</div>
|
||||||
|
<div className="position-relative">
|
||||||
|
<Search
|
||||||
|
size={20}
|
||||||
|
className="position-absolute"
|
||||||
|
style={{ left: "10px", top: "50%", transform: "translateY(-50%)", color: "#6c757d" }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control ps-5"
|
||||||
|
placeholder="Buscar paciente para filtrar consultas"
|
||||||
|
value={searchTermPatient}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSearchTermPatient(e.target.value);
|
||||||
|
setPatientDropdownOpen(true);
|
||||||
|
}}
|
||||||
|
onFocus={() => {
|
||||||
|
if (searchTermPatient.trim()) {
|
||||||
|
setPatientDropdownOpen(true);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
style={{ paddingLeft: "40px" }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{patientDropdownOpen && searchTermPatient.trim() && (
|
||||||
|
<div
|
||||||
|
className="patient-suggestions"
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: "100%",
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
zIndex: 10,
|
||||||
|
backgroundColor: "white",
|
||||||
|
border: "1px solid #ced4da",
|
||||||
|
borderTop: "none",
|
||||||
|
maxHeight: "250px",
|
||||||
|
overflowY: "auto",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{listaPacientesUnicos
|
||||||
|
.filter((p) => {
|
||||||
|
const nome = (p.full_name || "").toLowerCase();
|
||||||
|
const term = searchTermPatient.toLowerCase();
|
||||||
|
return nome.startsWith(term); // só começo do nome
|
||||||
|
})
|
||||||
|
.slice(0, 20)
|
||||||
|
.map((p) => (
|
||||||
|
<button
|
||||||
|
key={p.id}
|
||||||
|
type="button"
|
||||||
|
className="w-100 text-start px-3 py-1"
|
||||||
|
style={{
|
||||||
|
border: "none",
|
||||||
|
background: "white",
|
||||||
|
fontSize: "0.9rem",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
setSearchTermPatient(p.full_name);
|
||||||
|
setPatientDropdownOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{p.full_name} - {p.cpf}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{searchTermPatient && (
|
||||||
|
<div className="mt-2">
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-outline-secondary"
|
||||||
|
onClick={() => setSearchTermPatient("")}
|
||||||
|
>
|
||||||
|
<i className="bi bi-x-circle me-1"></i>
|
||||||
|
Limpar filtro
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div className="calendar-legend">
|
<div className="calendar-legend">
|
||||||
<div className="legend-item" data-status="completed">Realizado</div>
|
|
||||||
<div className="legend-item" data-status="confirmed">Confirmado</div>
|
</div>
|
||||||
<div className="legend-item" data-status="agendado">Agendado</div>
|
|
||||||
<div className="legend-item" data-status="cancelled">Cancelado</div>
|
|
||||||
</div>
|
|
||||||
<div className="calendar-controls">
|
<div className="calendar-controls">
|
||||||
<div className="date-indicator">
|
<div className="date-indicator">
|
||||||
<h2>{currentDate.format("MMMM [de] YYYY")}</h2>
|
<h2>{currentDate.format("MMMM [de] YYYY")}</h2>
|
||||||
<div
|
<div
|
||||||
className="quick-jump-controls"
|
className="quick-jump-controls"
|
||||||
style={{ display: "flex", gap: "5px", marginTop: "10px" }}
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
gap: "5px",
|
||||||
|
marginTop: "10px",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<select
|
<select
|
||||||
value={quickJump.month}
|
value={quickJump.month}
|
||||||
onChange={(e) => handleQuickJumpChange("month", e.target.value)}
|
onChange={(e) =>
|
||||||
|
handleQuickJumpChange("month", e.target.value)
|
||||||
|
}
|
||||||
className="form-select form-select-sm w-auto"
|
className="form-select form-select-sm w-auto"
|
||||||
>
|
>
|
||||||
{dayjs.months().map((month, index) => (
|
{dayjs.months().map((month, index) => (
|
||||||
@ -603,16 +769,19 @@ const Agendamento = () => {
|
|||||||
</select>
|
</select>
|
||||||
<select
|
<select
|
||||||
value={quickJump.year}
|
value={quickJump.year}
|
||||||
onChange={(e) => handleQuickJumpChange("year", e.target.value)}
|
onChange={(e) =>
|
||||||
|
handleQuickJumpChange("year", e.target.value)
|
||||||
|
}
|
||||||
className="form-select form-select-sm w-auto"
|
className="form-select form-select-sm w-auto"
|
||||||
>
|
>
|
||||||
{Array.from({ length: 11 }, (_, i) => dayjs().year() - 5 + i).map(
|
{Array.from(
|
||||||
(year) => (
|
{ length: 11 },
|
||||||
<option key={year} value={year}>
|
(_, i) => dayjs().year() - 5 + i
|
||||||
{year}
|
).map((year) => (
|
||||||
</option>
|
<option key={year} value={year}>
|
||||||
)
|
{year}
|
||||||
)}
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-outline-primary"
|
className="btn btn-sm btn-outline-primary"
|
||||||
@ -661,14 +830,21 @@ const Agendamento = () => {
|
|||||||
))}
|
))}
|
||||||
{dateGrid.map((day, index) => {
|
{dateGrid.map((day, index) => {
|
||||||
const dayString = day.format("YYYY-MM-DD");
|
const dayString = day.format("YYYY-MM-DD");
|
||||||
const appointmentsOnDay = DictAgendamentosOrganizados[dayString] || [];
|
const appointmentsOnDay =
|
||||||
const filteredAppointments = appointmentsOnDay.filter(
|
DictAgendamentosOrganizados[dayString] || [];
|
||||||
(app) =>
|
|
||||||
MedicoFiltrado.id === "vazio" ||
|
const filteredAppointments = filtrarPorPaciente(
|
||||||
app.doctor_id === MedicoFiltrado.id
|
appointmentsOnDay.filter(
|
||||||
);
|
(app) =>
|
||||||
|
MedicoFiltrado.id === "vazio" ||
|
||||||
|
app.doctor_id === MedicoFiltrado.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const cellClasses = `day-cell ${
|
const cellClasses = `day-cell ${
|
||||||
day.isSame(currentDate, "month") ? "current-month" : "other-month"
|
day.isSame(currentDate, "month")
|
||||||
|
? "current-month"
|
||||||
|
: "other-month"
|
||||||
} ${day.isSame(dayjs(), "day") ? "today" : ""} ${
|
} ${day.isSame(dayjs(), "day") ? "today" : ""} ${
|
||||||
day.isSame(selectedDay, "day") ? "selected" : ""
|
day.isSame(selectedDay, "day") ? "selected" : ""
|
||||||
}`;
|
}`;
|
||||||
@ -691,186 +867,231 @@ const Agendamento = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="page-content table-doctor-container">
|
<div className="page-content table-paciente-container">
|
||||||
<div className="table-doctor-card">
|
<section className="row">
|
||||||
<div className="card-header">
|
<div className="col-12">
|
||||||
<h4 className="card-title mb-0">Fila de Espera</h4>
|
<div className="card table-paciente-card">
|
||||||
</div>
|
<div className="card-header">
|
||||||
<div className="card-body">
|
<h4 className="card-title mb-0">Fila de Espera</h4>
|
||||||
<div className="table-doctor-filters">
|
|
||||||
<h5 className="mb-3">
|
|
||||||
<i className="bi bi-funnel-fill me-2 text-primary"></i> Filtros
|
|
||||||
</h5>
|
|
||||||
|
|
||||||
{/* Busca */}
|
|
||||||
<div className="mb-3">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control"
|
|
||||||
placeholder="Buscar por paciente, CPF ou médico..."
|
|
||||||
value={waitlistSearch}
|
|
||||||
onChange={(e) => setWaitlistSearch(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className="card-body">
|
||||||
{/* Linha de Filtros Básicos */}
|
<div className="card p-3 mb-3 table-paciente-filters">
|
||||||
<div className="d-flex flex-wrap align-items-center gap-3 mb-3">
|
<h5 className="mb-3">
|
||||||
{/* Ordenação */}
|
<i className="bi bi-funnel-fill me-2 text-primary"></i>{" "}
|
||||||
<div className="d-flex align-items-center gap-2">
|
Filtros
|
||||||
<label className="form-label mb-0 text-muted small">Ordenar por:</label>
|
</h5>
|
||||||
<select
|
<div className="mb-3">
|
||||||
className="form-select form-select-sm compact-select sort-select"
|
<input
|
||||||
style={{ minWidth: "180px" }}
|
type="text"
|
||||||
value={waitSortKey ? `${waitSortKey}-${waitSortDir}` : ""}
|
className="form-control"
|
||||||
onChange={(e) => {
|
placeholder="Buscar por paciente, CPF ou médico..."
|
||||||
const v = e.target.value;
|
value={waitlistSearch}
|
||||||
if (!v) {
|
onChange={(e) =>
|
||||||
setWaitSortKey(null);
|
setWaitlistSearch(e.target.value)
|
||||||
setWaitSortDir("asc");
|
}
|
||||||
return;
|
/>
|
||||||
}
|
<small className="text-muted">
|
||||||
const [k, d] = v.split("-");
|
Digite o nome do paciente, CPF ou nome do médico
|
||||||
setWaitSortKey(k);
|
</small>
|
||||||
setWaitSortDir(d);
|
</div>
|
||||||
}}
|
<div className="d-flex flex-wrap align-items-center gap-2 mb-3">
|
||||||
>
|
<div className="d-flex align-items-center gap-2">
|
||||||
<option value="">Sem ordenação</option>
|
<span className="me-2 text-muted small">
|
||||||
<option value="paciente-asc">Paciente (A-Z)</option>
|
Ordenar por:
|
||||||
<option value="paciente-desc">Paciente (Z-A)</option>
|
</span>
|
||||||
<option value="medico-asc">Médico (A-Z)</option>
|
<select
|
||||||
<option value="medico-desc">Médico (Z-A)</option>
|
className="form-select compact-select sort-select w-auto"
|
||||||
<option value="data-asc">Data (mais antiga)</option>
|
value={
|
||||||
<option value="data-desc">Data (mais recente)</option>
|
waitSortKey
|
||||||
</select>
|
? `${waitSortKey}-${waitSortDir}`
|
||||||
</div>
|
: ""
|
||||||
</div>
|
}
|
||||||
|
onChange={(e) => {
|
||||||
{/* Contador */}
|
const v = e.target.value;
|
||||||
<div className="mt-3">
|
if (!v) {
|
||||||
<div className="contador-medicos">
|
setWaitSortKey(null);
|
||||||
{filaEsperaFiltrada.length} DE {filaEsperaData.length} SOLICITAÇÕES ENCONTRADAS
|
setWaitSortDir("asc");
|
||||||
</div>
|
return;
|
||||||
</div>
|
}
|
||||||
</div>
|
const [k, d] = v.split("-");
|
||||||
|
setWaitSortKey(k);
|
||||||
{/* ===== TABELA SIMPLIFICADA ===== */}
|
setWaitSortDir(d);
|
||||||
<div className="table-responsive mt-4">
|
}}
|
||||||
<table className="table table-striped table-hover table-doctor-table">
|
>
|
||||||
<thead>
|
<option value="">Sem ordenação</option>
|
||||||
<tr>
|
<option value="paciente-asc">
|
||||||
<th>Nome do Paciente</th>
|
Paciente (A-Z)
|
||||||
<th>CPF</th>
|
</option>
|
||||||
<th>Médico Solicitado</th>
|
<option value="paciente-desc">
|
||||||
<th>Data da Solicitação</th>
|
Paciente (Z-A)
|
||||||
<th>Ações</th>
|
</option>
|
||||||
</tr>
|
<option value="medico-asc">Médico (A-Z)</option>
|
||||||
</thead>
|
<option value="medico-desc">
|
||||||
<tbody>
|
Médico (Z-A)
|
||||||
{filaEsperaPaginada.length > 0 ? (
|
</option>
|
||||||
filaEsperaPaginada.map((item, index) => (
|
<option value="data-asc">
|
||||||
<tr key={index}>
|
Data (mais antiga)
|
||||||
<td>{item?.Infos?.paciente_nome}</td>
|
</option>
|
||||||
<td>{item?.Infos?.paciente_cpf}</td>
|
<option value="data-desc">
|
||||||
<td>{item?.Infos?.medico_nome}</td>
|
Data (mais recente)
|
||||||
<td>
|
</option>
|
||||||
{dayjs(item.agendamento.scheduled_at).format("DD/MM/YYYY")}
|
</select>
|
||||||
</td>
|
</div>
|
||||||
<td>
|
</div>
|
||||||
<button
|
<div className="mt-3">
|
||||||
className="btn btn-sm btn-delete"
|
<div className="contador-pacientes">
|
||||||
onClick={() => {
|
{filaEsperaFiltrada.length} DE{" "}
|
||||||
setSelectedId(item.agendamento.id);
|
{filaEsperaData.length} SOLICITAÇÕES ENCONTRADAS
|
||||||
setShowDeleteModal(true);
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="table-responsive">
|
||||||
|
<table className="table table-striped table-hover table-paciente-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Nome do Paciente</th>
|
||||||
|
<th>CPF</th>
|
||||||
|
<th>Médico Solicitado</th>
|
||||||
|
<th>Data da Solicitação</th>
|
||||||
|
<th>Ações</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{filaEsperaPaginada.length > 0 ? (
|
||||||
|
filaEsperaPaginada.map((item, index) => (
|
||||||
|
<tr key={index}>
|
||||||
|
<td>{item?.Infos?.paciente_nome}</td>
|
||||||
|
<td>{item?.Infos?.paciente_cpf}</td>
|
||||||
|
<td>{item?.Infos?.medico_nome}</td>
|
||||||
|
<td>
|
||||||
|
{dayjs(
|
||||||
|
item.agendamento.scheduled_at
|
||||||
|
).format("DD/MM/YYYY")}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-delete"
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedId(item.agendamento.id);
|
||||||
|
setShowDeleteModal(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<i className="bi bi-trash me-1"></i>{" "}
|
||||||
|
Excluir
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<tr>
|
||||||
|
<td colSpan="5" className="text-center py-4">
|
||||||
|
<div className="text-muted">
|
||||||
|
{showSpinner ? (
|
||||||
|
<Spinner />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<i className="bi bi-inbox display-4"></i>
|
||||||
|
<p className="mt-2">
|
||||||
|
Nenhuma solicitação encontrada.
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{filaEsperaFiltrada.length > 0 && (
|
||||||
|
<div className="d-flex justify-content-between align-items-center mt-3">
|
||||||
|
<div className="d-flex align-items-center">
|
||||||
|
<span className="me-2 text-muted">
|
||||||
|
Itens por página:
|
||||||
|
</span>
|
||||||
|
<select
|
||||||
|
className="form-select form-select-sm w-auto"
|
||||||
|
value={waitPerPage}
|
||||||
|
onChange={(e) => {
|
||||||
|
setWaitPerPage(Number(e.target.value));
|
||||||
|
setWaitPage(1);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<i className="bi bi-trash me-1"></i> Excluir
|
<option value={5}>5</option>
|
||||||
</button>
|
<option value={10}>10</option>
|
||||||
</td>
|
<option value={25}>25</option>
|
||||||
</tr>
|
<option value={50}>50</option>
|
||||||
))
|
</select>
|
||||||
) : (
|
|
||||||
<tr>
|
|
||||||
<td colSpan="5" className="text-center py-4">
|
|
||||||
<div className="text-muted">
|
|
||||||
{showSpinner ? (
|
|
||||||
<Spinner />
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<i className="bi bi-search display-4"></i>
|
|
||||||
<p className="mt-2">Nenhuma solicitação encontrada.</p>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
<div className="d-flex align-items-center">
|
||||||
</tr>
|
<span className="me-3 text-muted">
|
||||||
)}
|
Página {waitPage} de {waitTotalPages} •
|
||||||
</tbody>
|
Mostrando {waitIndiceInicial + 1}-
|
||||||
</table>
|
{Math.min(
|
||||||
|
waitIndiceFinal,
|
||||||
{/* ===== PAGINAÇÃO ===== */}
|
filaEsperaFiltrada.length
|
||||||
{filaEsperaFiltrada.length > 0 && (
|
)}{" "}
|
||||||
<div className="d-flex justify-content-between align-items-center mt-3">
|
de {filaEsperaFiltrada.length}
|
||||||
<div className="d-flex align-items-center">
|
</span>
|
||||||
<span className="me-2 text-muted">Itens por página:</span>
|
<nav>
|
||||||
<select
|
<ul className="pagination pagination-sm mb-0">
|
||||||
className="form-select form-select-sm w-auto"
|
<li
|
||||||
value={waitPerPage}
|
className={`page-item ${
|
||||||
onChange={(e) => {
|
waitPage === 1 ? "disabled" : ""
|
||||||
setWaitPerPage(Number(e.target.value));
|
}`}
|
||||||
setWaitPage(1);
|
>
|
||||||
}}
|
<button
|
||||||
>
|
className="page-link"
|
||||||
<option value={5}>5</option>
|
onClick={() =>
|
||||||
<option value={10}>10</option>
|
setWaitPage((p) => Math.max(1, p - 1))
|
||||||
<option value={25}>25</option>
|
}
|
||||||
<option value={50}>50</option>
|
>
|
||||||
</select>
|
<i className="bi bi-chevron-left"></i>
|
||||||
</div>
|
</button>
|
||||||
<div className="d-flex align-items-center">
|
</li>
|
||||||
<span className="me-3 text-muted">
|
{gerarNumerosWaitPages().map((pagina) => (
|
||||||
Página {waitPage} de {waitTotalPages} • Mostrando {waitIndiceInicial + 1}-
|
<li
|
||||||
{Math.min(waitIndiceFinal, filaEsperaFiltrada.length)} de {filaEsperaFiltrada.length}
|
key={pagina}
|
||||||
</span>
|
className={`page-item ${
|
||||||
<nav>
|
pagina === waitPage ? "active" : ""
|
||||||
<ul className="pagination pagination-sm mb-0">
|
}`}
|
||||||
<li className={`page-item ${waitPage === 1 ? "disabled" : ""}`}>
|
>
|
||||||
<button
|
<button
|
||||||
className="page-link"
|
className="page-link"
|
||||||
onClick={() => setWaitPage((p) => Math.max(1, p - 1))}
|
onClick={() => setWaitPage(pagina)}
|
||||||
>
|
>
|
||||||
<i className="bi bi-chevron-left"></i>
|
{pagina}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
{gerarNumerosWaitPages().map((pagina) => (
|
))}
|
||||||
<li
|
<li
|
||||||
key={pagina}
|
className={`page-item ${
|
||||||
className={`page-item ${pagina === waitPage ? "active" : ""}`}
|
waitPage === waitTotalPages
|
||||||
>
|
? "disabled"
|
||||||
<button
|
: ""
|
||||||
className="page-link"
|
}`}
|
||||||
onClick={() => setWaitPage(pagina)}
|
>
|
||||||
>
|
<button
|
||||||
{pagina}
|
className="page-link"
|
||||||
</button>
|
onClick={() =>
|
||||||
</li>
|
setWaitPage((p) =>
|
||||||
))}
|
Math.min(waitTotalPages, p + 1)
|
||||||
<li className={`page-item ${waitPage === waitTotalPages ? "disabled" : ""}`}>
|
)
|
||||||
<button
|
}
|
||||||
className="page-link"
|
>
|
||||||
onClick={() => setWaitPage((p) => Math.min(waitTotalPages, p + 1))}
|
<i className="bi bi-chevron-right"></i>
|
||||||
>
|
</button>
|
||||||
<i className="bi bi-chevron-right"></i>
|
</li>
|
||||||
</button>
|
</ul>
|
||||||
</li>
|
</nav>
|
||||||
</ul>
|
</div>
|
||||||
</nav>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import html2pdf from 'html2pdf.js';
|
import html2pdf from 'html2pdf.js';
|
||||||
import TiptapViewer from './TiptapViewer';
|
import TiptapViewer from './TiptapViewer';
|
||||||
import './styleMedico/DoctorRelatorioManager.css';
|
import './styleMedico/DoctorRelatorioManager.css';
|
||||||
import '../pages/style/TableDoctor.css';
|
|
||||||
|
|
||||||
const DoctorRelatorioManager = () => {
|
const DoctorRelatorioManager = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -26,15 +25,12 @@ const DoctorRelatorioManager = () => {
|
|||||||
const [relatorioModal, setRelatorioModal] = useState(null);
|
const [relatorioModal, setRelatorioModal] = useState(null);
|
||||||
const [termoPesquisa, setTermoPesquisa] = useState('');
|
const [termoPesquisa, setTermoPesquisa] = useState('');
|
||||||
const [filtroExame, setFiltroExame] = useState('');
|
const [filtroExame, setFiltroExame] = useState('');
|
||||||
|
const [examesDisponiveis, setExamesDisponiveis] = useState([]);
|
||||||
const [modalIndex, setModalIndex] = useState(0);
|
const [modalIndex, setModalIndex] = useState(0);
|
||||||
const [loadingPacientes, setLoadingPacientes] = useState(false);
|
|
||||||
|
|
||||||
const [paginaAtual, setPaginaAtual] = useState(1);
|
const [paginaAtual, setPaginaAtual] = useState(1);
|
||||||
const [itensPorPagina, setItensPorPagina] = useState(10);
|
const [itensPorPagina, setItensPorPagina] = useState(10);
|
||||||
|
|
||||||
const [sortKey, setSortKey] = useState('');
|
|
||||||
const [sortDir, setSortDir] = useState('asc');
|
|
||||||
|
|
||||||
const totalPaginas = Math.max(1, Math.ceil(relatoriosFinais.length / itensPorPagina));
|
const totalPaginas = Math.max(1, Math.ceil(relatoriosFinais.length / itensPorPagina));
|
||||||
const indiceInicial = (paginaAtual - 1) * itensPorPagina;
|
const indiceInicial = (paginaAtual - 1) * itensPorPagina;
|
||||||
const indiceFinal = indiceInicial + itensPorPagina;
|
const indiceFinal = indiceInicial + itensPorPagina;
|
||||||
@ -50,6 +46,7 @@ const DoctorRelatorioManager = () => {
|
|||||||
if (authHeader) myHeaders.append('Authorization', authHeader);
|
if (authHeader) myHeaders.append('Authorization', authHeader);
|
||||||
const requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' };
|
const requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' };
|
||||||
|
|
||||||
|
|
||||||
let userId = null;
|
let userId = null;
|
||||||
let userFullName = null;
|
let userFullName = null;
|
||||||
try {
|
try {
|
||||||
@ -63,10 +60,12 @@ const DoctorRelatorioManager = () => {
|
|||||||
console.warn('Não foi possível obter UserInfos (pode não estar logado):', err);
|
console.warn('Não foi possível obter UserInfos (pode não estar logado):', err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const baseUrl = "https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/reports?select=*";
|
const baseUrl = "https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/reports?select=*";
|
||||||
let data = [];
|
let data = [];
|
||||||
|
|
||||||
if (userId) {
|
if (userId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${baseUrl}&doctor_id=eq.${userId}`, requestOptions);
|
const res = await fetch(`${baseUrl}&doctor_id=eq.${userId}`, requestOptions);
|
||||||
data = await res.json();
|
data = await res.json();
|
||||||
@ -75,6 +74,7 @@ const DoctorRelatorioManager = () => {
|
|||||||
data = [];
|
data = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((!Array.isArray(data) || data.length === 0) && userId) {
|
if ((!Array.isArray(data) || data.length === 0) && userId) {
|
||||||
try {
|
try {
|
||||||
const res2 = await fetch(`${baseUrl}&created_by=eq.${userId}`, requestOptions);
|
const res2 = await fetch(`${baseUrl}&created_by=eq.${userId}`, requestOptions);
|
||||||
@ -87,6 +87,7 @@ const DoctorRelatorioManager = () => {
|
|||||||
|
|
||||||
if ((!Array.isArray(data) || data.length === 0) && userFullName) {
|
if ((!Array.isArray(data) || data.length === 0) && userFullName) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const encodedName = encodeURIComponent(userFullName);
|
const encodedName = encodeURIComponent(userFullName);
|
||||||
const res3 = await fetch(`${baseUrl}&requested_by=eq.${encodedName}`, requestOptions);
|
const res3 = await fetch(`${baseUrl}&requested_by=eq.${encodedName}`, requestOptions);
|
||||||
data = await res3.json();
|
data = await res3.json();
|
||||||
@ -107,6 +108,7 @@ const DoctorRelatorioManager = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const uniqueMap = new Map();
|
const uniqueMap = new Map();
|
||||||
(Array.isArray(data) ? data : []).forEach(r => {
|
(Array.isArray(data) ? data : []).forEach(r => {
|
||||||
if (r && r.id) uniqueMap.set(r.id, r);
|
if (r && r.id) uniqueMap.set(r.id, r);
|
||||||
@ -140,13 +142,13 @@ const DoctorRelatorioManager = () => {
|
|||||||
};
|
};
|
||||||
}, [authHeader]);
|
}, [authHeader]);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchRelData = async () => {
|
const fetchRelData = async () => {
|
||||||
setLoadingPacientes(true);
|
|
||||||
const pacientes = [];
|
const pacientes = [];
|
||||||
const medicos = [];
|
const medicos = [];
|
||||||
for (let i = 0; i < relatoriosOriginais.length; i++) {
|
for (let i = 0; i < relatoriosFinais.length; i++) {
|
||||||
const rel = relatoriosOriginais[i];
|
const rel = relatoriosFinais[i];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const pacienteRes = await GetPatientByID(rel.patient_id, authHeader);
|
const pacienteRes = await GetPatientByID(rel.patient_id, authHeader);
|
||||||
@ -160,6 +162,7 @@ const DoctorRelatorioManager = () => {
|
|||||||
const docRes = await GetDoctorByID(rel.doctor_id, authHeader);
|
const docRes = await GetDoctorByID(rel.doctor_id, authHeader);
|
||||||
medicos.push(Array.isArray(docRes) ? docRes[0] : docRes);
|
medicos.push(Array.isArray(docRes) ? docRes[0] : docRes);
|
||||||
} else if (rel.created_by) {
|
} else if (rel.created_by) {
|
||||||
|
|
||||||
const docRes = await GetDoctorByID(rel.created_by, authHeader);
|
const docRes = await GetDoctorByID(rel.created_by, authHeader);
|
||||||
medicos.push(Array.isArray(docRes) ? docRes[0] : docRes);
|
medicos.push(Array.isArray(docRes) ? docRes[0] : docRes);
|
||||||
} else if (rel.requested_by) {
|
} else if (rel.requested_by) {
|
||||||
@ -173,82 +176,14 @@ const DoctorRelatorioManager = () => {
|
|||||||
}
|
}
|
||||||
setPacientesComRelatorios(pacientes);
|
setPacientesComRelatorios(pacientes);
|
||||||
setMedicosComRelatorios(medicos);
|
setMedicosComRelatorios(medicos);
|
||||||
setLoadingPacientes(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (relatoriosOriginais.length > 0) fetchRelData();
|
if (relatoriosFinais.length > 0) fetchRelData();
|
||||||
else {
|
else {
|
||||||
setPacientesComRelatorios([]);
|
setPacientesComRelatorios([]);
|
||||||
setMedicosComRelatorios([]);
|
setMedicosComRelatorios([]);
|
||||||
setLoadingPacientes(false);
|
|
||||||
}
|
}
|
||||||
}, [relatoriosOriginais, authHeader]);
|
}, [relatoriosFinais, authHeader]);
|
||||||
|
|
||||||
// Filtragem e Ordenação
|
|
||||||
useEffect(() => {
|
|
||||||
// Aguardar o carregamento dos pacientes antes de filtrar
|
|
||||||
if (loadingPacientes) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const q = (termoPesquisa || '').toLowerCase().trim();
|
|
||||||
const ex = (filtroExame || '').toLowerCase().trim();
|
|
||||||
|
|
||||||
let items = relatoriosOriginais || [];
|
|
||||||
|
|
||||||
// Aplicar filtros
|
|
||||||
if (q || ex) {
|
|
||||||
items = items.filter((r, idx) => {
|
|
||||||
let passaBusca = true;
|
|
||||||
let passaExame = true;
|
|
||||||
|
|
||||||
if (q) {
|
|
||||||
const paciente = pacientesComRelatorios[idx];
|
|
||||||
const patientName = (paciente?.full_name || r.patient_name || r.patient_fullname || '').toString().toLowerCase();
|
|
||||||
const patientCPF = (paciente?.cpf || '').toString().toLowerCase();
|
|
||||||
const pedido = (r.id || r.request_id || r.request || '').toString().toLowerCase();
|
|
||||||
passaBusca = patientName.includes(q) || patientCPF.includes(q) || pedido.includes(q) || (r.patient_id && r.patient_id.toString().includes(q));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ex) {
|
|
||||||
passaExame = (r.exam || r.exame || '').toLowerCase().includes(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return passaBusca && passaExame;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aplicar ordenação
|
|
||||||
if (sortKey) {
|
|
||||||
items = [...items].sort((a, b) => {
|
|
||||||
let aValue = '';
|
|
||||||
let bValue = '';
|
|
||||||
|
|
||||||
if (sortKey === 'paciente') {
|
|
||||||
const aIdx = relatoriosOriginais.findIndex(r => r.id === a.id);
|
|
||||||
const bIdx = relatoriosOriginais.findIndex(r => r.id === b.id);
|
|
||||||
const aPaciente = pacientesComRelatorios[aIdx];
|
|
||||||
const bPaciente = pacientesComRelatorios[bIdx];
|
|
||||||
aValue = (aPaciente?.full_name || a.patient_name || a.patient_fullname || '').toLowerCase();
|
|
||||||
bValue = (bPaciente?.full_name || b.patient_name || b.patient_fullname || '').toLowerCase();
|
|
||||||
} else if (sortKey === 'exame') {
|
|
||||||
aValue = (a.exam || a.exame || '').toLowerCase();
|
|
||||||
bValue = (b.exam || b.exame || '').toLowerCase();
|
|
||||||
} else if (sortKey === 'data') {
|
|
||||||
aValue = new Date(a.due_at || a.date || a.created_at || 0);
|
|
||||||
bValue = new Date(b.due_at || b.date || b.created_at || 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aValue < bValue) return sortDir === 'asc' ? -1 : 1;
|
|
||||||
if (aValue > bValue) return sortDir === 'asc' ? 1 : -1;
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setRelatoriosFiltrados(items);
|
|
||||||
setRelatoriosFinais(items);
|
|
||||||
setPaginaAtual(1);
|
|
||||||
}, [termoPesquisa, filtroExame, relatoriosOriginais, sortKey, sortDir, pacientesComRelatorios, loadingPacientes]);
|
|
||||||
|
|
||||||
const abrirModal = (relatorio, pageIndex) => {
|
const abrirModal = (relatorio, pageIndex) => {
|
||||||
const globalIndex = relatoriosFinais.findIndex(r => r.id === relatorio.id);
|
const globalIndex = relatoriosFinais.findIndex(r => r.id === relatorio.id);
|
||||||
@ -258,11 +193,10 @@ const DoctorRelatorioManager = () => {
|
|||||||
setShowModal(true);
|
setShowModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const limparFiltros = () => {
|
const limparFiltros = () => {
|
||||||
setTermoPesquisa('');
|
setTermoPesquisa('');
|
||||||
setFiltroExame('');
|
setFiltroExame('');
|
||||||
setSortKey('');
|
|
||||||
setSortDir('asc');
|
|
||||||
setRelatoriosFinais(relatoriosOriginais);
|
setRelatoriosFinais(relatoriosOriginais);
|
||||||
setPaginaAtual(1);
|
setPaginaAtual(1);
|
||||||
};
|
};
|
||||||
@ -282,257 +216,41 @@ const DoctorRelatorioManager = () => {
|
|||||||
html2pdf().set(opt).from(elemento).save();
|
html2pdf().set(opt).from(elemento).save();
|
||||||
};
|
};
|
||||||
|
|
||||||
const irParaPagina = (pagina) => setPaginaAtual(pagina);
|
const irParaPagina = (pagina) => {
|
||||||
const avancarPagina = () => paginaAtual < totalPaginas && setPaginaAtual(p => p + 1);
|
setPaginaAtual(pagina);
|
||||||
const voltarPagina = () => paginaAtual > 1 && setPaginaAtual(p => p - 1);
|
};
|
||||||
|
|
||||||
|
const avancarPagina = () => {
|
||||||
|
if (paginaAtual < totalPaginas) {
|
||||||
|
setPaginaAtual(paginaAtual + 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const voltarPagina = () => {
|
||||||
|
if (paginaAtual > 1) {
|
||||||
|
setPaginaAtual(paginaAtual - 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const gerarNumerosPaginas = () => {
|
const gerarNumerosPaginas = () => {
|
||||||
const paginas = [];
|
const paginas = [];
|
||||||
const paginasParaMostrar = 5;
|
const paginasParaMostrar = 5;
|
||||||
|
|
||||||
let inicio = Math.max(1, paginaAtual - Math.floor(paginasParaMostrar / 2));
|
let inicio = Math.max(1, paginaAtual - Math.floor(paginasParaMostrar / 2));
|
||||||
let fim = Math.min(totalPaginas, inicio + paginasParaMostrar - 1);
|
let fim = Math.min(totalPaginas, inicio + paginasParaMostrar - 1);
|
||||||
|
|
||||||
inicio = Math.max(1, fim - paginasParaMostrar + 1);
|
inicio = Math.max(1, fim - paginasParaMostrar + 1);
|
||||||
for (let i = inicio; i <= fim; i++) paginas.push(i);
|
|
||||||
|
for (let i = inicio; i <= fim; i++) {
|
||||||
|
paginas.push(i);
|
||||||
|
}
|
||||||
|
|
||||||
return paginas;
|
return paginas;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="page-heading">
|
{showModal && (
|
||||||
<h3>Lista de Relatórios</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="page-content table-doctor-container">
|
|
||||||
<div className="table-doctor-card">
|
|
||||||
<div className="card-header d-flex justify-content-between align-items-center">
|
|
||||||
<h4 className="card-title mb-0">Relatórios Cadastrados</h4>
|
|
||||||
<Link to={'criar'}>
|
|
||||||
<button className="btn btn-primary">
|
|
||||||
<i className="bi bi-plus-circle"></i> Adicionar Relatório
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="card-body">
|
|
||||||
{/* ===== FILTROS PADRONIZADOS ===== */}
|
|
||||||
<div className="table-doctor-filters">
|
|
||||||
<h5 className="mb-3">
|
|
||||||
<i className="bi bi-funnel-fill me-2 text-primary"></i> Filtros
|
|
||||||
</h5>
|
|
||||||
|
|
||||||
{/* Busca */}
|
|
||||||
<div className="mb-3">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control"
|
|
||||||
placeholder="Buscar por nome ou CPF do paciente..."
|
|
||||||
value={termoPesquisa}
|
|
||||||
onChange={(e) => setTermoPesquisa(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Linha de Filtros Básicos - TUDO EM UMA LINHA SÓ */}
|
|
||||||
<div className="d-flex flex-wrap align-items-center gap-3 mb-3">
|
|
||||||
{/* Filtro Exame */}
|
|
||||||
<div className="d-flex align-items-center gap-2">
|
|
||||||
<label className="form-label mb-0 text-muted small">Tipo de Exame:</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control form-control-sm compact-select"
|
|
||||||
placeholder="Digite o exame..."
|
|
||||||
value={filtroExame}
|
|
||||||
onChange={(e) => setFiltroExame(e.target.value)}
|
|
||||||
style={{ minWidth: "180px" }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Separador */}
|
|
||||||
<div className="vr d-none d-md-block" style={{ height: "30px" }} />
|
|
||||||
|
|
||||||
{/* Ordenação */}
|
|
||||||
<div className="d-flex align-items-center gap-2">
|
|
||||||
<label className="form-label mb-0 text-muted small">Ordenar por:</label>
|
|
||||||
<select
|
|
||||||
className="form-select form-select-sm compact-select sort-select"
|
|
||||||
value={sortKey ? `${sortKey}-${sortDir}` : ''}
|
|
||||||
onChange={e => {
|
|
||||||
const v = e.target.value;
|
|
||||||
if (!v) {
|
|
||||||
setSortKey('');
|
|
||||||
setSortDir('asc');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const [k, d] = v.split('-');
|
|
||||||
setSortKey(k);
|
|
||||||
setSortDir(d);
|
|
||||||
}}
|
|
||||||
style={{ minWidth: "180px" }}
|
|
||||||
>
|
|
||||||
<option value="">Sem ordenação</option>
|
|
||||||
<option value="paciente-asc">Paciente (A-Z)</option>
|
|
||||||
<option value="paciente-desc">Paciente (Z-A)</option>
|
|
||||||
<option value="exame-asc">Exame (A-Z)</option>
|
|
||||||
<option value="exame-desc">Exame (Z-A)</option>
|
|
||||||
<option value="data-asc">Data (mais antiga)</option>
|
|
||||||
<option value="data-desc">Data (mais recente)</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Linha de Ações */}
|
|
||||||
<div className="d-flex justify-content-between align-items-center">
|
|
||||||
<div></div> {/* Espaço vazio para alinhamento */}
|
|
||||||
|
|
||||||
<button
|
|
||||||
className="btn btn-outline-secondary btn-sm d-flex align-items-center"
|
|
||||||
onClick={limparFiltros}
|
|
||||||
>
|
|
||||||
<i className="bi bi-arrow-clockwise me-1"></i> Limpar Filtros
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Contador */}
|
|
||||||
<div className="mt-3">
|
|
||||||
<div className="contador-medicos">
|
|
||||||
{relatoriosFinais.length} DE {relatoriosOriginais.length} RELATÓRIOS ENCONTRADOS
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* ===== TABELA SIMPLIFICADA ===== */}
|
|
||||||
<div className="table-responsive mt-4">
|
|
||||||
<table className="table table-striped table-hover table-paciente-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Paciente</th>
|
|
||||||
<th>CPF</th>
|
|
||||||
<th>Exame</th>
|
|
||||||
<th>Data</th>
|
|
||||||
<th>Ações</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{relatoriosPaginados.length > 0 ? (
|
|
||||||
relatoriosPaginados.map((relatorio, index) => {
|
|
||||||
const globalIndex = relatoriosFinais.findIndex(r => r.id === relatorio.id);
|
|
||||||
const paciente = pacientesComRelatorios[globalIndex];
|
|
||||||
const dataRelatorio = relatorio.due_at || relatorio.date || relatorio.created_at;
|
|
||||||
const dataFormatada = dataRelatorio ? new Date(dataRelatorio).toLocaleDateString('pt-BR') : '—';
|
|
||||||
|
|
||||||
return (
|
|
||||||
<tr key={relatorio.id}>
|
|
||||||
<td>
|
|
||||||
<div className="d-flex align-items-center patient-name-container">
|
|
||||||
{paciente?.full_name || 'Carregando...'}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>{paciente?.cpf || 'Carregando...'}</td>
|
|
||||||
<td>
|
|
||||||
<span className="badge specialty-badge">
|
|
||||||
{relatorio.exam || '—'}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span className="text-muted small">
|
|
||||||
{dataFormatada}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div className="d-flex gap-2">
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-view"
|
|
||||||
onClick={() => abrirModal(relatorio, index)}
|
|
||||||
>
|
|
||||||
<i className="bi bi-eye me-1"></i> Ver
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-edit"
|
|
||||||
onClick={() => navigate(`/medico/relatorios/${relatorio.id}/edit`)}
|
|
||||||
>
|
|
||||||
<i className="bi bi-pencil me-1"></i> Editar
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
) : (
|
|
||||||
<tr>
|
|
||||||
<td colSpan="5" className="text-center py-4">
|
|
||||||
<div className="text-muted">
|
|
||||||
<i className="bi bi-search display-4"></i>
|
|
||||||
<p className="mt-2">Nenhum relatório encontrado com os filtros aplicados.</p>
|
|
||||||
{(termoPesquisa || filtroExame) && (
|
|
||||||
<button className="btn btn-outline-primary btn-sm mt-2" onClick={limparFiltros}>
|
|
||||||
Limpar filtros
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{/* ===== PAGINAÇÃO ===== */}
|
|
||||||
{relatoriosFinais.length > 0 && (
|
|
||||||
<div className="d-flex justify-content-between align-items-center mt-3">
|
|
||||||
<div className="d-flex align-items-center">
|
|
||||||
<span className="me-2 text-muted">Itens por página:</span>
|
|
||||||
<select
|
|
||||||
className="form-select form-select-sm w-auto"
|
|
||||||
value={itensPorPagina}
|
|
||||||
onChange={(e) => {
|
|
||||||
setItensPorPagina(Number(e.target.value));
|
|
||||||
setPaginaAtual(1);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<option value={5}>5</option>
|
|
||||||
<option value={10}>10</option>
|
|
||||||
<option value={25}>25</option>
|
|
||||||
<option value={50}>50</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex align-items-center">
|
|
||||||
<span className="me-3 text-muted">
|
|
||||||
Página {paginaAtual} de {totalPaginas} •
|
|
||||||
Mostrando {indiceInicial + 1}-{Math.min(indiceFinal, relatoriosFinais.length)} de {relatoriosFinais.length} relatórios
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<nav>
|
|
||||||
<ul className="pagination pagination-sm mb-0">
|
|
||||||
<li className={`page-item ${paginaAtual === 1 ? 'disabled' : ''}`}>
|
|
||||||
<button className="page-link" onClick={voltarPagina}>
|
|
||||||
<i className="bi bi-chevron-left"></i>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{gerarNumerosPaginas().map(pagina => (
|
|
||||||
<li key={pagina} className={`page-item ${pagina === paginaAtual ? 'active' : ''}`}>
|
|
||||||
<button className="page-link" onClick={() => irParaPagina(pagina)}>
|
|
||||||
{pagina}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<li className={`page-item ${paginaAtual === totalPaginas ? 'disabled' : ''}`}>
|
|
||||||
<button className="page-link" onClick={avancarPagina}>
|
|
||||||
<i className="bi bi-chevron-right"></i>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* ===== MODAL DE DETALHES ===== */}
|
|
||||||
{showModal && relatorioModal && (
|
|
||||||
<div className="modal fade show" style={{ display: "block", backgroundColor: "rgba(0, 0, 0, 0.5)" }} tabIndex="-1">
|
<div className="modal fade show" style={{ display: "block", backgroundColor: "rgba(0, 0, 0, 0.5)" }} tabIndex="-1">
|
||||||
<div className="modal-dialog modal-dialog-centered modal-lg">
|
<div className="modal-dialog modal-dialog-centered modal-lg">
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
@ -578,6 +296,159 @@ const DoctorRelatorioManager = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<div className="page-heading"><h3>Lista de Relatórios</h3></div>
|
||||||
|
<div className="page-content">
|
||||||
|
<section className="row">
|
||||||
|
<div className="col-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-header d-flex justify-content-between align-items-center">
|
||||||
|
<h4 className="card-title mb-0">Relatórios Cadastrados</h4>
|
||||||
|
<Link to={'criar'}>
|
||||||
|
<button className="btn btn-primary">
|
||||||
|
<i className="bi bi-plus-circle"></i> Adicionar Relatório
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="card p-3 mb-3">
|
||||||
|
<h5 className="mb-3">
|
||||||
|
<i className="bi bi-funnel-fill me-2 text-primary"></i> Filtros
|
||||||
|
</h5>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-md-5">
|
||||||
|
<div className="mb-3">
|
||||||
|
<label className="form-label">Buscar por nome ou CPF do paciente</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Digite nome ou CPF do paciente..."
|
||||||
|
value={termoPesquisa}
|
||||||
|
onChange={(e) => setTermoPesquisa(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-5">
|
||||||
|
<div className="mb-3">
|
||||||
|
<label className="form-label">Filtrar por tipo de exame</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Digite o tipo de exame..."
|
||||||
|
value={filtroExame}
|
||||||
|
onChange={(e) => setFiltroExame(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-2 d-flex align-items-end">
|
||||||
|
<button className="btn btn-outline-secondary w-100" onClick={limparFiltros}>
|
||||||
|
<i className="bi bi-arrow-clockwise"></i> Limpar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mt-2">
|
||||||
|
<div className="contador-relatorios">
|
||||||
|
{relatoriosFinais.length} DE {relatoriosOriginais.length} RELATÓRIOS ENCONTRADOS
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="table-responsive">
|
||||||
|
<table className="table table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Paciente</th>
|
||||||
|
<th>CPF</th>
|
||||||
|
<th>Exame</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{relatoriosPaginados.length > 0 ? (
|
||||||
|
relatoriosPaginados.map((relatorio, index) => {
|
||||||
|
const globalIndex = relatoriosFinais.findIndex(r => r.id === relatorio.id);
|
||||||
|
const paciente = pacientesComRelatorios[globalIndex];
|
||||||
|
return (
|
||||||
|
<tr key={relatorio.id}>
|
||||||
|
<td>{paciente?.full_name || 'Carregando...'}</td>
|
||||||
|
<td>{paciente?.cpf || 'Carregando...'}</td>
|
||||||
|
<td>{relatorio.exam}</td>
|
||||||
|
<td>
|
||||||
|
<div className="d-flex gap-2">
|
||||||
|
<button className="btn btn-sm btn-ver-detalhes" onClick={() => abrirModal(relatorio, index)}>
|
||||||
|
<i className="bi bi-eye me-1"></i> Ver Detalhes
|
||||||
|
</button>
|
||||||
|
<button className="btn btn-sm btn-editar" onClick={() => navigate(`/medico/relatorios/${relatorio.id}/edit`)}>
|
||||||
|
<i className="bi bi-pencil me-1"></i> Editar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) : (
|
||||||
|
<tr><td colSpan="4" className="text-center">Nenhum relatório encontrado.</td></tr>
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{relatoriosFinais.length > 0 && (
|
||||||
|
<div className="d-flex justify-content-between align-items-center mt-3">
|
||||||
|
<div className="d-flex align-items-center">
|
||||||
|
<span className="me-2 text-muted">Itens por página:</span>
|
||||||
|
<select
|
||||||
|
className="form-select form-select-sm w-auto"
|
||||||
|
value={itensPorPagina}
|
||||||
|
onChange={(e) => {
|
||||||
|
setItensPorPagina(Number(e.target.value));
|
||||||
|
setPaginaAtual(1);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option value={5}>5</option>
|
||||||
|
<option value={10}>10</option>
|
||||||
|
<option value={25}>25</option>
|
||||||
|
<option value={50}>50</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="d-flex align-items-center">
|
||||||
|
<span className="me-3 text-muted">
|
||||||
|
Página {paginaAtual} de {totalPaginas} •
|
||||||
|
Mostrando {indiceInicial + 1}-{Math.min(indiceFinal, relatoriosFinais.length)} de {relatoriosFinais.length} itens
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<ul className="pagination pagination-sm mb-0">
|
||||||
|
<li className={`page-item ${paginaAtual === 1 ? 'disabled' : ''}`}>
|
||||||
|
<button className="page-link" onClick={voltarPagina}>
|
||||||
|
<i className="bi bi-chevron-left"></i>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{gerarNumerosPaginas().map(pagina => (
|
||||||
|
<li key={pagina} className={`page-item ${pagina === paginaAtual ? 'active' : ''}`}>
|
||||||
|
<button className="page-link" onClick={() => irParaPagina(pagina)}>
|
||||||
|
{pagina}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<li className={`page-item ${paginaAtual === totalPaginas ? 'disabled' : ''}`}>
|
||||||
|
<button className="page-link" onClick={avancarPagina}>
|
||||||
|
<i className="bi bi-chevron-right"></i>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
|
// src/PagesMedico/FormNovoRelatorio.jsx
|
||||||
import React, { useEffect, useState, useRef } from 'react';
|
import React, { useEffect, useState, useRef } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate, useLocation } from 'react-router-dom';
|
||||||
import API_KEY from '../components/utils/apiKeys';
|
import API_KEY from '../components/utils/apiKeys';
|
||||||
import { useAuth } from '../components/utils/AuthProvider';
|
import { useAuth } from '../components/utils/AuthProvider';
|
||||||
import TiptapEditor from './TiptapEditor';
|
import TiptapEditor from './TiptapEditor';
|
||||||
@ -12,6 +13,7 @@ const FormNovoRelatorio = () => {
|
|||||||
const { getAuthorizationHeader } = useAuth();
|
const { getAuthorizationHeader } = useAuth();
|
||||||
const authHeader = getAuthorizationHeader();
|
const authHeader = getAuthorizationHeader();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
const [patients, setPatients] = useState([]);
|
const [patients, setPatients] = useState([]);
|
||||||
const [doctors, setDoctors] = useState([]);
|
const [doctors, setDoctors] = useState([]);
|
||||||
@ -33,6 +35,7 @@ const FormNovoRelatorio = () => {
|
|||||||
const [showDoctorDropdown, setShowDoctorDropdown] = useState(false);
|
const [showDoctorDropdown, setShowDoctorDropdown] = useState(false);
|
||||||
const patientRef = useRef();
|
const patientRef = useRef();
|
||||||
const doctorRef = useRef();
|
const doctorRef = useRef();
|
||||||
|
const [lockedFromAppointment, setLockedFromAppointment] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let mounted = true;
|
let mounted = true;
|
||||||
@ -129,7 +132,24 @@ const FormNovoRelatorio = () => {
|
|||||||
|
|
||||||
const handleEditorChange = (html) => setForm(prev => ({ ...prev, contentHtml: html }));
|
const handleEditorChange = (html) => setForm(prev => ({ ...prev, contentHtml: html }));
|
||||||
|
|
||||||
// 🔹 Agora com created_by sendo o ID do usuário logado
|
useEffect(() => {
|
||||||
|
if (location && location.state && location.state.appointment) {
|
||||||
|
const appt = location.state.appointment;
|
||||||
|
const paciente_nome = location.state.paciente_nome || appt.paciente_nome || '';
|
||||||
|
const medico_nome = location.state.medico_nome || appt.medico_nome || '';
|
||||||
|
setForm(prev => ({
|
||||||
|
...prev,
|
||||||
|
patient_id: appt.patient_id || prev.patient_id,
|
||||||
|
patient_name: paciente_nome || prev.patient_name,
|
||||||
|
patient_birth: prev.patient_birth || '',
|
||||||
|
doctor_id: appt.doctor_id || prev.doctor_id,
|
||||||
|
doctor_name: medico_nome || prev.doctor_name,
|
||||||
|
contentHtml: generateTemplate(paciente_nome, prev.patient_birth || '', medico_nome)
|
||||||
|
}));
|
||||||
|
setLockedFromAppointment(true);
|
||||||
|
}
|
||||||
|
}, [location]);
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!form.patient_id) return alert('Selecione o paciente (clicando no item) antes de salvar.');
|
if (!form.patient_id) return alert('Selecione o paciente (clicando no item) antes de salvar.');
|
||||||
@ -149,7 +169,6 @@ const FormNovoRelatorio = () => {
|
|||||||
requested_by: form.doctor_name || ''
|
requested_by: form.doctor_name || ''
|
||||||
};
|
};
|
||||||
|
|
||||||
// Busca o id do usuário logado (via token)
|
|
||||||
let userId = null;
|
let userId = null;
|
||||||
try {
|
try {
|
||||||
const token = authHeader?.replace(/^Bearer\s+/i, '') || '';
|
const token = authHeader?.replace(/^Bearer\s+/i, '') || '';
|
||||||
@ -189,8 +208,6 @@ const FormNovoRelatorio = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const created = await res.json();
|
const created = await res.json();
|
||||||
console.log('Relatório criado:', created);
|
|
||||||
|
|
||||||
window.dispatchEvent(new Event('reports:refresh'));
|
window.dispatchEvent(new Event('reports:refresh'));
|
||||||
alert('Relatório criado com sucesso!');
|
alert('Relatório criado com sucesso!');
|
||||||
navigate('/medico/relatorios');
|
navigate('/medico/relatorios');
|
||||||
@ -211,11 +228,12 @@ const FormNovoRelatorio = () => {
|
|||||||
<input
|
<input
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder="Comece a digitar (ex.: m para pacientes que começam com m)"
|
placeholder="Comece a digitar (ex.: m para pacientes que começam com m)"
|
||||||
value={patientQuery}
|
value={lockedFromAppointment ? form.patient_name : patientQuery}
|
||||||
onChange={(e) => { setPatientQuery(e.target.value); setShowPatientDropdown(true); }}
|
onChange={(e) => { if (!lockedFromAppointment) { setPatientQuery(e.target.value); setShowPatientDropdown(true); } }}
|
||||||
onFocus={() => setShowPatientDropdown(true)}
|
onFocus={() => { if (!lockedFromAppointment) setShowPatientDropdown(true); }}
|
||||||
|
disabled={lockedFromAppointment}
|
||||||
/>
|
/>
|
||||||
{showPatientDropdown && patientQuery && (
|
{!lockedFromAppointment && showPatientDropdown && patientQuery && (
|
||||||
<ul className="list-group position-absolute" style={{ zIndex: 50, maxHeight: 220, overflowY: 'auto', width: '100%' }}>
|
<ul className="list-group position-absolute" style={{ zIndex: 50, maxHeight: 220, overflowY: 'auto', width: '100%' }}>
|
||||||
{filteredPatients.length > 0 ? filteredPatients.map(p => (
|
{filteredPatients.length > 0 ? filteredPatients.map(p => (
|
||||||
<li key={p.id} className="list-group-item list-group-item-action" onClick={() => choosePatient(p)}>
|
<li key={p.id} className="list-group-item list-group-item-action" onClick={() => choosePatient(p)}>
|
||||||
@ -232,11 +250,12 @@ const FormNovoRelatorio = () => {
|
|||||||
<input
|
<input
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder="Comece a digitar o nome do médico"
|
placeholder="Comece a digitar o nome do médico"
|
||||||
value={doctorQuery}
|
value={lockedFromAppointment ? form.doctor_name : doctorQuery}
|
||||||
onChange={(e) => { setDoctorQuery(e.target.value); setShowDoctorDropdown(true); }}
|
onChange={(e) => { if (!lockedFromAppointment) { setDoctorQuery(e.target.value); setShowDoctorDropdown(true); } }}
|
||||||
onFocus={() => setShowDoctorDropdown(true)}
|
onFocus={() => { if (!lockedFromAppointment) setShowDoctorDropdown(true); }}
|
||||||
|
disabled={lockedFromAppointment}
|
||||||
/>
|
/>
|
||||||
{showDoctorDropdown && doctorQuery && (
|
{!lockedFromAppointment && showDoctorDropdown && doctorQuery && (
|
||||||
<ul className="list-group position-absolute" style={{ zIndex: 50, maxHeight: 220, overflowY: 'auto', width: '100%' }}>
|
<ul className="list-group position-absolute" style={{ zIndex: 50, maxHeight: 220, overflowY: 'auto', width: '100%' }}>
|
||||||
{filteredDoctors.length > 0 ? filteredDoctors.map(d => (
|
{filteredDoctors.length > 0 ? filteredDoctors.map(d => (
|
||||||
<li key={d.id} className="list-group-item list-group-item-action" onClick={() => chooseDoctor(d)}>
|
<li key={d.id} className="list-group-item list-group-item-action" onClick={() => chooseDoctor(d)}>
|
||||||
|
|||||||
@ -6,18 +6,58 @@
|
|||||||
/* --- Posiciona a barra de busca corretamente --- */
|
/* --- Posiciona a barra de busca corretamente --- */
|
||||||
.busca-atendimento {
|
.busca-atendimento {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center; /* Alinha os itens verticalmente */
|
align-items: center;
|
||||||
margin-top: 20px; /* Espaço acima da barra de busca */
|
margin-top: 20px;
|
||||||
padding: 0 10px; /* Adiciona um padding lateral para alinhar com o resto */
|
padding: 0 10px;
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.busca-atendimento > div:first-child {
|
.busca-atendimento > div:first-child {
|
||||||
width: 400px; /* Define um tamanho para a barra de pesquisa */
|
width: 400px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.busca-atendimento {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.busca-atendimento > div:first-child {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btns-e-legenda-container {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legenda-tabela {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.busca-atendimento {
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btns-e-legenda-container {
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-selecionar-tabeladia,
|
||||||
|
.btn-selecionar-tabelasemana,
|
||||||
|
.btn-selecionar-tabelames {
|
||||||
|
padding: 6px 8px;
|
||||||
|
font-size: medium;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.busca-atendimento input {
|
.busca-atendimento input {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
@ -126,13 +166,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.container-btns-agenda-fila_esepera {
|
.container-btns-agenda-fila_esepera {
|
||||||
margin-top: 30px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-end;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
margin-left: 20px;
|
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
margin-left: 0;
|
||||||
|
padding: 0 20px 0;
|
||||||
|
border-bottom: 1px solid #edf1f7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.btn-fila-espera,
|
.btn-fila-espera,
|
||||||
.btn-agenda {
|
.btn-agenda {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
@ -230,3 +277,9 @@ html[data-bs-theme="dark"] .legenda-item-agendado {
|
|||||||
border: 3px solid #4d4d2e;
|
border: 3px solid #4d4d2e;
|
||||||
color: #f7f7c4;
|
color: #f7f7c4;
|
||||||
}
|
}
|
||||||
|
.calendar-legend {
|
||||||
|
margin-top: 8px;
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|||||||
@ -85,13 +85,35 @@
|
|||||||
@media (max-width: 900px) {
|
@media (max-width: 900px) {
|
||||||
.ai-editor-container {
|
.ai-editor-container {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
min-height: auto;
|
||||||
}
|
}
|
||||||
.editor-sidebar {
|
.editor-sidebar {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
.preview-area {
|
||||||
|
padding: 20px;
|
||||||
}
|
}
|
||||||
.paper-a4 {
|
.paper-a4 {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-height: auto;
|
||||||
padding: 15mm;
|
padding: 15mm;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.ai-editor-container {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.editor-sidebar {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
.preview-area {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.paper-a4 {
|
||||||
|
padding: 10mm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,83 +1,110 @@
|
|||||||
import React from 'react'
|
import React, { useState, useEffect } from 'react';
|
||||||
import FormConsultaPaciente from './FormConsultaPaciente'
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useState, useEffect } from 'react'
|
import dayjs from 'dayjs';
|
||||||
import { useNavigate } from 'react-router-dom'
|
|
||||||
import { useAuth } from '../components/utils/AuthProvider'
|
import FormConsultaPaciente from './FormConsultaPaciente';
|
||||||
import API_KEY from '../components/utils/apiKeys'
|
import { useAuth } from '../components/utils/AuthProvider';
|
||||||
|
import API_KEY from '../components/utils/apiKeys';
|
||||||
|
import { UserInfos } from '../components/utils/Functions-Endpoints/General';
|
||||||
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { UserInfos } from '../components/utils/Functions-Endpoints/General'
|
|
||||||
const ConsultaCadastroManager = () => {
|
const ConsultaCadastroManager = () => {
|
||||||
|
const { getAuthorizationHeader, user } = useAuth();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const {getAuthorizationHeader} = useAuth()
|
const [Dict, setDict] = useState({});
|
||||||
const [Dict, setDict] = useState({})
|
// patient_id fixo do Pedro Abravanel
|
||||||
const navigate = useNavigate()
|
const [patientId, setPatientId] = useState('bf7d8323-05e1-437a-817c-f08eb5f174ef');
|
||||||
const [idUsuario, setIDusuario] = useState("")
|
const [idUsuario, setIDusuario] = useState('');
|
||||||
|
|
||||||
let authHeader = getAuthorizationHeader()
|
|
||||||
|
|
||||||
|
const authHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
|
// Opcional: ainda tenta buscar infos do usuário, mas NÃO mostra mais alerta
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const ColherInfoUsuario =async () => {
|
const ColherInfoUsuario = async () => {
|
||||||
const result = await UserInfos(authHeader)
|
try {
|
||||||
|
if (!authHeader) return;
|
||||||
|
|
||||||
setIDusuario(result?.profile?.id)
|
const result = await UserInfos(authHeader);
|
||||||
|
|
||||||
}
|
const pid =
|
||||||
ColherInfoUsuario()
|
result?.patient_id ||
|
||||||
|
result?.profile?.id ||
|
||||||
|
user?.patient_id ||
|
||||||
|
user?.profile?.id ||
|
||||||
|
user?.user?.id;
|
||||||
|
|
||||||
|
if (pid) {
|
||||||
|
setPatientId(pid);
|
||||||
|
}
|
||||||
|
|
||||||
}, [])
|
setIDusuario(result?.profile?.id || pid || '');
|
||||||
|
} catch (e) {
|
||||||
const handleSave = (Dict) => {
|
console.error('Erro ao colher infos do usuário:', e);
|
||||||
|
}
|
||||||
let DataAtual = dayjs()
|
|
||||||
var myHeaders = new Headers();
|
|
||||||
myHeaders.append("apikey", API_KEY);
|
|
||||||
myHeaders.append("Authorization", authHeader);
|
|
||||||
myHeaders.append("Content-Type", "application/json");
|
|
||||||
|
|
||||||
|
|
||||||
var raw = JSON.stringify({
|
|
||||||
"patient_id": "6e7f8829-0574-42df-9290-8dbb70f75ada",
|
|
||||||
"doctor_id": Dict.doctor_id,
|
|
||||||
"scheduled_at": `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
|
||||||
"duration_minutes": 30,
|
|
||||||
"appointment_type": Dict.tipo_consulta,
|
|
||||||
|
|
||||||
"patient_notes": "Prefiro horário pela manhã",
|
|
||||||
"insurance_provider": Dict.convenio,
|
|
||||||
"status": "confirmed",
|
|
||||||
"created_by": idUsuario
|
|
||||||
});
|
|
||||||
|
|
||||||
var requestOptions = {
|
|
||||||
method: 'POST',
|
|
||||||
headers: myHeaders,
|
|
||||||
body: raw,
|
|
||||||
redirect: 'follow'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments", requestOptions)
|
ColherInfoUsuario();
|
||||||
.then(response => response.text())
|
}, [authHeader, user]);
|
||||||
.then(result => console.log(result))
|
|
||||||
.catch(error => console.log('error', error));
|
|
||||||
|
|
||||||
}
|
const handleSave = (Dict) => {
|
||||||
|
// se por algum motivo não tiver, usa o fixo do Pedro
|
||||||
|
const finalPatientId = patientId || 'bf7d8323-05e1-437a-817c-f08eb5f174ef';
|
||||||
|
|
||||||
|
const myHeaders = new Headers();
|
||||||
|
myHeaders.append('apikey', API_KEY);
|
||||||
|
myHeaders.append('Authorization', authHeader);
|
||||||
|
myHeaders.append('Content-Type', 'application/json');
|
||||||
|
|
||||||
|
const raw = JSON.stringify({
|
||||||
|
patient_id: finalPatientId, // paciente Pedro
|
||||||
|
doctor_id: Dict.doctor_id,
|
||||||
|
scheduled_at: `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
||||||
|
duration_minutes: 30,
|
||||||
|
appointment_type: Dict.tipo_consulta,
|
||||||
|
patient_notes: 'Prefiro horário pela manhã',
|
||||||
|
insurance_provider: Dict.convenio,
|
||||||
|
status: 'confirmed',
|
||||||
|
created_by: idUsuario || finalPatientId,
|
||||||
|
});
|
||||||
|
|
||||||
|
const requestOptions = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: myHeaders,
|
||||||
|
body: raw,
|
||||||
|
redirect: 'follow',
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch(
|
||||||
|
'https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments',
|
||||||
|
requestOptions
|
||||||
|
)
|
||||||
|
.then(async (response) => {
|
||||||
|
if (!response.ok) {
|
||||||
|
const text = await response.text();
|
||||||
|
throw new Error(`Erro ao salvar consulta: ${response.status} - ${text}`);
|
||||||
|
}
|
||||||
|
return response.text();
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
alert('Consulta solicitada com sucesso!');
|
||||||
|
navigate('/paciente/agendamento/'); // volta para o calendário
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('error', error);
|
||||||
|
alert('Erro ao salvar a consulta. Tente novamente.');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
return (
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<FormConsultaPaciente agendamento={Dict} setAgendamento={setDict} onSave={handleSave} onCancel={() => navigate("/paciente/agendamento/")}/>
|
<FormConsultaPaciente
|
||||||
|
agendamento={Dict}
|
||||||
|
setAgendamento={setDict}
|
||||||
|
onSave={handleSave}
|
||||||
|
onCancel={() => navigate('/paciente/agendamento/')}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default ConsultaCadastroManager
|
export default ConsultaCadastroManager;
|
||||||
|
|||||||
@ -7,10 +7,9 @@ import dayjs from 'dayjs';
|
|||||||
import 'dayjs/locale/pt-br';
|
import 'dayjs/locale/pt-br';
|
||||||
import isBetween from 'dayjs/plugin/isBetween';
|
import isBetween from 'dayjs/plugin/isBetween';
|
||||||
import localeData from 'dayjs/plugin/localeData';
|
import localeData from 'dayjs/plugin/localeData';
|
||||||
import { ChevronLeft, ChevronRight, Edit, Trash2 } from 'lucide-react';
|
import { ChevronLeft, ChevronRight, Trash2 } from 'lucide-react';
|
||||||
import "../pages/style/Agendamento.css";
|
import '../pages/style/Agendamento.css';
|
||||||
import '../pages/style/FilaEspera.css';
|
import '../pages/style/FilaEspera.css';
|
||||||
import '../pages/style/TableDoctor.css';
|
|
||||||
import Spinner from '../components/Spinner.jsx';
|
import Spinner from '../components/Spinner.jsx';
|
||||||
|
|
||||||
dayjs.locale('pt-br');
|
dayjs.locale('pt-br');
|
||||||
@ -21,8 +20,12 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { getAuthorizationHeader, user } = useAuth();
|
const { getAuthorizationHeader, user } = useAuth();
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
console.log('USER NO AGENDAMENTO:', user);
|
||||||
const [DictAgendamentosOrganizados, setDictAgendamentosOrganizados] = useState({});
|
|
||||||
|
const [patientId, setPatientId] = useState('bf7d8323-05e1-437a-817c-f08eb5f174ef');
|
||||||
|
const [isLoading, setIsLoading] = useState(false); // começa false
|
||||||
|
const [DictAgendamentosOrganizados, setDictAgendamentosOrganizados] =
|
||||||
|
useState({});
|
||||||
const [filaEsperaData, setFilaDeEsperaData] = useState([]);
|
const [filaEsperaData, setFilaDeEsperaData] = useState([]);
|
||||||
const [FiladeEspera, setFiladeEspera] = useState(false);
|
const [FiladeEspera, setFiladeEspera] = useState(false);
|
||||||
const [PageNovaConsulta, setPageConsulta] = useState(false);
|
const [PageNovaConsulta, setPageConsulta] = useState(false);
|
||||||
@ -31,90 +34,115 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
const [selectedDay, setSelectedDay] = useState(dayjs());
|
const [selectedDay, setSelectedDay] = useState(dayjs());
|
||||||
const [quickJump, setQuickJump] = useState({
|
const [quickJump, setQuickJump] = useState({
|
||||||
month: currentDate.month(),
|
month: currentDate.month(),
|
||||||
year: currentDate.year()
|
year: currentDate.year(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const [isCancelModalOpen, setIsCancelModalOpen] = useState(false);
|
const [isCancelModalOpen, setIsCancelModalOpen] = useState(false);
|
||||||
const [appointmentToCancel, setAppointmentToCancel] = useState(null);
|
const [appointmentToCancel, setAppointmentToCancel] = useState(null);
|
||||||
const [cancellationReason, setCancellationReason] = useState('');
|
const [cancellationReason, setCancellationReason] = useState('');
|
||||||
|
|
||||||
// Estados para filtro, ordenação e paginação da fila de espera
|
const authHeader = useMemo(
|
||||||
const [waitlistSearch, setWaitlistSearch] = useState('');
|
() => getAuthorizationHeader(),
|
||||||
const [waitSortKey, setWaitSortKey] = useState(null);
|
[getAuthorizationHeader]
|
||||||
const [waitSortDir, setWaitSortDir] = useState('asc');
|
);
|
||||||
const [waitPage, setWaitPage] = useState(1);
|
|
||||||
const [waitPerPage, setWaitPerPage] = useState(10);
|
|
||||||
|
|
||||||
const authHeader = useMemo(() => getAuthorizationHeader(), [getAuthorizationHeader]);
|
// Buscar consultas desse paciente
|
||||||
|
const carregarDados = async () => {
|
||||||
|
// só tenta buscar quando tiver header e patientId
|
||||||
|
if (!authHeader) {
|
||||||
|
console.warn('Header de autorização não disponível.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
if (!patientId) {
|
||||||
const carregarDados = async () => {
|
console.warn('patientId ainda não carregado, aguardando contexto.');
|
||||||
const patientId = user?.patient_id || "6e7f8829-0574-42df-9290-8dbb70f75ada";
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!authHeader) {
|
setIsLoading(true);
|
||||||
console.warn("Header de autorização não disponível.");
|
try {
|
||||||
setIsLoading(false);
|
const myHeaders = new Headers({
|
||||||
return;
|
Authorization: authHeader,
|
||||||
}
|
apikey: API_KEY,
|
||||||
|
});
|
||||||
|
const requestOptions = { method: 'GET', headers: myHeaders };
|
||||||
|
|
||||||
setIsLoading(true);
|
const response = await fetch(
|
||||||
try {
|
`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?select=*,doctors(full_name)&patient_id=eq.${patientId}`,
|
||||||
const myHeaders = new Headers({ "Authorization": authHeader, "apikey": API_KEY });
|
requestOptions
|
||||||
const requestOptions = { method: 'GET', headers: myHeaders };
|
);
|
||||||
const response = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?select=*,doctors(full_name)&patient_id=eq.${patientId}`, requestOptions);
|
|
||||||
|
|
||||||
if (!response.ok) throw new Error(`Erro na requisição: ${response.statusText}`);
|
if (!response.ok)
|
||||||
|
throw new Error(`Erro na requisição: ${response.statusText}`);
|
||||||
|
|
||||||
const consultasBrutas = await response.json() || [];
|
const consultasBrutas = (await response.json()) || [];
|
||||||
|
console.log('CONSULTAS BRUTAS PACIENTE:', consultasBrutas);
|
||||||
|
|
||||||
const newDict = {};
|
const newDict = {};
|
||||||
const newFila = [];
|
const newFila = [];
|
||||||
|
|
||||||
for (const agendamento of consultasBrutas) {
|
for (const agendamento of consultasBrutas) {
|
||||||
const agendamentoMelhorado = {
|
const agendamentoMelhorado = {
|
||||||
...agendamento,
|
...agendamento,
|
||||||
medico_nome: agendamento.doctors?.full_name || 'Médico não informado'
|
medico_nome: agendamento.doctors?.full_name || 'Médico não informado',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (agendamento.status === "requested") {
|
if (agendamento.status === 'requested') {
|
||||||
newFila.push({ agendamento: agendamentoMelhorado, Infos: agendamentoMelhorado });
|
newFila.push({
|
||||||
|
agendamento: agendamentoMelhorado,
|
||||||
|
Infos: agendamentoMelhorado,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const diaAgendamento = dayjs(
|
||||||
|
agendamento.scheduled_at
|
||||||
|
).format('YYYY-MM-DD');
|
||||||
|
if (newDict[diaAgendamento]) {
|
||||||
|
newDict[diaAgendamento].push(agendamentoMelhorado);
|
||||||
} else {
|
} else {
|
||||||
const diaAgendamento = dayjs(agendamento.scheduled_at).format("YYYY-MM-DD");
|
newDict[diaAgendamento] = [agendamentoMelhorado];
|
||||||
if (newDict[diaAgendamento]) {
|
|
||||||
newDict[diaAgendamento].push(agendamentoMelhorado);
|
|
||||||
} else {
|
|
||||||
newDict[diaAgendamento] = [agendamentoMelhorado];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key in newDict) {
|
|
||||||
newDict[key].sort((a, b) => a.scheduled_at.localeCompare(b.scheduled_at));
|
|
||||||
}
|
|
||||||
|
|
||||||
setDictAgendamentosOrganizados(newDict);
|
|
||||||
setFilaDeEsperaData(newFila);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Falha ao buscar ou processar agendamentos:', err);
|
|
||||||
setDictAgendamentosOrganizados({});
|
|
||||||
setFilaDeEsperaData([]);
|
|
||||||
} finally {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
for (const key in newDict) {
|
||||||
|
newDict[key].sort((a, b) =>
|
||||||
|
a.scheduled_at.localeCompare(b.scheduled_at)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
setDictAgendamentosOrganizados(newDict);
|
||||||
|
setFilaDeEsperaData(newFila);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Falha ao buscar ou processar agendamentos:', err);
|
||||||
|
setDictAgendamentosOrganizados({});
|
||||||
|
setFilaDeEsperaData([]);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// roda quando authHeader ou patientId mudarem
|
||||||
|
useEffect(() => {
|
||||||
carregarDados();
|
carregarDados();
|
||||||
}, [authHeader, user]);
|
}, [authHeader, patientId]); // padrão recomendado para fetch com useEffect [web:46][web:82]
|
||||||
|
|
||||||
const updateAppointmentStatus = async (id, updates) => {
|
const updateAppointmentStatus = async (id, updates) => {
|
||||||
const myHeaders = new Headers({
|
const myHeaders = new Headers({
|
||||||
"Authorization": authHeader, "apikey": API_KEY, "Content-Type": "application/json"
|
Authorization: authHeader,
|
||||||
|
apikey: API_KEY,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
});
|
});
|
||||||
const requestOptions = { method: 'PATCH', headers: myHeaders, body: JSON.stringify(updates) };
|
const requestOptions = {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: myHeaders,
|
||||||
|
body: JSON.stringify(updates),
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${id}`, requestOptions);
|
const response = await fetch(
|
||||||
|
`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${id}`,
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
if (!response.ok) throw new Error('Falha ao atualizar o status.');
|
if (!response.ok) throw new Error('Falha ao atualizar o status.');
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -132,11 +160,13 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
const executeCancellation = async () => {
|
const executeCancellation = async () => {
|
||||||
if (!appointmentToCancel) return;
|
if (!appointmentToCancel) return;
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const motivo = cancellationReason.trim() || "Cancelado pelo paciente (motivo não especificado)";
|
const motivo =
|
||||||
|
cancellationReason.trim() ||
|
||||||
|
'Cancelado pelo paciente (motivo não especificado)';
|
||||||
const success = await updateAppointmentStatus(appointmentToCancel, {
|
const success = await updateAppointmentStatus(appointmentToCancel, {
|
||||||
status: "cancelled",
|
status: 'cancelled',
|
||||||
cancellation_reason: motivo,
|
cancellation_reason: motivo,
|
||||||
updated_at: new Date().toISOString()
|
updated_at: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
|
|
||||||
setIsCancelModalOpen(false);
|
setIsCancelModalOpen(false);
|
||||||
@ -144,28 +174,38 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
setCancellationReason('');
|
setCancellationReason('');
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
alert("Solicitação cancelada com sucesso!");
|
alert('Solicitação cancelada com sucesso!');
|
||||||
|
|
||||||
setDictAgendamentosOrganizados(prev => {
|
setDictAgendamentosOrganizados((prev) => {
|
||||||
const newDict = { ...prev };
|
const newDict = { ...prev };
|
||||||
for (const date in newDict) {
|
for (const date in newDict) {
|
||||||
newDict[date] = newDict[date].filter(app => app.id !== appointmentToCancel);
|
newDict[date] = newDict[date].filter(
|
||||||
|
(app) => app.id !== appointmentToCancel
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return newDict;
|
return newDict;
|
||||||
});
|
});
|
||||||
setFilaDeEsperaData(prev => prev.filter(item => item.agendamento.id !== appointmentToCancel));
|
setFilaDeEsperaData((prev) =>
|
||||||
|
prev.filter((item) => item.agendamento.id !== appointmentToCancel)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
alert("Falha ao cancelar a solicitação.");
|
alert('Falha ao cancelar a solicitação.');
|
||||||
}
|
}
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleQuickJumpChange = (type, value) => setQuickJump(prev => ({ ...prev, [type]: Number(value) }));
|
const handleQuickJumpChange = (type, value) =>
|
||||||
|
setQuickJump((prev) => ({ ...prev, [type]: Number(value) }));
|
||||||
|
|
||||||
const applyQuickJump = () => {
|
const applyQuickJump = () => {
|
||||||
const newDate = dayjs().year(quickJump.year).month(quickJump.month).date(1);
|
const newDate = dayjs()
|
||||||
|
.year(quickJump.year)
|
||||||
|
.month(quickJump.month)
|
||||||
|
.date(1);
|
||||||
setCurrentDate(newDate);
|
setCurrentDate(newDate);
|
||||||
setSelectedDay(newDate);
|
setSelectedDay(newDate);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dateGrid = useMemo(() => {
|
const dateGrid = useMemo(() => {
|
||||||
const grid = [];
|
const grid = [];
|
||||||
const startOfMonth = currentDate.startOf('month');
|
const startOfMonth = currentDate.startOf('month');
|
||||||
@ -176,156 +216,247 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
}
|
}
|
||||||
return grid;
|
return grid;
|
||||||
}, [currentDate]);
|
}, [currentDate]);
|
||||||
|
|
||||||
const weekDays = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'];
|
const weekDays = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'];
|
||||||
const handleDateClick = (day) => setSelectedDay(day);
|
const handleDateClick = (day) => setSelectedDay(day);
|
||||||
|
|
||||||
// Filtro e ordenação da fila de espera
|
|
||||||
const filaEsperaFiltrada = useMemo(() => {
|
|
||||||
if (!waitlistSearch.trim()) return filaEsperaData;
|
|
||||||
const term = waitlistSearch.toLowerCase();
|
|
||||||
return filaEsperaData.filter(
|
|
||||||
(item) =>
|
|
||||||
(item?.Infos?.medico_nome?.toLowerCase() || '').includes(term)
|
|
||||||
);
|
|
||||||
}, [waitlistSearch, filaEsperaData]);
|
|
||||||
|
|
||||||
const applySortingWaitlist = (arr) => {
|
|
||||||
if (!Array.isArray(arr) || !waitSortKey) return arr;
|
|
||||||
const copy = [...arr];
|
|
||||||
if (waitSortKey === 'medico') {
|
|
||||||
copy.sort((a, b) => (a?.Infos?.medico_nome || '').localeCompare(b?.Infos?.medico_nome || ''));
|
|
||||||
} else if (waitSortKey === 'data') {
|
|
||||||
copy.sort((a, b) =>
|
|
||||||
new Date(a?.agendamento?.created_at || 0) - new Date(b?.agendamento?.created_at || 0)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (waitSortDir === 'desc') copy.reverse();
|
|
||||||
return copy;
|
|
||||||
};
|
|
||||||
|
|
||||||
const filaEsperaOrdenada = applySortingWaitlist(filaEsperaFiltrada);
|
|
||||||
const waitTotalPages = Math.ceil(filaEsperaOrdenada.length / waitPerPage) || 1;
|
|
||||||
const waitIndiceInicial = (waitPage - 1) * waitPerPage;
|
|
||||||
const waitIndiceFinal = waitIndiceInicial + waitPerPage;
|
|
||||||
const filaEsperaPaginada = filaEsperaOrdenada.slice(waitIndiceInicial, waitIndiceFinal);
|
|
||||||
|
|
||||||
const gerarNumerosWaitPages = () => {
|
|
||||||
const paginas = [];
|
|
||||||
const paginasParaMostrar = 5;
|
|
||||||
let inicio = Math.max(1, waitPage - Math.floor(paginasParaMostrar / 2));
|
|
||||||
let fim = Math.min(waitTotalPages, inicio + paginasParaMostrar - 1);
|
|
||||||
inicio = Math.max(1, fim - paginasParaMostrar + 1);
|
|
||||||
for (let i = inicio; i <= fim; i++) paginas.push(i);
|
|
||||||
return paginas;
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setWaitPage(1);
|
|
||||||
}, [waitlistSearch, waitSortKey, waitSortDir]);
|
|
||||||
|
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="form-container" style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '50vh' }}>
|
<div
|
||||||
|
className="form-container"
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
height: '50vh',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Spinner />
|
<Spinner />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>Minhas consultas</h1>
|
<h1>Minhas consultas</h1>
|
||||||
<div className="btns-gerenciamento-e-consulta" style={{ display: 'flex', gap: '10px', marginBottom: '20px' }}>
|
<div
|
||||||
<button
|
className="btns-gerenciamento-e-consulta"
|
||||||
className="btn-adicionar-consulta"
|
style={{ display: 'flex', gap: '10px', marginBottom: '20px' }}
|
||||||
onClick={() => {
|
>
|
||||||
setPageConsulta(true);
|
<button
|
||||||
setFiladeEspera(false);
|
className="btn btn-primary btn-consulta-paciente"
|
||||||
}}
|
onClick={() => {
|
||||||
style={{
|
setPageConsulta(true);
|
||||||
backgroundColor: PageNovaConsulta ? '#1d4ed8' : undefined
|
setFiladeEspera(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<i className="bi bi-plus-circle"></i> Solicitar Agendamento
|
<i className="bi bi-plus-circle"></i> Solicitar Agendamento
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="btn-adicionar-consulta"
|
className="btn btn-primary btn-consulta-paciente"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setFiladeEspera(!FiladeEspera);
|
setFiladeEspera(!FiladeEspera);
|
||||||
setPageConsulta(false);
|
setPageConsulta(false);
|
||||||
}}
|
}}
|
||||||
style={{
|
>
|
||||||
backgroundColor: FiladeEspera && !PageNovaConsulta ? '#1d4ed8' : undefined
|
<i className="bi bi-list-task me-1"></i> Fila de Espera ({filaEsperaData.length})
|
||||||
}}
|
</button>
|
||||||
>
|
</div>
|
||||||
<i className="bi bi-list-task me-1"></i> Fila de Espera ({filaEsperaData.length})
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{!PageNovaConsulta ? (
|
{!PageNovaConsulta ? (
|
||||||
<div className='atendimento-eprocura'>
|
<div className="atendimento-eprocura">
|
||||||
<section className='calendario-ou-filaespera'>
|
<section className="calendario-ou-filaespera">
|
||||||
{!FiladeEspera ? (
|
{!FiladeEspera ? (
|
||||||
<div className="calendar-wrapper">
|
<div className="calendar-wrapper">
|
||||||
<div className="calendar-info-panel">
|
<div className="calendar-info-panel">
|
||||||
<div className="info-date-display"><span>{selectedDay.format('MMM')}</span><strong>{selectedDay.format('DD')}</strong></div>
|
<div className="info-date-display">
|
||||||
<div className="info-details"><h3>{selectedDay.format('dddd')}</h3><p>{selectedDay.format('D [de] MMMM [de] YYYY')}</p></div>
|
<span>{selectedDay.format('MMM')}</span>
|
||||||
|
<strong>{selectedDay.format('DD')}</strong>
|
||||||
|
</div>
|
||||||
|
<div className="info-details">
|
||||||
|
<h3>{selectedDay.format('dddd')}</h3>
|
||||||
|
<p>{selectedDay.format('D [de] MMMM [de] YYYY')}</p>
|
||||||
|
</div>
|
||||||
<div className="appointments-list">
|
<div className="appointments-list">
|
||||||
|
<div
|
||||||
|
className="calendar-legend compact-legend"
|
||||||
|
style={{
|
||||||
|
marginTop: 4,
|
||||||
|
gap: 3,
|
||||||
|
fontSize: 8,
|
||||||
|
lineHeight: 1.1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="legend-item"
|
||||||
|
data-status="completed"
|
||||||
|
style={{ padding: '0px 5px' }}
|
||||||
|
>
|
||||||
|
Realizado
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="legend-item"
|
||||||
|
data-status="confirmed"
|
||||||
|
style={{ padding: '0px 5px' }}
|
||||||
|
>
|
||||||
|
Confirmado
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="legend-item"
|
||||||
|
data-status="agendado"
|
||||||
|
style={{ padding: '0px 5px' }}
|
||||||
|
>
|
||||||
|
Agendado
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="legend-item"
|
||||||
|
data-status="cancelled"
|
||||||
|
style={{ padding: '0px 5px' }}
|
||||||
|
>
|
||||||
|
Cancelado
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h4>Consultas para {selectedDay.format('DD/MM')}</h4>
|
<h4>Consultas para {selectedDay.format('DD/MM')}</h4>
|
||||||
{(DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')]?.length > 0) ? (
|
{DictAgendamentosOrganizados[
|
||||||
DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')].map(app => (
|
selectedDay.format('YYYY-MM-DD')
|
||||||
<div key={app.id} className="appointment-item" data-status={app.status}>
|
]?.length > 0 ? (
|
||||||
<div className="item-time">{dayjs(app.scheduled_at).format('HH:mm')}</div>
|
DictAgendamentosOrganizados[
|
||||||
|
selectedDay.format('YYYY-MM-DD')
|
||||||
|
].map((app) => (
|
||||||
|
<div
|
||||||
|
key={app.id}
|
||||||
|
className="appointment-item"
|
||||||
|
data-status={app.status}
|
||||||
|
>
|
||||||
|
<div className="item-time">
|
||||||
|
{dayjs(app.scheduled_at).add(3, 'hour').format('HH:mm')}
|
||||||
|
|
||||||
|
</div>
|
||||||
<div className="item-details">
|
<div className="item-details">
|
||||||
<span>Consulta com Dr(a). {app.medico_nome}</span>
|
<span>Consulta com Dr(a). {app.medico_nome}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className='item-actions'>
|
<div className="item-actions">
|
||||||
{app.status !== 'cancelled' && dayjs(app.scheduled_at).isAfter(dayjs()) && (
|
{app.status !== 'cancelled' &&
|
||||||
<button className="btn btn-sm btn-outline-danger" onClick={() => handleCancelClick(app.id)} title="Cancelar Consulta">
|
dayjs(app.scheduled_at).isAfter(dayjs()) && (
|
||||||
<Trash2 size={16} />
|
<button
|
||||||
</button>
|
className="btn btn-sm btn-outline-danger"
|
||||||
)}
|
onClick={() => handleCancelClick(app.id)}
|
||||||
|
title="Cancelar Consulta"
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
) : (<div className="no-appointments-info"><p>Nenhuma consulta agendada para esta data.</p></div>)}
|
) : (
|
||||||
|
<div className="no-appointments-info">
|
||||||
|
<p>Nenhuma consulta agendada para esta data.</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="calendar-main">
|
<div className="calendar-main">
|
||||||
<div className="calendar-legend">
|
<div className="calendar-legend"></div>
|
||||||
<div className="legend-item" data-status="completed">Realizado</div>
|
|
||||||
<div className="legend-item" data-status="confirmed">Confirmado</div>
|
|
||||||
<div className="legend-item" data-status="agendado">Agendado</div>
|
|
||||||
<div className="legend-item" data-status="cancelled">Cancelado</div>
|
|
||||||
</div>
|
|
||||||
<div className="calendar-controls">
|
<div className="calendar-controls">
|
||||||
<div className="date-indicator">
|
<div className="date-indicator">
|
||||||
<h2>{currentDate.format('MMMM [de] YYYY')}</h2>
|
<h2>{currentDate.format('MMMM [de] YYYY')}</h2>
|
||||||
<div className="quick-jump-controls" style={{ display: 'flex', gap: '5px', marginTop: '10px' }}>
|
<div
|
||||||
<select value={quickJump.month} onChange={(e) => handleQuickJumpChange('month', e.target.value)} className="form-select form-select-sm w-auto">
|
className="quick-jump-controls"
|
||||||
{dayjs.months().map((month, index) => (<option key={index} value={index}>{month.charAt(0).toUpperCase() + month.slice(1)}</option>))}
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: '5px',
|
||||||
|
marginTop: '10px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
value={quickJump.month}
|
||||||
|
onChange={(e) =>
|
||||||
|
handleQuickJumpChange('month', e.target.value)
|
||||||
|
}
|
||||||
|
className="form-select form-select-sm w-auto"
|
||||||
|
>
|
||||||
|
{dayjs.months().map((month, index) => (
|
||||||
|
<option key={index} value={index}>
|
||||||
|
{month.charAt(0).toUpperCase() + month.slice(1)}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
<select value={quickJump.year} onChange={(e) => handleQuickJumpChange('year', e.target.value)} className="form-select form-select-sm w-auto">
|
<select
|
||||||
{Array.from({ length: 11 }, (_, i) => dayjs().year() - 5 + i).map(year => (<option key={year} value={year}>{year}</option>))}
|
value={quickJump.year}
|
||||||
|
onChange={(e) =>
|
||||||
|
handleQuickJumpChange('year', e.target.value)
|
||||||
|
}
|
||||||
|
className="form-select form-select-sm w-auto"
|
||||||
|
>
|
||||||
|
{Array.from({ length: 11 }, (_, i) =>
|
||||||
|
dayjs().year() - 5 + i
|
||||||
|
).map((year) => (
|
||||||
|
<option key={year} value={year}>
|
||||||
|
{year}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
<button className="btn btn-sm btn-outline-primary" onClick={applyQuickJump} disabled={quickJump.month === currentDate.month() && quickJump.year === currentDate.year()}>Ir</button>
|
<button
|
||||||
|
className="btn btn-sm btn-outline-primary"
|
||||||
|
onClick={applyQuickJump}
|
||||||
|
disabled={
|
||||||
|
quickJump.month === currentDate.month() &&
|
||||||
|
quickJump.year === currentDate.year()
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Ir
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="nav-buttons">
|
<div className="nav-buttons">
|
||||||
<button onClick={() => setCurrentDate(c => c.subtract(1, 'month'))}><ChevronLeft size={20} /></button>
|
<button
|
||||||
<button onClick={() => setCurrentDate(dayjs())}>Hoje</button>
|
onClick={() => setCurrentDate((c) => c.subtract(1, 'month'))}
|
||||||
<button onClick={() => setCurrentDate(c => c.add(1, 'month'))}><ChevronRight size={20} /></button>
|
>
|
||||||
|
<ChevronLeft size={20} />
|
||||||
|
</button>
|
||||||
|
<button onClick={() => setCurrentDate(dayjs())}>
|
||||||
|
Hoje
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => setCurrentDate((c) => c.add(1, 'month'))}
|
||||||
|
>
|
||||||
|
<ChevronRight size={20} />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="calendar-grid">
|
<div className="calendar-grid">
|
||||||
{weekDays.map(day => <div key={day} className="day-header">{day}</div>)}
|
{weekDays.map((day) => (
|
||||||
|
<div key={day} className="day-header">
|
||||||
|
{day}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
{dateGrid.map((day, index) => {
|
{dateGrid.map((day, index) => {
|
||||||
const appointmentsOnDay = DictAgendamentosOrganizados[day.format('YYYY-MM-DD')] || [];
|
const appointmentsOnDay =
|
||||||
const cellClasses = `day-cell ${day.isSame(currentDate, 'month') ? 'current-month' : 'other-month'} ${day.isSame(dayjs(), 'day') ? 'today' : ''} ${day.isSame(selectedDay, 'day') ? 'selected' : ''}`;
|
DictAgendamentosOrganizados[
|
||||||
|
day.format('YYYY-MM-DD')
|
||||||
|
] || [];
|
||||||
|
const cellClasses = `day-cell ${
|
||||||
|
day.isSame(currentDate, 'month')
|
||||||
|
? 'current-month'
|
||||||
|
: 'other-month'
|
||||||
|
} ${day.isSame(dayjs(), 'day') ? 'today' : ''} ${
|
||||||
|
day.isSame(selectedDay, 'day') ? 'selected' : ''
|
||||||
|
}`;
|
||||||
return (
|
return (
|
||||||
<div key={index} className={cellClasses} onClick={() => handleDateClick(day)}>
|
<div
|
||||||
|
key={index}
|
||||||
|
className={cellClasses}
|
||||||
|
onClick={() => handleDateClick(day)}
|
||||||
|
>
|
||||||
<span>{day.format('D')}</span>
|
<span>{day.format('D')}</span>
|
||||||
{appointmentsOnDay.length > 0 && <div className="appointments-indicator">{appointmentsOnDay.length}</div>}
|
{appointmentsOnDay.length > 0 && (
|
||||||
|
<div className="appointments-indicator">
|
||||||
|
{appointmentsOnDay.length}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@ -333,233 +464,167 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="page-content table-doctor-container">
|
<div className="page-content table-paciente-container">
|
||||||
<div className="table-doctor-card">
|
<section className="row">
|
||||||
<div className="card-header">
|
<div className="col-12">
|
||||||
<h4 className="card-title mb-0">Minhas Solicitações em Fila de Espera</h4>
|
<div className="card table-paciente-card">
|
||||||
</div>
|
<div className="card-header">
|
||||||
<div className="card-body">
|
<h4 className="card-title mb-0">
|
||||||
{/* ===== FILTROS PADRONIZADOS ===== */}
|
Minhas Solicitações em Fila de Espera
|
||||||
<div className="table-doctor-filters">
|
</h4>
|
||||||
<h5 className="mb-3">
|
|
||||||
<i className="bi bi-funnel-fill me-2 text-primary"></i> Filtros
|
|
||||||
</h5>
|
|
||||||
|
|
||||||
{/* Busca */}
|
|
||||||
<div className="mb-3">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control"
|
|
||||||
placeholder="Buscar por médico..."
|
|
||||||
value={waitlistSearch}
|
|
||||||
onChange={(e) => setWaitlistSearch(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className="card-body">
|
||||||
{/* Linha de Filtros Básicos */}
|
<div className="table-responsive">
|
||||||
<div className="d-flex flex-wrap align-items-center gap-3 mb-3">
|
<table className="table table-striped table-hover">
|
||||||
{/* Ordenação */}
|
<thead>
|
||||||
<div className="d-flex align-items-center gap-2">
|
<tr>
|
||||||
<label className="form-label mb-0 text-muted small">Ordenar por:</label>
|
<th>Médico Solicitado</th>
|
||||||
<select
|
<th>Data da Solicitação</th>
|
||||||
className="form-select form-select-sm compact-select sort-select"
|
<th>Ações</th>
|
||||||
style={{ minWidth: "180px" }}
|
|
||||||
value={waitSortKey ? `${waitSortKey}-${waitSortDir}` : ''}
|
|
||||||
onChange={(e) => {
|
|
||||||
const v = e.target.value;
|
|
||||||
if (!v) {
|
|
||||||
setWaitSortKey(null);
|
|
||||||
setWaitSortDir('asc');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const [k, d] = v.split('-');
|
|
||||||
setWaitSortKey(k);
|
|
||||||
setWaitSortDir(d);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<option value="">Sem ordenação</option>
|
|
||||||
<option value="medico-asc">Médico (A-Z)</option>
|
|
||||||
<option value="medico-desc">Médico (Z-A)</option>
|
|
||||||
<option value="data-asc">Data (mais antiga)</option>
|
|
||||||
<option value="data-desc">Data (mais recente)</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Contador */}
|
|
||||||
<div className="mt-3">
|
|
||||||
<div className="contador-medicos">
|
|
||||||
{filaEsperaFiltrada.length} DE {filaEsperaData.length} SOLICITAÇÕES ENCONTRADAS
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* ===== TABELA SIMPLIFICADA ===== */}
|
|
||||||
<div className="table-responsive mt-4">
|
|
||||||
<table className="table table-striped table-hover table-doctor-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Médico Solicitado</th>
|
|
||||||
<th>Data da Solicitação</th>
|
|
||||||
<th>Ações</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{filaEsperaPaginada.length > 0 ? (
|
|
||||||
filaEsperaPaginada.map((item) => (
|
|
||||||
<tr key={item.agendamento.id}>
|
|
||||||
<td>Dr(a). {item.Infos?.medico_nome}</td>
|
|
||||||
<td>{dayjs(item.agendamento.created_at).format('DD/MM/YYYY HH:mm')}</td>
|
|
||||||
<td>
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-delete"
|
|
||||||
onClick={() => handleCancelClick(item.agendamento.id)}
|
|
||||||
>
|
|
||||||
<i className="bi bi-trash me-1"></i> Cancelar
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
))
|
</thead>
|
||||||
) : (
|
<tbody>
|
||||||
<tr>
|
{filaEsperaData.length > 0 ? (
|
||||||
<td colSpan="3" className="text-center py-4">
|
filaEsperaData.map((item) => (
|
||||||
<div className="text-muted">
|
<tr key={item.agendamento.id}>
|
||||||
<i className="bi bi-search display-4"></i>
|
<td>Dr(a). {item.Infos?.medico_nome}</td>
|
||||||
<p className="mt-2">Nenhuma solicitação na fila de espera.</p>
|
<td>
|
||||||
</div>
|
{dayjs(
|
||||||
</td>
|
item.agendamento.created_at
|
||||||
</tr>
|
).format('DD/MM/YYYY HH:mm')}
|
||||||
)}
|
</td>
|
||||||
</tbody>
|
<td>
|
||||||
</table>
|
<button
|
||||||
|
className="btn btn-sm btn-danger"
|
||||||
{/* ===== PAGINAÇÃO ===== */}
|
onClick={() =>
|
||||||
{filaEsperaFiltrada.length > 0 && (
|
handleCancelClick(item.agendamento.id)
|
||||||
<div className="d-flex justify-content-between align-items-center mt-3">
|
}
|
||||||
<div className="d-flex align-items-center">
|
>
|
||||||
<span className="me-2 text-muted">Itens por página:</span>
|
<i className="bi bi-trash me-1"></i>{' '}
|
||||||
<select
|
Cancelar
|
||||||
className="form-select form-select-sm w-auto"
|
</button>
|
||||||
value={waitPerPage}
|
</td>
|
||||||
onChange={(e) => {
|
</tr>
|
||||||
setWaitPerPage(Number(e.target.value));
|
))
|
||||||
setWaitPage(1);
|
) : (
|
||||||
}}
|
<tr>
|
||||||
>
|
<td
|
||||||
<option value={5}>5</option>
|
colSpan="3"
|
||||||
<option value={10}>10</option>
|
className="text-center py-4"
|
||||||
<option value={25}>25</option>
|
|
||||||
<option value={50}>50</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex align-items-center">
|
|
||||||
<span className="me-3 text-muted">
|
|
||||||
Página {waitPage} de {waitTotalPages} •
|
|
||||||
Mostrando {waitIndiceInicial + 1}-{Math.min(waitIndiceFinal, filaEsperaFiltrada.length)} de {filaEsperaFiltrada.length} solicitações
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<nav>
|
|
||||||
<ul className="pagination pagination-sm mb-0">
|
|
||||||
<li className={`page-item ${waitPage === 1 ? 'disabled' : ''}`}>
|
|
||||||
<button
|
|
||||||
className="page-link"
|
|
||||||
onClick={() => setWaitPage(p => Math.max(1, p - 1))}
|
|
||||||
>
|
>
|
||||||
<i className="bi bi-chevron-left"></i>
|
<div className="text-muted">
|
||||||
</button>
|
Nenhuma solicitação na fila de espera.
|
||||||
</li>
|
</div>
|
||||||
|
</td>
|
||||||
{gerarNumerosWaitPages().map(pagina => (
|
</tr>
|
||||||
<li
|
)}
|
||||||
key={pagina}
|
</tbody>
|
||||||
className={`page-item ${pagina === waitPage ? 'active' : ''}`}
|
</table>
|
||||||
>
|
|
||||||
<button
|
|
||||||
className="page-link"
|
|
||||||
onClick={() => setWaitPage(pagina)}
|
|
||||||
>
|
|
||||||
{pagina}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<li className={`page-item ${waitPage === waitTotalPages ? 'disabled' : ''}`}>
|
|
||||||
<button
|
|
||||||
className="page-link"
|
|
||||||
onClick={() => setWaitPage(p => Math.min(waitTotalPages, p + 1))}
|
|
||||||
>
|
|
||||||
<i className="bi bi-chevron-right"></i>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<AgendamentoCadastroManager setPageConsulta={setPageConsulta} />
|
<AgendamentoCadastroManager
|
||||||
|
setPageConsulta={setPageConsulta}
|
||||||
|
onSaved={() => {
|
||||||
|
carregarDados(); // recarrega consultas do paciente
|
||||||
|
setPageConsulta(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* ===== MODAL DE CANCELAMENTO ===== */}
|
|
||||||
{isCancelModalOpen && (
|
{isCancelModalOpen && (
|
||||||
<div
|
<div className="modal-overlay">
|
||||||
className="modal fade show delete-modal"
|
<div className="modal-content" style={{ maxWidth: '400px' }}>
|
||||||
style={{ display: "block", backgroundColor: "rgba(0, 0, 0, 0.5)" }}
|
<div
|
||||||
tabIndex="-1"
|
className="modal-header"
|
||||||
onClick={(e) => e.target.classList.contains("modal") && setIsCancelModalOpen(false)}
|
style={{
|
||||||
>
|
backgroundColor: '#fee2e2',
|
||||||
<div className="modal-dialog modal-dialog-centered">
|
borderBottom: '1px solid #fca5a5',
|
||||||
<div className="modal-content">
|
padding: '15px',
|
||||||
<div className="modal-header" style={{ backgroundColor: '#dc3545', color: 'white' }}>
|
borderRadius: '8px 8px 0 0',
|
||||||
<h5 className="modal-title">Confirmação de Cancelamento</h5>
|
}}
|
||||||
</div>
|
>
|
||||||
|
<h4 style={{ margin: 0, color: '#dc2626' }}>
|
||||||
<div className="modal-body">
|
Confirmação de Cancelamento
|
||||||
<p className="mb-3 fs-5">Deseja realmente cancelar esta consulta?</p>
|
</h4>
|
||||||
<p className="text-muted small mb-2">Esta ação não pode ser desfeita.</p>
|
<button
|
||||||
|
className="close-button"
|
||||||
<label className="form-label fw-bold mt-3">Motivo do cancelamento (opcional):</label>
|
onClick={() => setIsCancelModalOpen(false)}
|
||||||
<textarea
|
style={{
|
||||||
className="form-control"
|
background: 'none',
|
||||||
value={cancellationReason}
|
border: 'none',
|
||||||
onChange={(e) => setCancellationReason(e.target.value)}
|
fontSize: '1.5rem',
|
||||||
placeholder="Ex: Precisei viajar, motivo pessoal, etc."
|
cursor: 'pointer',
|
||||||
rows="4"
|
}}
|
||||||
style={{ resize: 'none' }}
|
>
|
||||||
></textarea>
|
×
|
||||||
</div>
|
</button>
|
||||||
|
</div>
|
||||||
<div className="modal-footer">
|
<div className="modal-body" style={{ padding: '20px' }}>
|
||||||
<button
|
<p>Qual o motivo do cancelamento?</p>
|
||||||
type="button"
|
<textarea
|
||||||
className="btn btn-primary"
|
value={cancellationReason}
|
||||||
onClick={() => setIsCancelModalOpen(false)}
|
onChange={(e) => setCancellationReason(e.target.value)}
|
||||||
>
|
placeholder="Ex: Precisei viajar, motivo pessoal, etc."
|
||||||
Voltar
|
rows="4"
|
||||||
</button>
|
style={{
|
||||||
|
width: '100%',
|
||||||
<button
|
padding: '10px',
|
||||||
type="button"
|
resize: 'none',
|
||||||
className="btn btn-danger"
|
border: '1px solid #ccc',
|
||||||
onClick={executeCancellation}
|
borderRadius: '4px',
|
||||||
>
|
}}
|
||||||
<i className="bi bi-trash me-1"></i> Cancelar Consulta
|
></textarea>
|
||||||
</button>
|
</div>
|
||||||
</div>
|
<div
|
||||||
|
className="modal-footer"
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'flex-end',
|
||||||
|
gap: '10px',
|
||||||
|
padding: '15px',
|
||||||
|
borderTop: '1px solid #eee',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="btn btn-secondary"
|
||||||
|
onClick={() => setIsCancelModalOpen(false)}
|
||||||
|
style={{
|
||||||
|
backgroundColor: '#6c757d',
|
||||||
|
color: 'white',
|
||||||
|
border: 'none',
|
||||||
|
padding: '8px 15px',
|
||||||
|
borderRadius: '4px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Cancelar
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-danger"
|
||||||
|
onClick={executeCancellation}
|
||||||
|
style={{
|
||||||
|
backgroundColor: '#dc3545',
|
||||||
|
color: 'white',
|
||||||
|
border: 'none',
|
||||||
|
padding: '8px 15px',
|
||||||
|
borderRadius: '4px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Trash2 size={16} style={{ marginRight: '5px' }} /> Excluir
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Agendamento;
|
export default Agendamento;
|
||||||
|
|||||||
@ -1,14 +1,71 @@
|
|||||||
|
|
||||||
/* Estilo geral do card para agrupar e dar um formato */
|
/* Estilo geral do card para agrupar e dar um formato */
|
||||||
.card-consulta {
|
.card-consulta {
|
||||||
background-color: #007bff; /* Um tom de azul padrão */
|
background-color: #007bff;
|
||||||
display: flex; /* Para colocar horário e info lado a lado */
|
display: flex;
|
||||||
border-radius: 10px; /* Cantos arredondados */
|
border-radius: 10px;
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Sombra suave */
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
overflow: hidden; /* Garante que o fundo azul não 'vaze' */
|
overflow: hidden;
|
||||||
/* width: 280px; /* Largura de exemplo */
|
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
font-family: Arial, sans-serif; /* Fonte legível */
|
font-family: Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.card-consulta {
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.horario-container {
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: 1px solid #0056b3;
|
||||||
|
padding: 10px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.horario {
|
||||||
|
font-size: 1.8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-container {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions-container {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
background: none;
|
||||||
|
backdrop-filter: none;
|
||||||
|
-webkit-backdrop-filter: none;
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
margin-left: 0;
|
||||||
|
padding: 0;
|
||||||
|
justify-content: flex-start;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-consulta:hover .actions-container {
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.horario {
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.informacao {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-edit-custom-style,
|
||||||
|
.btn-delete-custom-style {
|
||||||
|
padding: 6px 10px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 1. Estilo para o Horário (Fundo Azul e Texto Branco/Grande) */
|
/* 1. Estilo para o Horário (Fundo Azul e Texto Branco/Grande) */
|
||||||
|
|||||||
@ -6,98 +6,156 @@ import { GetAllDoctors } from "../utils/Functions-Endpoints/Doctor";
|
|||||||
import { useAuth } from "../utils/AuthProvider";
|
import { useAuth } from "../utils/AuthProvider";
|
||||||
import API_KEY from "../utils/apiKeys";
|
import API_KEY from "../utils/apiKeys";
|
||||||
|
|
||||||
|
|
||||||
const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) => {
|
const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) => {
|
||||||
const { getAuthorizationHeader } = useAuth();
|
const { getAuthorizationHeader } = useAuth();
|
||||||
|
|
||||||
const [sessoes, setSessoes] = useState(1);
|
const [sessoes, setSessoes] = useState(1);
|
||||||
const [tempoBaseConsulta] = useState(30);
|
const [tempoBaseConsulta] = useState(30);
|
||||||
const [showSuccessModal, setShowSuccessModal] = useState(false);
|
const [horarioInicio, setHorarioInicio] = useState("");
|
||||||
|
const [horarioTermino, setHorarioTermino] = useState("");
|
||||||
|
const [horariosDisponiveis, sethorariosDisponiveis] = useState([]);
|
||||||
|
const [status, setStatus] = useState(agendamento?.status || "confirmed");
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
const [todosProfissionais, setTodosProfissionais] = useState([]);
|
const [todosProfissionais, setTodosProfissionais] = useState([]);
|
||||||
const [profissionaisFiltrados, setProfissionaisFiltrados] = useState([]);
|
const [profissionaisFiltrados, setProfissionaisFiltrados] = useState([]);
|
||||||
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
||||||
const [horarioInicio, setHorarioInicio] = useState('');
|
|
||||||
const [horarioTermino, setHorarioTermino] = useState('');
|
|
||||||
const [horariosDisponiveis, sethorariosDisponiveis] = useState([]);
|
|
||||||
|
|
||||||
const [todosPacientes, setTodosPacientes] = useState([])
|
const [todosPacientes, setTodosPacientes] = useState([]);
|
||||||
const [pacientesFiltrados, setPacientesFiltrados] = useState([])
|
const [pacientesFiltrados, setPacientesFiltrados] = useState([]);
|
||||||
const [isDropdownPacienteOpen, setIsDropdownPacienteOpen] = useState(false)
|
const [isDropdownPacienteOpen, setIsDropdownPacienteOpen] = useState(false);
|
||||||
|
|
||||||
const [status, setStatus] = useState("confirmed")
|
const authHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
let authHeader = getAuthorizationHeader()
|
|
||||||
|
|
||||||
const FormatCPF = (valor) => {
|
const FormatCPF = (valor) => {
|
||||||
const digits = String(valor).replace(/\D/g, '').slice(0, 11);
|
const digits = String(valor).replace(/\D/g, "").slice(0, 11);
|
||||||
return digits
|
return digits
|
||||||
.replace(/(\d{3})(\d)/, '$1.$2')
|
.replace(/(\d{3})(\d)/, "$1.$2")
|
||||||
.replace(/(\d{3})(\d)/, '$1.$2')
|
.replace(/(\d{3})(\d)/, "$1.$2")
|
||||||
.replace(/(\d{3})(\d{1,2})$/, '$1-$2');
|
.replace(/(\d{3})(\d{1,2})$/, "$1-$2");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
const { value, name } = e.target;
|
const { value, name } = e.target;
|
||||||
|
|
||||||
if (name === 'email') {
|
if (name === "email") {
|
||||||
setAgendamento(prev => ({
|
setAgendamento((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
contato: { ...prev.contato, email: value }
|
contato: {
|
||||||
|
...(prev.contato || {}),
|
||||||
|
email: value,
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
} else if (name === 'status') {
|
} else if (name === "status") {
|
||||||
setAgendamento(prev => ({
|
setAgendamento((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
status: prev.status === 'requested' ? 'confirmed' : 'requested'
|
status: prev.status === "requested" ? "confirmed" : "requested",
|
||||||
}));
|
}));
|
||||||
} else if (name === 'paciente_cpf') {
|
setStatus((prev) => (prev === "confirmed" ? "requested" : "confirmed"));
|
||||||
|
} else if (name === "paciente_cpf") {
|
||||||
const cpfFormatted = FormatCPF(value);
|
const cpfFormatted = FormatCPF(value);
|
||||||
const fetchPatient = async () => {
|
const fetchPatient = async () => {
|
||||||
const patientData = await GetPatientByCPF(cpfFormatted, authHeader);
|
const patientData = await GetPatientByCPF(cpfFormatted, authHeader);
|
||||||
if (patientData) {
|
if (patientData) {
|
||||||
setAgendamento(prev => ({
|
setAgendamento((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
paciente_nome: patientData.full_name,
|
paciente_nome: patientData.full_name,
|
||||||
patient_id: patientData.id
|
patient_id: patientData.id,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setAgendamento(prev => ({ ...prev, paciente_cpf: cpfFormatted }));
|
setAgendamento((prev) => ({ ...prev, paciente_cpf: cpfFormatted }));
|
||||||
fetchPatient();
|
fetchPatient();
|
||||||
} else if (name === 'convenio') {
|
} else if (name === "convenio") {
|
||||||
setAgendamento(prev => ({ ...prev, insurance_provider: value }));
|
setAgendamento((prev) => ({ ...prev, insurance_provider: value }));
|
||||||
} else {
|
} else {
|
||||||
setAgendamento(prev => ({ ...prev, [name]: value }));
|
setAgendamento((prev) => ({ ...prev, [name]: value }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ChamarMedicos = useCallback(async () => {
|
const ChamarMedicos = useCallback(async () => {
|
||||||
const Medicos = await GetAllDoctors(authHeader);
|
const Medicos = await GetAllDoctors(authHeader);
|
||||||
setTodosProfissionais(Medicos);
|
setTodosProfissionais(Medicos || []);
|
||||||
}, [authHeader]);
|
}, [authHeader]);
|
||||||
|
|
||||||
const ChamarPacientes = useCallback (async () => {
|
const ChamarPacientes = useCallback(async () => {
|
||||||
const Pacientes = await GetAllPatients(authHeader);
|
const Pacientes = await GetAllPatients(authHeader);
|
||||||
setTodosPacientes(Pacientes)
|
setTodosPacientes(Pacientes || []);
|
||||||
console.log("pacientes")
|
}, [authHeader]);
|
||||||
console.log(Pacientes)
|
|
||||||
}, [authHeader])
|
// AUTOCOMPLETE PACIENTE
|
||||||
|
const handleSearchPaciente = (e) => {
|
||||||
|
const term = e.target.value;
|
||||||
|
setAgendamento((prev) => ({ ...prev, paciente_nome: term }));
|
||||||
|
|
||||||
|
if (term.trim() === "") {
|
||||||
|
setPacientesFiltrados([]);
|
||||||
|
setIsDropdownPacienteOpen(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const filtered = todosPacientes.filter((p) =>
|
||||||
|
p.full_name.toLowerCase().includes(term.toLowerCase())
|
||||||
|
);
|
||||||
|
|
||||||
|
setPacientesFiltrados(filtered);
|
||||||
|
setIsDropdownPacienteOpen(filtered.length > 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectPaciente = (paciente) => {
|
||||||
|
setAgendamento((prev) => ({
|
||||||
|
...prev,
|
||||||
|
patient_id: paciente.id,
|
||||||
|
paciente_nome: paciente.full_name,
|
||||||
|
paciente_cpf: paciente.cpf,
|
||||||
|
}));
|
||||||
|
setPacientesFiltrados([]);
|
||||||
|
setIsDropdownPacienteOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
// AUTOCOMPLETE PROFISSIONAL
|
||||||
|
const handleSearchProfissional = (e) => {
|
||||||
|
const term = e.target.value;
|
||||||
|
handleChange(e);
|
||||||
|
|
||||||
|
if (term.trim() === "") {
|
||||||
|
setProfissionaisFiltrados([]);
|
||||||
|
setIsDropdownOpen(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const filtered = todosProfissionais.filter((p) =>
|
||||||
|
p.full_name.toLowerCase().includes(term.toLowerCase())
|
||||||
|
);
|
||||||
|
|
||||||
|
setProfissionaisFiltrados(filtered);
|
||||||
|
setIsDropdownOpen(filtered.length > 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectProfissional = (profissional) => {
|
||||||
|
setAgendamento((prev) => ({
|
||||||
|
...prev,
|
||||||
|
doctor_id: profissional.id,
|
||||||
|
nome_medico: profissional.full_name,
|
||||||
|
}));
|
||||||
|
setProfissionaisFiltrados([]);
|
||||||
|
setIsDropdownOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatarHora = (datetimeString) => {
|
||||||
|
return datetimeString?.substring(11, 16) || "";
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (agendamento?.scheduled_at) {
|
||||||
|
setHorarioInicio(formatarHora(agendamento.scheduled_at));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
console.log("Horario","tessssste" )
|
useEffect(() => {
|
||||||
if (agendamento?.scheduled_at) {
|
|
||||||
setHorarioInicio(formatarHora(agendamento.scheduled_at));
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
ChamarMedicos();
|
ChamarMedicos();
|
||||||
}, [ChamarMedicos]);
|
ChamarPacientes();
|
||||||
|
}, [ChamarMedicos, ChamarPacientes]);
|
||||||
useEffect(() => {
|
|
||||||
|
|
||||||
ChamarPacientes()
|
|
||||||
}, [ChamarPacientes])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!agendamento.dataAtendimento || !agendamento.doctor_id) return;
|
if (!agendamento.dataAtendimento || !agendamento.doctor_id) return;
|
||||||
@ -105,7 +163,7 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
const myHeaders = new Headers();
|
const myHeaders = new Headers();
|
||||||
myHeaders.append("Content-Type", "application/json");
|
myHeaders.append("Content-Type", "application/json");
|
||||||
myHeaders.append("apikey", API_KEY);
|
myHeaders.append("apikey", API_KEY);
|
||||||
myHeaders.append("Authorization", `Bearer ${authHeader.split(' ')[1]}`);
|
myHeaders.append("Authorization", `Bearer ${authHeader.split(" ")[1]}`);
|
||||||
|
|
||||||
const raw = JSON.stringify({
|
const raw = JSON.stringify({
|
||||||
doctor_id: agendamento.doctor_id,
|
doctor_id: agendamento.doctor_id,
|
||||||
@ -114,321 +172,304 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
headers: myHeaders,
|
headers: myHeaders,
|
||||||
body: raw,
|
body: raw,
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/functions/v1/get-available-slots", requestOptions)
|
fetch(
|
||||||
.then(response => response.json())
|
"https://yuanqfswhberkoevtmfr.supabase.co/functions/v1/get-available-slots",
|
||||||
.then(result => sethorariosDisponiveis(result))
|
requestOptions
|
||||||
.catch(error => console.log('error', error));
|
)
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((result) => {
|
||||||
|
sethorariosDisponiveis(result);
|
||||||
|
})
|
||||||
|
.catch((error) => console.log("error", error));
|
||||||
}, [agendamento.dataAtendimento, agendamento.doctor_id, authHeader]);
|
}, [agendamento.dataAtendimento, agendamento.doctor_id, authHeader]);
|
||||||
|
|
||||||
const handleSearchProfissional = (e) => {
|
const slotsArray = Array.isArray(horariosDisponiveis)
|
||||||
const term = e.target.value;
|
? horariosDisponiveis
|
||||||
handleChange(e);
|
: horariosDisponiveis?.slots || [];
|
||||||
|
|
||||||
if (term.trim() === '') {
|
const opcoesDeHorario = slotsArray.map((item) => ({
|
||||||
setProfissionaisFiltrados([]);
|
|
||||||
setIsDropdownOpen(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filtered = todosProfissionais.filter(p =>
|
|
||||||
p.full_name.toLowerCase().includes(term.toLowerCase())
|
|
||||||
);
|
|
||||||
|
|
||||||
setProfissionaisFiltrados(filtered);
|
|
||||||
setIsDropdownOpen(filtered.length > 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSearchPaciente = (e) => {
|
|
||||||
const term = e.target.value;
|
|
||||||
handleChange(e);
|
|
||||||
|
|
||||||
if (term.trim() === '') {
|
|
||||||
setPacientesFiltrados([]);
|
|
||||||
setIsDropdownPacienteOpen(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filtered = todosPacientes.filter(p =>
|
|
||||||
p.full_name.toLowerCase().includes(term.toLowerCase())
|
|
||||||
);
|
|
||||||
console.log(filtered.length > 0, "filtrados")
|
|
||||||
|
|
||||||
setPacientesFiltrados(filtered);
|
|
||||||
setIsDropdownPacienteOpen(filtered.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSelectProfissional = (profissional) => {
|
|
||||||
setAgendamento(prev => ({
|
|
||||||
...prev,
|
|
||||||
doctor_id: profissional.id,
|
|
||||||
nome_medico: profissional.full_name
|
|
||||||
}));
|
|
||||||
setProfissionaisFiltrados([]);
|
|
||||||
setIsDropdownOpen(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSelectPaciente = (paciente) => {
|
|
||||||
setAgendamento(prev => ({
|
|
||||||
...prev,
|
|
||||||
patient_id:paciente.id,
|
|
||||||
paciente_nome: paciente.full_name,
|
|
||||||
paciente_cpf: paciente.cpf
|
|
||||||
}))
|
|
||||||
setProfissionaisFiltrados([])
|
|
||||||
setIsDropdownPacienteOpen(false)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatarHora = (datetimeString) => {
|
|
||||||
return datetimeString?.substring(11, 16) || '';
|
|
||||||
};
|
|
||||||
|
|
||||||
const opcoesDeHorario = horariosDisponiveis?.slots?.map(item => ({
|
|
||||||
value: formatarHora(item.datetime),
|
value: formatarHora(item.datetime),
|
||||||
label: formatarHora(item.datetime),
|
label: formatarHora(item.datetime),
|
||||||
disabled: !item.available
|
disabled: !item.available,
|
||||||
})) || [];
|
}));
|
||||||
|
|
||||||
const calcularHorarioTermino = useCallback((inicio, sessoes, tempoBase) => {
|
const calcularHorarioTermino = useCallback((inicio, sessoesParam, tempoBase) => {
|
||||||
if (!inicio || inicio.length !== 5 || !inicio.includes(':')) return '';
|
if (!inicio || inicio.length !== 5 || !inicio.includes(":")) return "";
|
||||||
|
|
||||||
const [horas, minutos] = inicio.split(':').map(Number);
|
const [horas, minutos] = inicio.split(":").map(Number);
|
||||||
const minutosInicio = (horas * 60) + minutos;
|
const minutosInicio = horas * 60 + minutos;
|
||||||
const duracaoTotalMinutos = sessoes * tempoBase;
|
const duracaoTotalMinutos = sessoesParam * tempoBase;
|
||||||
const minutosTermino = minutosInicio + duracaoTotalMinutos;
|
const minutosTermino = minutosInicio + duracaoTotalMinutos;
|
||||||
|
|
||||||
const horaTermino = Math.floor(minutosTermino / 60) % 24;
|
const horaTermino = Math.floor(minutosTermino / 60) % 24;
|
||||||
const minutoTermino = minutosTermino % 60;
|
const minutoTermino = minutosTermino % 60;
|
||||||
|
|
||||||
const formatar = (num) => String(num).padStart(2, '0');
|
const formatar = (num) => String(num).padStart(2, "0");
|
||||||
return `${formatar(horaTermino)}:${formatar(minutoTermino)}`;
|
return `${formatar(horaTermino)}:${formatar(minutoTermino)}`;
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const novoTermino = calcularHorarioTermino(horarioInicio, sessoes, tempoBaseConsulta);
|
const novoTermino = calcularHorarioTermino(
|
||||||
|
horarioInicio,
|
||||||
|
sessoes,
|
||||||
|
tempoBaseConsulta
|
||||||
|
);
|
||||||
|
|
||||||
setHorarioTermino(novoTermino);
|
setHorarioTermino(novoTermino);
|
||||||
setAgendamento(prev => ({
|
setAgendamento((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
horarioTermino: novoTermino
|
horarioTermino: novoTermino,
|
||||||
}));
|
}));
|
||||||
}, [horarioInicio, sessoes, tempoBaseConsulta, setAgendamento, calcularHorarioTermino]);
|
}, [horarioInicio, sessoes, tempoBaseConsulta, calcularHorarioTermino, setAgendamento]);
|
||||||
|
|
||||||
const handleSubmit = (e) => {
|
const handleSubmit = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setShowSuccessModal(true);
|
if (isSubmitting) return;
|
||||||
};
|
|
||||||
|
|
||||||
const handleCloseModal = () => {
|
if (
|
||||||
setShowSuccessModal(false);
|
!agendamento.doctor_id ||
|
||||||
onSave({ ...agendamento, horarioInicio: horarioInicio, status:status });
|
!agendamento.patient_id ||
|
||||||
|
!agendamento.dataAtendimento ||
|
||||||
|
!horarioInicio
|
||||||
|
) {
|
||||||
|
alert(
|
||||||
|
"Por favor, preencha o profissional, paciente, data e horário de início."
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSubmitting(true);
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
...agendamento,
|
||||||
|
horarioInicio,
|
||||||
|
status,
|
||||||
|
duration_minutes: sessoes * tempoBaseConsulta,
|
||||||
|
};
|
||||||
|
|
||||||
|
onSave?.(payload);
|
||||||
|
setIsSubmitting(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCheckbox = () => {
|
const handleCheckbox = () => {
|
||||||
if(status === "confirmed"){
|
if (status === "confirmed") {
|
||||||
setStatus("requested")
|
setStatus("requested");
|
||||||
}else{
|
setAgendamento((prev) => ({ ...prev, status: "requested" }));
|
||||||
setStatus("confirmed")
|
} else {
|
||||||
|
setStatus("confirmed");
|
||||||
|
setAgendamento((prev) => ({ ...prev, status: "confirmed" }));
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
return (
|
||||||
|
<div className="form-container">
|
||||||
|
<form className="form-agendamento" onSubmit={handleSubmit}>
|
||||||
|
<h2 className="section-title">Informações do paciente</h2>
|
||||||
|
|
||||||
return (<div className="form-container">
|
<div
|
||||||
{showSuccessModal && (
|
className="campos-informacoes-paciente"
|
||||||
<div className="modal-overlay">
|
id="informacoes-paciente-linha-um"
|
||||||
<div className="modal-content">
|
>
|
||||||
<div className="modal-header">
|
<div className="campo-de-input-container">
|
||||||
<h5 className="modal-title">Sucesso</h5>
|
<div className="campo-de-input">
|
||||||
</div>
|
<label>Nome *</label>
|
||||||
<div className="modal-body">
|
<input
|
||||||
<p className="modal-message">Agendamento salvo com sucesso!</p>
|
type="text"
|
||||||
</div>
|
name="paciente_nome"
|
||||||
<div className="modal-footer">
|
value={agendamento.paciente_nome || ""}
|
||||||
<button onClick={handleCloseModal} className="modal-confirm-btn">Fechar</button>
|
placeholder="Insira o nome do paciente"
|
||||||
</div>
|
required
|
||||||
</div>
|
onChange={handleSearchPaciente}
|
||||||
</div>
|
autoComplete="off"
|
||||||
)}
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form className="form-agendamento" onSubmit={handleSubmit}>
|
<div className="campo-de-input">
|
||||||
<h2 className="section-title">Informações do paciente</h2>
|
<label>CPF do paciente</label>
|
||||||
|
<InputMask
|
||||||
|
mask="999.999.999-99"
|
||||||
|
maskChar={null}
|
||||||
|
type="text"
|
||||||
|
name="paciente_cpf"
|
||||||
|
placeholder="000.000.000-00"
|
||||||
|
value={agendamento.paciente_cpf || ""}
|
||||||
|
onChange={handleChange}
|
||||||
|
autoComplete="off"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="campos-informacoes-paciente" id="informacoes-paciente-linha-um">
|
{isDropdownPacienteOpen && pacientesFiltrados.length > 0 && (
|
||||||
<div className="campo-de-input-container">
|
<div className="dropdown-pacientes">
|
||||||
<div className="campo-de-input">
|
{pacientesFiltrados.map((paciente) => (
|
||||||
<label>Nome *</label>
|
<div
|
||||||
<input
|
key={paciente.id}
|
||||||
type="text"
|
className="dropdown-item"
|
||||||
name="paciente_nome"
|
onClick={() => handleSelectPaciente(paciente)}
|
||||||
placeholder="Insira o nome do paciente"
|
>
|
||||||
required
|
{`${paciente.full_name} - ${paciente.cpf}`}
|
||||||
onChange={(e) => handleSearchPaciente(e)}
|
</div>
|
||||||
value={agendamento?.paciente_nome || ""}
|
))}
|
||||||
autoComplete="off"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{isDropdownPacienteOpen && pacientesFiltrados.length > 0 && (
|
|
||||||
<div className="dropdown-pacientes">
|
|
||||||
{pacientesFiltrados.map((paciente) => (
|
|
||||||
<div
|
|
||||||
key={paciente.id}
|
|
||||||
className="dropdown-item"
|
|
||||||
onClick={() => handleSelectPaciente(paciente)}
|
|
||||||
>
|
|
||||||
{`${paciente.full_name.split(" ")[0]} ${paciente.full_name.split(" ")[1]} - ${paciente.cpf}`}
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="campo-de-input campo-cpf">
|
<div
|
||||||
<label>CPF do paciente</label>
|
className="campos-informacoes-paciente"
|
||||||
<input
|
id="informacoes-paciente-linha-tres"
|
||||||
type="text"
|
>
|
||||||
name="paciente_cpf"
|
<div>
|
||||||
placeholder="000.000.000-00"
|
<label>Convênio</label>
|
||||||
onChange={handleChange}
|
|
||||||
value={agendamento.paciente_cpf}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="campos-informacoes-paciente" id="informacoes-paciente-linha-tres">
|
|
||||||
<div>
|
|
||||||
<label>Convênio</label>
|
|
||||||
<select name="convenio" onChange={handleChange} value={agendamento.insurance_provider}>
|
|
||||||
<option value="publico">Público</option>
|
|
||||||
<option value="unimed">Unimed</option>
|
|
||||||
<option value="bradesco_saude">Bradesco Saúde</option>
|
|
||||||
<option value="hapvida">Hapvida</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2 className="section-title">Informações do atendimento</h2>
|
|
||||||
|
|
||||||
<div className="campo-informacoes-atendimento">
|
|
||||||
<div className="campo-de-input-container">
|
|
||||||
<div className="campo-de-input">
|
|
||||||
<label>Nome do profissional *</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="nome_medico"
|
|
||||||
onChange={handleSearchProfissional}
|
|
||||||
value={agendamento?.nome_medico || ''}
|
|
||||||
autoComplete="off"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{isDropdownOpen && profissionaisFiltrados.length > 0 && (
|
|
||||||
<div className="dropdown-profissionais">
|
|
||||||
{profissionaisFiltrados.map((profissional) => (
|
|
||||||
<div
|
|
||||||
key={profissional.id}
|
|
||||||
className="dropdown-item"
|
|
||||||
onClick={() => handleSelectProfissional(profissional)}
|
|
||||||
>
|
|
||||||
{profissional.full_name}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="tipo_atendimento">
|
|
||||||
<label>Tipo de atendimento *</label>
|
|
||||||
<select name="tipo_atendimento" onChange={handleChange} value={agendamento.tipo_atendimento}>
|
|
||||||
<option value="presencial">Presencial</option>
|
|
||||||
<option value="teleconsulta">Teleconsulta</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section id="informacoes-atendimento-segunda-linha">
|
|
||||||
<div className="campo-informacoes-atendimento">
|
|
||||||
<div className="campo-de-input">
|
|
||||||
<label>Data *</label>
|
|
||||||
<input
|
|
||||||
type="date"
|
|
||||||
name="dataAtendimento"
|
|
||||||
onChange={handleChange}
|
|
||||||
value={agendamento.dataAtendimento}
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="linha">
|
|
||||||
<div className="campo-de-input">
|
|
||||||
<label htmlFor="inicio">Início *</label>
|
|
||||||
<select
|
<select
|
||||||
id="inicio"
|
name="convenio"
|
||||||
name="inicio"
|
onChange={handleChange}
|
||||||
required
|
value={agendamento.insurance_provider || "publico"}
|
||||||
value={horarioInicio}
|
|
||||||
onChange={(e) => setHorarioInicio(e.target.value)}
|
|
||||||
>
|
>
|
||||||
<option value="" disabled>Selecione a hora de início</option>
|
<option value="publico">Público</option>
|
||||||
{opcoesDeHorario.map((opcao, index) => (
|
<option value="unimed">Unimed</option>
|
||||||
<option key={index} value={opcao.value} disabled={opcao.disabled}>
|
<option value="bradesco_saude">Bradesco Saúde</option>
|
||||||
{opcao.label}
|
<option value="hapvida">Hapvida</option>
|
||||||
{opcao.disabled && " (Indisponível)"}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="campo-de-input">
|
<h2 className="section-title">Informações do atendimento</h2>
|
||||||
<label htmlFor="termino">Término *</label>
|
|
||||||
<input
|
<div className="campo-informacoes-atendimento">
|
||||||
type="text"
|
<div className="campo-de-input-container">
|
||||||
id="termino"
|
<div className="campo-de-input">
|
||||||
name="termino"
|
<label>Nome do profissional *</label>
|
||||||
value={horarioTermino || '— —'}
|
<input
|
||||||
readOnly
|
type="text"
|
||||||
className="horario-termino-readonly"
|
name="nome_medico"
|
||||||
/>
|
onChange={handleSearchProfissional}
|
||||||
|
value={agendamento?.nome_medico || ""}
|
||||||
|
autoComplete="off"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isDropdownOpen && profissionaisFiltrados.length > 0 && (
|
||||||
|
<div className="dropdown-profissionais">
|
||||||
|
{profissionaisFiltrados.map((profissional) => (
|
||||||
|
<div
|
||||||
|
key={profissional.id}
|
||||||
|
className="dropdown-item"
|
||||||
|
onClick={() => handleSelectProfissional(profissional)}
|
||||||
|
>
|
||||||
|
{profissional.full_name}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="tipo_atendimento">
|
||||||
|
<label>Tipo de atendimento *</label>
|
||||||
|
<select
|
||||||
|
name="tipo_atendimento"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={agendamento.tipo_atendimento || "presencial"}
|
||||||
|
>
|
||||||
|
<option value="presencial">Presencial</option>
|
||||||
|
<option value="teleconsulta">Teleconsulta</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="campo-de-input observacoes">
|
<section id="informacoes-atendimento-segunda-linha">
|
||||||
<label>Observações</label>
|
<section id="informacoes-atendimento-segunda-linha-esquerda">
|
||||||
<textarea
|
<div className="campo-informacoes-atendimento">
|
||||||
name="observacoes"
|
<div className="campo-de-input">
|
||||||
rows="4"
|
<label>Data *</label>
|
||||||
cols="1"
|
<input
|
||||||
onChange={handleChange}
|
type="date"
|
||||||
value={agendamento.observacoes || ''}
|
name="dataAtendimento"
|
||||||
/>
|
onChange={handleChange}
|
||||||
</div>
|
value={agendamento.dataAtendimento || ""}
|
||||||
</section>
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="campo-de-input-check">
|
<div className="linha">
|
||||||
<input
|
<div className="campo-de-input">
|
||||||
className="form-check-input form-custom-check"
|
<label htmlFor="inicio">Início *</label>
|
||||||
type="checkbox"
|
<select
|
||||||
name="status"
|
id="inicio"
|
||||||
onChange={handleCheckbox}
|
name="inicio"
|
||||||
checked={status === "requested"}
|
value={horarioInicio}
|
||||||
/>
|
onChange={(e) => setHorarioInicio(e.target.value)}
|
||||||
<label className="form-check-label checkbox-label" htmlFor="status">
|
required
|
||||||
Adicionar à fila de espera
|
>
|
||||||
</label>
|
<option value="" disabled>
|
||||||
|
Selecione a hora de início
|
||||||
|
</option>
|
||||||
|
{opcoesDeHorario.map((opcao, index) => (
|
||||||
|
<option
|
||||||
|
key={index}
|
||||||
|
value={opcao.value}
|
||||||
|
disabled={opcao.disabled}
|
||||||
|
>
|
||||||
|
{opcao.label}
|
||||||
|
{opcao.disabled && " (Indisponível)"}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="campo-de-input">
|
||||||
|
<label htmlFor="termino">Término *</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="termino"
|
||||||
|
name="termino"
|
||||||
|
value={horarioTermino || "— —"}
|
||||||
|
readOnly
|
||||||
|
className="horario-termino-readonly"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className="informacoes-atendimento-segunda-linha-direita">
|
||||||
|
<div className="campo-de-input">
|
||||||
|
<label>Observações</label>
|
||||||
|
<textarea
|
||||||
|
name="observacoes"
|
||||||
|
rows="4"
|
||||||
|
cols="1"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={agendamento.observacoes || ""}
|
||||||
|
></textarea>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div className="form-actions">
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn-primary"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{isSubmitting ? "Salvando..." : "Salvar agendamento"}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-cancel"
|
||||||
|
onClick={onCancel}
|
||||||
|
>
|
||||||
|
Cancelar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-actions">
|
|
||||||
<button type="submit" className="btn-primary">Salvar agendamento</button>
|
|
||||||
<button type="button" className="btn-cancel" onClick={onCancel}>Cancelar</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
@media (max-width: 768px) {
|
||||||
|
.container-cardconsulta {
|
||||||
|
padding-right: 80px; /* Espaço para os botões */
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.actions-container {
|
.actions-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
@ -85,3 +92,49 @@
|
|||||||
width: 24rem;
|
width: 24rem;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.actions-container {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
background: none;
|
||||||
|
backdrop-filter: none;
|
||||||
|
-webkit-backdrop-filter: none;
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
margin-left: 0;
|
||||||
|
padding: 0;
|
||||||
|
justify-content: flex-end;
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-cardconsulta:hover .actions-container {
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabelamensal .container-cardconsulta {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.container-cardconsulta {
|
||||||
|
padding-right: 10px; /* Remove o padding extra para telas muito pequenas */
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions-container {
|
||||||
|
position: static;
|
||||||
|
margin-top: 10px;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-edit-custom-style,
|
||||||
|
.btn-delete-custom-style,
|
||||||
|
.btn-confirm-style {
|
||||||
|
padding: 6px 10px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -183,6 +183,67 @@ textarea{
|
|||||||
gap: 16px;
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.campos-informacoes-paciente,
|
||||||
|
.campo-informacoes-atendimento {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#informacoes-atendimento-segunda-linha {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#informacoes-atendimento-segunda-linha-esquerda select[name="unidade"],
|
||||||
|
input[type="time"],
|
||||||
|
select[name=solicitante],
|
||||||
|
.campo-de-input {
|
||||||
|
width: 100% !important;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tipo_atendimento {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.linha {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sessao-contador {
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.form-container {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-title {
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-agendamento input,
|
||||||
|
.form-agendamento select,
|
||||||
|
.form-agendamento textarea {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary,
|
||||||
|
.btn-cancel {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.campo-de-input {
|
.campo-de-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -690,3 +751,93 @@ input[name="paciente_cpf"]{
|
|||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
#informacoes-atendimento-segunda-linha .linha-horarios {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: flex-end; /* alinha pela base dos inputs */
|
||||||
|
}
|
||||||
|
|
||||||
|
#informacoes-atendimento-segunda-linha .linha-horarios .campo-de-input {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.campo-de-input-container {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px; /* nome e cpf na mesma linha */
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo-de-input {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo-de-input label {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo-de-input input,
|
||||||
|
.campo-de-input select,
|
||||||
|
.campo-de-input textarea {
|
||||||
|
width: 220px; /* ajuste pro layout que você quer */
|
||||||
|
padding: 6px 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* placeholder visível e suave */
|
||||||
|
.campo-de-input input::placeholder {
|
||||||
|
color: #999;
|
||||||
|
opacity: 1; /* garante no Firefox */
|
||||||
|
}
|
||||||
|
/* bloco da coluna esquerda (Data, Início, Término) */
|
||||||
|
#informacoes-atendimento-segunda-linha-esquerda {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* linha com Início e Término */
|
||||||
|
#informacoes-atendimento-segunda-linha-esquerda .linha {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mesma largura pros três campos */
|
||||||
|
#informacoes-atendimento-segunda-linha-esquerda .campo-de-input input,
|
||||||
|
#informacoes-atendimento-segunda-linha-esquerda .campo-de-input select {
|
||||||
|
width: 230px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.informacoes-atendimento-segunda-linha-direita {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.informacoes-atendimento-segunda-linha-direita .campo-de-input textarea {
|
||||||
|
width: 100%; /* ocupa toda a coluna da direita */
|
||||||
|
min-height: 150px; /* aumenta a altura (muda pra 200, 250 se quiser maior) */
|
||||||
|
resize: vertical;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
#informacoes-atendimento-segunda-linha {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto 1.8fr; /* coluna da direita grande, mas não infinita */
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* garante que o container da direita não estoure */
|
||||||
|
.informacoes-atendimento-segunda-linha-direita {
|
||||||
|
max-width: 800px; /* ajusta se quiser menor/maior */
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.informacoes-atendimento-segunda-linha-direita .campo-de-input textarea {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 150px;
|
||||||
|
resize: vertical;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|||||||
@ -259,18 +259,6 @@
|
|||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Estilo para o item Início para ficar com borda semelhante aos blocos */
|
|
||||||
.inicio-item .sidebar-link {
|
|
||||||
border: 1px solid var(--toggle-border);
|
|
||||||
border-radius: 8px;
|
|
||||||
background: var(--toggle-bg);
|
|
||||||
padding: 10px 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inicio-item .sidebar-link:hover {
|
|
||||||
background-color: var(--toggle-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.logout-button {
|
.logout-button {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@ -223,6 +223,8 @@
|
|||||||
z-index: 2001;
|
z-index: 2001;
|
||||||
margin-top: 80px;
|
margin-top: 80px;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
|
/* Adicionado para responsividade */
|
||||||
|
max-width: 90vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.suporte-card {
|
.suporte-card {
|
||||||
@ -309,6 +311,8 @@
|
|||||||
z-index: 3001;
|
z-index: 3001;
|
||||||
margin-top: 80px;
|
margin-top: 80px;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
|
/* Adicionado para responsividade */
|
||||||
|
max-width: 90vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-online {
|
.chat-online {
|
||||||
@ -462,6 +466,81 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Responsividade */
|
/* Responsividade */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.header-container {
|
||||||
|
padding: 10px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-corner-elements {
|
||||||
|
gap: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-picture-container {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.suporte-card-container,
|
||||||
|
.chat-container {
|
||||||
|
margin-top: 60px;
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.suporte-card,
|
||||||
|
.chat-online {
|
||||||
|
width: calc(100vw - 20px);
|
||||||
|
max-width: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.header-container {
|
||||||
|
padding: 8px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-corner-elements {
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-picture-container {
|
||||||
|
width: 35px;
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phone-icon-container {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.suporte-card-container,
|
||||||
|
.chat-container {
|
||||||
|
margin-top: 50px;
|
||||||
|
margin-right: 5px;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.suporte-card {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-online {
|
||||||
|
width: calc(100vw - 10px);
|
||||||
|
height: 80vh; /* Limita a altura para telas pequenas */
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-input {
|
||||||
|
padding: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-campo {
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-enviar {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.header-container {
|
.header-container {
|
||||||
padding: 10px 15px;
|
padding: 10px 15px;
|
||||||
@ -525,31 +604,3 @@
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Avatar Styles */
|
|
||||||
.profile-avatar-image {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
border-radius: 50%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
.profile-placeholder-loading {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justifyContent: center;
|
|
||||||
fontSize: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.profile-placeholder-initials {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #fff;
|
|
||||||
background-color: #6c63ff;
|
|
||||||
text-transform: uppercase;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -2,11 +2,10 @@
|
|||||||
import React, { useState, useRef, useEffect } from 'react';
|
import React, { useState, useRef, useEffect } from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { useNavigate, useLocation } from 'react-router-dom';
|
import { useNavigate, useLocation } from 'react-router-dom';
|
||||||
import API_KEY from '../utils/apiKeys';
|
|
||||||
import { UserInfos } from '../utils/Functions-Endpoints/General';
|
|
||||||
import './Header.css';
|
import './Header.css';
|
||||||
|
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
|
// --- hooks (sempre na mesma ordem) ---
|
||||||
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
||||||
const [isSuporteCardOpen, setIsSuporteCardOpen] = useState(false);
|
const [isSuporteCardOpen, setIsSuporteCardOpen] = useState(false);
|
||||||
const [isChatOpen, setIsChatOpen] = useState(false);
|
const [isChatOpen, setIsChatOpen] = useState(false);
|
||||||
@ -14,89 +13,40 @@ const Header = () => {
|
|||||||
const [mensagens, setMensagens] = useState([]);
|
const [mensagens, setMensagens] = useState([]);
|
||||||
const [showLogoutModal, setShowLogoutModal] = useState(false);
|
const [showLogoutModal, setShowLogoutModal] = useState(false);
|
||||||
const [avatarUrl, setAvatarUrl] = useState(null);
|
const [avatarUrl, setAvatarUrl] = useState(null);
|
||||||
const [uploadingAvatar, setUploadingAvatar] = useState(false);
|
|
||||||
const [userName, setUserName] = useState('');
|
|
||||||
const [userId, setUserId] = useState(null);
|
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const fileInputRef = useRef(null);
|
|
||||||
|
|
||||||
const chatInputRef = useRef(null);
|
const chatInputRef = useRef(null);
|
||||||
const mensagensContainerRef = useRef(null);
|
const mensagensContainerRef = useRef(null);
|
||||||
|
|
||||||
|
// foco quando abre chat
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isChatOpen && chatInputRef.current) {
|
if (isChatOpen && chatInputRef.current) {
|
||||||
chatInputRef.current.focus();
|
chatInputRef.current.focus();
|
||||||
}
|
}
|
||||||
}, [isChatOpen]);
|
}, [isChatOpen]);
|
||||||
|
|
||||||
|
// scroll automático quando nova mensagem
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (mensagensContainerRef.current) {
|
if (mensagensContainerRef.current) {
|
||||||
mensagensContainerRef.current.scrollTop = mensagensContainerRef.current.scrollHeight;
|
mensagensContainerRef.current.scrollTop = mensagensContainerRef.current.scrollHeight;
|
||||||
}
|
}
|
||||||
}, [mensagens]);
|
}, [mensagens]);
|
||||||
|
|
||||||
|
// carrega avatar se existir
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadUserAndAvatar = async () => {
|
const loadAvatar = () => {
|
||||||
try {
|
const localAvatar = localStorage.getItem('user_avatar');
|
||||||
const token = localStorage.getItem('access_token') || localStorage.getItem('token') || localStorage.getItem('authToken') || sessionStorage.getItem('token');
|
if (localAvatar) setAvatarUrl(localAvatar);
|
||||||
|
|
||||||
if (!token) return;
|
|
||||||
|
|
||||||
const userInfo = await UserInfos(`Bearer ${token}`);
|
|
||||||
|
|
||||||
const userIdFromInfo = userInfo?.id || userInfo?.user?.id || userInfo?.sub;
|
|
||||||
|
|
||||||
const userFullName =
|
|
||||||
userInfo?.full_name ||
|
|
||||||
userInfo?.user?.full_name ||
|
|
||||||
userInfo?.profile?.full_name ||
|
|
||||||
userInfo?.user?.user_metadata?.full_name ||
|
|
||||||
userInfo?.user?.email ||
|
|
||||||
userInfo?.email ||
|
|
||||||
'Usuário';
|
|
||||||
|
|
||||||
setUserId(userIdFromInfo);
|
|
||||||
setUserName(userFullName);
|
|
||||||
|
|
||||||
if (!userIdFromInfo) return;
|
|
||||||
|
|
||||||
const avatarPath = `${userIdFromInfo}/avatar.jpg`;
|
|
||||||
|
|
||||||
const myHeaders = new Headers();
|
|
||||||
myHeaders.append('apikey', API_KEY);
|
|
||||||
myHeaders.append('Authorization', `Bearer ${token}`);
|
|
||||||
|
|
||||||
const response = await fetch(
|
|
||||||
`https://yuanqfswhberkoevtmfr.supabase.co/storage/v1/object/public/avatars/${avatarPath}`,
|
|
||||||
{ method: 'GET', headers: myHeaders, redirect: 'follow' }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
const blob = await response.blob();
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
setAvatarUrl(url);
|
|
||||||
} else {
|
|
||||||
const authResponse = await fetch(
|
|
||||||
`https://yuanqfswhberkoevtmfr.supabase.co/storage/v1/object/avatars/${avatarPath}`,
|
|
||||||
{ method: 'GET', headers: myHeaders, redirect: 'follow' }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (authResponse.ok) {
|
|
||||||
const blob = await authResponse.blob();
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
setAvatarUrl(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.warn('Erro ao carregar usuário/avatar:', err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
loadAvatar();
|
||||||
loadUserAndAvatar();
|
const onStorage = () => loadAvatar();
|
||||||
|
window.addEventListener('storage', onStorage);
|
||||||
|
return () => window.removeEventListener('storage', onStorage);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// ESC fecha qualquer overlay/portal aberto (logout / suporte / chat)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onKey = (e) => {
|
const onKey = (e) => {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
@ -109,6 +59,7 @@ const Header = () => {
|
|||||||
return () => window.removeEventListener('keydown', onKey);
|
return () => window.removeEventListener('keydown', onKey);
|
||||||
}, [showLogoutModal, isSuporteCardOpen, isChatOpen]);
|
}, [showLogoutModal, isSuporteCardOpen, isChatOpen]);
|
||||||
|
|
||||||
|
// --- handlers logout (mantive comportamento) ---
|
||||||
const handleLogoutClick = () => {
|
const handleLogoutClick = () => {
|
||||||
setShowLogoutModal(true);
|
setShowLogoutModal(true);
|
||||||
setIsDropdownOpen(false);
|
setIsDropdownOpen(false);
|
||||||
@ -148,6 +99,7 @@ const Header = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// ignora erro de rede / endpoint — prossegue para limpar local
|
||||||
console.warn('logout endpoint error (ignored):', err);
|
console.warn('logout endpoint error (ignored):', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,6 +117,7 @@ const Header = () => {
|
|||||||
|
|
||||||
const handleLogoutCancel = () => setShowLogoutModal(false);
|
const handleLogoutCancel = () => setShowLogoutModal(false);
|
||||||
|
|
||||||
|
// --- profile / suporte / chat handlers ---
|
||||||
const handleProfileClick = () => {
|
const handleProfileClick = () => {
|
||||||
setIsDropdownOpen(!isDropdownOpen);
|
setIsDropdownOpen(!isDropdownOpen);
|
||||||
if (isSuporteCardOpen) setIsSuporteCardOpen(false);
|
if (isSuporteCardOpen) setIsSuporteCardOpen(false);
|
||||||
@ -176,75 +129,6 @@ const Header = () => {
|
|||||||
setIsDropdownOpen(false);
|
setIsDropdownOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAvatarClick = () => {
|
|
||||||
if (fileInputRef.current) {
|
|
||||||
fileInputRef.current.click();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleAvatarUpload = async (event) => {
|
|
||||||
const file = event.target.files?.[0];
|
|
||||||
if (!file) return;
|
|
||||||
|
|
||||||
// Validar tipo de arquivo
|
|
||||||
if (!file.type.startsWith('image/')) {
|
|
||||||
alert('Por favor, selecione um arquivo de imagem válido.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validar tamanho (máximo 5MB)
|
|
||||||
if (file.size > 5 * 1024 * 1024) {
|
|
||||||
alert('A imagem deve ter no máximo 5MB.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
setUploadingAvatar(true);
|
|
||||||
|
|
||||||
if (!userId) {
|
|
||||||
alert('Usuário não identificado. Faça login novamente.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const avatarPath = `${userId}/avatar.jpg`;
|
|
||||||
const token = localStorage.getItem('access_token') || localStorage.getItem('token') || localStorage.getItem('authToken') || sessionStorage.getItem('token');
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('file', file);
|
|
||||||
|
|
||||||
const myHeaders = new Headers();
|
|
||||||
myHeaders.append('apikey', API_KEY);
|
|
||||||
if (token) myHeaders.append('Authorization', `Bearer ${token}`);
|
|
||||||
|
|
||||||
const response = await fetch(
|
|
||||||
`https://yuanqfswhberkoevtmfr.supabase.co/storage/v1/object/avatars/${avatarPath}`,
|
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
headers: myHeaders,
|
|
||||||
body: formData,
|
|
||||||
redirect: 'follow'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
// Recarregar avatar
|
|
||||||
const url = URL.createObjectURL(file);
|
|
||||||
setAvatarUrl(url);
|
|
||||||
alert('Avatar atualizado com sucesso!');
|
|
||||||
} else {
|
|
||||||
const errorText = await response.text();
|
|
||||||
console.error('Erro ao fazer upload:', errorText);
|
|
||||||
alert('Erro ao fazer upload do avatar. Tente novamente.');
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Erro no upload:', err);
|
|
||||||
alert('Erro ao fazer upload do avatar. Tente novamente.');
|
|
||||||
} finally {
|
|
||||||
setUploadingAvatar(false);
|
|
||||||
if (fileInputRef.current) fileInputRef.current.value = '';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSuporteClick = () => {
|
const handleSuporteClick = () => {
|
||||||
setIsSuporteCardOpen((s) => !s);
|
setIsSuporteCardOpen((s) => !s);
|
||||||
setIsDropdownOpen(false);
|
setIsDropdownOpen(false);
|
||||||
@ -307,6 +191,7 @@ const Header = () => {
|
|||||||
}, 900);
|
}, 900);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --- subcomponentes (UI) ---
|
||||||
const SuporteCardContent = ({ onOpenChat }) => (
|
const SuporteCardContent = ({ onOpenChat }) => (
|
||||||
<div className="suporte-card">
|
<div className="suporte-card">
|
||||||
<h2 className="suporte-titulo">Suporte</h2>
|
<h2 className="suporte-titulo">Suporte</h2>
|
||||||
@ -474,10 +359,12 @@ const Header = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --- evita render na rota de login (mantendo hooks invocados) ---
|
||||||
if (location.pathname === '/login') {
|
if (location.pathname === '/login') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- JSX principal (header visual) ---
|
||||||
return (
|
return (
|
||||||
<div className="header-container" style={{ pointerEvents: 'auto' }}>
|
<div className="header-container" style={{ pointerEvents: 'auto' }}>
|
||||||
<div className="right-corner-elements">
|
<div className="right-corner-elements">
|
||||||
@ -492,54 +379,12 @@ const Header = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="profile-section" style={{ pointerEvents: 'auto' }}>
|
<div className="profile-section" style={{ pointerEvents: 'auto' }}>
|
||||||
<input
|
<div className="profile-picture-container" onClick={handleProfileClick} role="button" tabIndex={0}>
|
||||||
ref={fileInputRef}
|
<div className="profile-placeholder"></div>
|
||||||
type="file"
|
|
||||||
accept="image/*"
|
|
||||||
onChange={handleAvatarUpload}
|
|
||||||
style={{ display: 'none' }}
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
className="profile-picture-container"
|
|
||||||
onClick={handleProfileClick}
|
|
||||||
onDoubleClick={handleAvatarClick}
|
|
||||||
role="button"
|
|
||||||
tabIndex={0}
|
|
||||||
title="Clique para abrir menu"
|
|
||||||
>
|
|
||||||
{uploadingAvatar ? (
|
|
||||||
<div className="profile-placeholder profile-placeholder-loading">
|
|
||||||
<span>⏳</span>
|
|
||||||
</div>
|
|
||||||
) : avatarUrl ? (
|
|
||||||
<img
|
|
||||||
src={avatarUrl}
|
|
||||||
alt="Avatar"
|
|
||||||
className="profile-avatar-image"
|
|
||||||
/>
|
|
||||||
) : userName ? (
|
|
||||||
<div className="profile-placeholder profile-placeholder-initials">
|
|
||||||
{(() => {
|
|
||||||
const words = userName.trim().split(/\s+/).filter(w => w.length > 0);
|
|
||||||
if (words.length >= 2) {
|
|
||||||
return words.slice(0, 2).map(w => w[0]).join('');
|
|
||||||
} else if (words.length === 1 && words[0].length >= 2) {
|
|
||||||
return words[0].substring(0, 2);
|
|
||||||
} else {
|
|
||||||
return words[0]?.[0] || 'U';
|
|
||||||
}
|
|
||||||
})()}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="profile-placeholder"></div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isDropdownOpen && (
|
{isDropdownOpen && (
|
||||||
<div className="profile-dropdown" onClick={(e) => e.stopPropagation()}>
|
<div className="profile-dropdown" onClick={(e) => e.stopPropagation()}>
|
||||||
<button type="button" onClick={handleAvatarClick} className="dropdown-button">
|
|
||||||
<i className="bi bi-camera me-2"></i>Alterar Foto
|
|
||||||
</button>
|
|
||||||
<button type="button" onClick={handleViewProfile} className="dropdown-button">Ver Perfil</button>
|
<button type="button" onClick={handleViewProfile} className="dropdown-button">Ver Perfil</button>
|
||||||
<button type="button" onClick={handleLogoutClick} className="dropdown-button logout-button">Sair (Logout)</button>
|
<button type="button" onClick={handleLogoutClick} className="dropdown-button logout-button">Sair (Logout)</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -243,14 +243,6 @@ function Sidebar({ menuItems }) {
|
|||||||
<div className="sidebar-menu">
|
<div className="sidebar-menu">
|
||||||
<ul className="menu">
|
<ul className="menu">
|
||||||
|
|
||||||
{/* Botão Início fixo */}
|
|
||||||
<li className="sidebar-item inicio-item" style={{ marginBottom: "15px" }}>
|
|
||||||
<Link to={roleUser.includes("admin") ? "/secretaria/" : roleUser.includes("secretaria") ? "/secretaria/" : roleUser.includes("medico") ? "/medico/" : roleUser.includes("paciente") ? "/paciente/" : "/"} className="sidebar-link">
|
|
||||||
<i className="bi bi-house"></i>
|
|
||||||
<span>Início</span>
|
|
||||||
</Link>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{roleUser.includes("admin") &&
|
{roleUser.includes("admin") &&
|
||||||
<ToggleSidebar perfil={"administrador"} items={admItems} defaultOpen={pathname.includes("admin") } />
|
<ToggleSidebar perfil={"administrador"} items={admItems} defaultOpen={pathname.includes("admin") } />
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -4,179 +4,98 @@ import API_KEY from '../components/utils/apiKeys';
|
|||||||
import { useAuth } from '../components/utils/AuthProvider';
|
import { useAuth } from '../components/utils/AuthProvider';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { UserInfos } from '../components/utils/Functions-Endpoints/General';
|
import { UserInfos } from '../components/utils/Functions-Endpoints/General';
|
||||||
import { toast } from 'react-toastify';
|
|
||||||
const AgendamentoCadastroManager = ({ setPageConsulta, agendamentoInicial }) => {
|
|
||||||
|
|
||||||
const { getAuthorizationHeader } = useAuth();
|
const AgendamentoCadastroManager = ({ setPageConsulta, Dict, onSaved }) => {
|
||||||
|
const { getAuthorizationHeader, user } = useAuth();
|
||||||
|
const [agendamento, setAgendamento] = useState({ status: 'confirmed' });
|
||||||
|
const [idUsuario, setIDusuario] = useState('0');
|
||||||
|
|
||||||
const [agendamento, setAgendamento] = useState({ status: 'agendado' });
|
// patient_id do paciente logado (ou fallback para o Pedro)
|
||||||
const [idUsuario, setIDusuario] = useState('0');
|
|
||||||
const [isEditMode, setIsEditMode] = useState(false);
|
|
||||||
|
|
||||||
let authHeader = getAuthorizationHeader();
|
const patientId = 'bf7d8323-05e1-437a-817c-f08eb5f174ef';
|
||||||
|
|
||||||
useEffect(() => {
|
const authHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
if (agendamentoInicial && agendamentoInicial.id) {
|
if (!Dict) {
|
||||||
|
setAgendamento({ status: 'confirmed' });
|
||||||
const scheduled_at = dayjs(agendamentoInicial.scheduled_at);
|
} else {
|
||||||
|
setAgendamento(Dict);
|
||||||
setAgendamento({
|
|
||||||
...agendamentoInicial,
|
|
||||||
|
|
||||||
dataAtendimento: scheduled_at.format('YYYY-MM-DD'),
|
|
||||||
horarioInicio: scheduled_at.format('HH:mm'),
|
|
||||||
|
|
||||||
|
|
||||||
tipo_consulta: agendamentoInicial.appointment_type || 'Presencial',
|
|
||||||
convenio: agendamentoInicial.insurance_provider || 'Público',
|
|
||||||
|
|
||||||
|
|
||||||
paciente_nome: agendamentoInicial.paciente_nome || '',
|
|
||||||
paciente_cpf: agendamentoInicial.paciente_cpf || '',
|
|
||||||
medico_nome: agendamentoInicial.medico_nome || '',
|
|
||||||
|
|
||||||
|
|
||||||
patient_id: agendamentoInicial.patient_id,
|
|
||||||
doctor_id: agendamentoInicial.doctor_id,
|
|
||||||
status: agendamentoInicial.status,
|
|
||||||
});
|
|
||||||
setIsEditMode(true);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
setAgendamento({
|
|
||||||
status: 'agendado',
|
|
||||||
patient_id: null,
|
|
||||||
doctor_id: null,
|
|
||||||
dataAtendimento: dayjs().format('YYYY-MM-DD'),
|
|
||||||
horarioInicio: '',
|
|
||||||
tipo_consulta: 'Presencial',
|
|
||||||
convenio: 'Público',
|
|
||||||
paciente_nome: '',
|
|
||||||
paciente_cpf: '',
|
|
||||||
medico_nome: ''
|
|
||||||
});
|
|
||||||
setIsEditMode(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const ColherInfoUsuario = async () => {
|
|
||||||
const result = await UserInfos(authHeader);
|
|
||||||
setIDusuario(result?.profile?.id);
|
|
||||||
};
|
|
||||||
ColherInfoUsuario();
|
|
||||||
|
|
||||||
|
|
||||||
}, [agendamentoInicial, authHeader]);
|
|
||||||
const handleSave = async (Dict) => {
|
|
||||||
var myHeaders = new Headers();
|
|
||||||
myHeaders.append("apikey", API_KEY);
|
|
||||||
myHeaders.append("Authorization", authHeader);
|
|
||||||
myHeaders.append("Content-Type", "application/json");
|
|
||||||
myHeaders.append("Prefer", "return=representation");
|
|
||||||
|
|
||||||
var raw = JSON.stringify({
|
|
||||||
"patient_id": Dict.patient_id,
|
|
||||||
"doctor_id": Dict.doctor_id,
|
|
||||||
"scheduled_at": `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
|
||||||
"duration_minutes": Dict.duration_minutes || 30,
|
|
||||||
"appointment_type": Dict.tipo_consulta,
|
|
||||||
"insurance_provider": Dict.convenio,
|
|
||||||
"status": Dict.status || 'agendado',
|
|
||||||
"created_by": idUsuario,
|
|
||||||
"created_at": dayjs().toISOString(),
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
var requestOptions = {
|
|
||||||
method: 'POST',
|
|
||||||
headers: myHeaders,
|
|
||||||
body: raw,
|
|
||||||
redirect: 'follow'
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments", requestOptions);
|
|
||||||
if (response.ok) {
|
|
||||||
toast.success("Agendamento criado com sucesso! ✅");
|
|
||||||
setPageConsulta(false);
|
|
||||||
} else {
|
|
||||||
const errorText = await response.text();
|
|
||||||
console.error('Erro ao cadastrar agendamento:', errorText);
|
|
||||||
toast.error(`Falha ao criar agendamento: ${JSON.parse(errorText)?.message || 'Erro desconhecido'}`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Erro de rede:', error);
|
|
||||||
toast.error("Erro de rede ao salvar. ❌");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const handleUpdate = async (Dict) => {
|
|
||||||
const appointmentId = agendamentoInicial.id;
|
|
||||||
|
|
||||||
var myHeaders = new Headers();
|
|
||||||
myHeaders.append("apikey", API_KEY);
|
|
||||||
myHeaders.append("Authorization", authHeader);
|
|
||||||
myHeaders.append("Content-Type", "application/json");
|
|
||||||
myHeaders.append("Prefer", "return=representation");
|
|
||||||
|
|
||||||
var raw = JSON.stringify({
|
|
||||||
"patient_id": Dict.patient_id,
|
|
||||||
"doctor_id": Dict.doctor_id,
|
|
||||||
"scheduled_at": `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
|
||||||
"duration_minutes": Dict.duration_minutes || 30,
|
|
||||||
"appointment_type": Dict.tipo_consulta,
|
|
||||||
"insurance_provider": Dict.convenio,
|
|
||||||
"status": Dict.status,
|
|
||||||
"updated_at": dayjs().toISOString(),
|
|
||||||
"updated_by": idUsuario,
|
|
||||||
});
|
|
||||||
|
|
||||||
var requestOptions = {
|
|
||||||
method: 'PATCH',
|
|
||||||
headers: myHeaders,
|
|
||||||
body: raw,
|
|
||||||
redirect: 'follow'
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${appointmentId}`, requestOptions);
|
|
||||||
if (response.ok) {
|
|
||||||
toast.success("Agendamento atualizado com sucesso! 📝");
|
|
||||||
setPageConsulta(false);
|
|
||||||
} else {
|
|
||||||
const errorText = await response.text();
|
|
||||||
console.error('Erro ao atualizar agendamento:', errorText);
|
|
||||||
toast.error(`Falha ao atualizar agendamento: ${JSON.parse(errorText)?.message || 'Erro desconhecido'}`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Erro de rede:', error);
|
|
||||||
toast.error("Erro de rede ao atualizar. ❌");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const handleFormSubmit = (Dict) => {
|
|
||||||
if (isEditMode) {
|
|
||||||
|
|
||||||
handleUpdate(Dict);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
handleSave(Dict);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ColherInfoUsuario = async () => {
|
||||||
|
try {
|
||||||
|
const result = await UserInfos(authHeader);
|
||||||
|
setIDusuario(result?.profile?.id);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Erro ao buscar infos do usuário:', e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
if (authHeader) {
|
||||||
<div>
|
ColherInfoUsuario();
|
||||||
{}
|
}
|
||||||
<FormNovaConsulta
|
}, [Dict, authHeader]);
|
||||||
onSave={handleFormSubmit}
|
|
||||||
agendamento={agendamento}
|
const handleSave = async (DictForm) => {
|
||||||
setAgendamento={setAgendamento}
|
if (!authHeader) {
|
||||||
onCancel={() => setPageConsulta(false)}
|
alert('Sem autorização. Faça login novamente.');
|
||||||
/>
|
return;
|
||||||
</div>
|
}
|
||||||
);
|
|
||||||
|
const myHeaders = new Headers();
|
||||||
|
myHeaders.append('apikey', API_KEY);
|
||||||
|
myHeaders.append('Authorization', authHeader);
|
||||||
|
myHeaders.append('Content-Type', 'application/json');
|
||||||
|
|
||||||
|
const raw = JSON.stringify({
|
||||||
|
patient_id: patientId, // paciente logado
|
||||||
|
doctor_id: DictForm.doctor_id,
|
||||||
|
scheduled_at: `${DictForm.dataAtendimento}T${DictForm.horarioInicio}:00`,
|
||||||
|
duration_minutes: 30,
|
||||||
|
appointment_type: DictForm.tipo_consulta,
|
||||||
|
patient_notes: '',
|
||||||
|
insurance_provider: DictForm.convenio,
|
||||||
|
status: 'confirmed', // ou 'confirmed'
|
||||||
|
created_by: idUsuario,
|
||||||
|
created_at: dayjs().toISOString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const requestOptions = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: myHeaders,
|
||||||
|
body: raw,
|
||||||
|
redirect: 'follow',
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
'https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments',
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
if (response.ok) {
|
||||||
|
if (onSaved) onSaved(); // pai recarrega e fecha
|
||||||
|
else setPageConsulta(false);
|
||||||
|
} else {
|
||||||
|
console.error('Erro ao criar agendamento:', await response.text());
|
||||||
|
alert('Falha ao criar agendamento.');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erro de rede:', error);
|
||||||
|
alert('Erro de rede ao salvar agendamento.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<FormNovaConsulta
|
||||||
|
onSave={handleSave}
|
||||||
|
agendamento={agendamento}
|
||||||
|
setAgendamento={setAgendamento}
|
||||||
|
onCancel={() => setPageConsulta(false)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AgendamentoCadastroManager;
|
export default AgendamentoCadastroManager;
|
||||||
@ -1,17 +1,17 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import API_KEY from "../components/utils/apiKeys";
|
import API_KEY from "../components/utils/apiKeys";
|
||||||
import { useAuth } from "../components/utils/AuthProvider";
|
import { useAuth } from "../components/utils/AuthProvider";
|
||||||
import { Link, useNavigate } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import "./style/TableDoctor.css";
|
import "./style/TableDoctor.css";
|
||||||
|
|
||||||
function TableDoctor({ setDictInfo }) {
|
function TableDoctor({setDictInfo}) {
|
||||||
const { getAuthorizationHeader, isAuthenticated } = useAuth();
|
const { getAuthorizationHeader, isAuthenticated } = useAuth();
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const [medicos, setMedicos] = useState([]);
|
const [medicos, setMedicos] = useState([]);
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const [filtroEspecialidade, setFiltroEspecialidade] = useState("Todos");
|
const [filtroEspecialidade, setFiltroEspecialidade] = useState("Todos");
|
||||||
const [filtroAniversariante, setFiltroAniversariante] = useState(false);
|
const [filtroAniversariante, setFiltroAniversariante] = useState(false);
|
||||||
|
|
||||||
const [showFiltrosAvancados, setShowFiltrosAvancados] = useState(false);
|
const [showFiltrosAvancados, setShowFiltrosAvancados] = useState(false);
|
||||||
const [filtroCidade, setFiltroCidade] = useState("");
|
const [filtroCidade, setFiltroCidade] = useState("");
|
||||||
const [filtroEstado, setFiltroEstado] = useState("");
|
const [filtroEstado, setFiltroEstado] = useState("");
|
||||||
@ -20,8 +20,6 @@ function TableDoctor({ setDictInfo }) {
|
|||||||
const [dataInicial, setDataInicial] = useState("");
|
const [dataInicial, setDataInicial] = useState("");
|
||||||
const [dataFinal, setDataFinal] = useState("");
|
const [dataFinal, setDataFinal] = useState("");
|
||||||
|
|
||||||
const [sortKey, setSortKey] = useState(null);
|
|
||||||
const [sortDir, setSortDir] = useState('asc');
|
|
||||||
|
|
||||||
const [paginaAtual, setPaginaAtual] = useState(1);
|
const [paginaAtual, setPaginaAtual] = useState(1);
|
||||||
const [itensPorPagina, setItensPorPagina] = useState(10);
|
const [itensPorPagina, setItensPorPagina] = useState(10);
|
||||||
@ -29,11 +27,52 @@ function TableDoctor({ setDictInfo }) {
|
|||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||||
const [selectedDoctorId, setSelectedDoctorId] = useState(null);
|
const [selectedDoctorId, setSelectedDoctorId] = useState(null);
|
||||||
|
|
||||||
// ===== FUNÇÕES AUXILIARES =====
|
const [sortKey, setSortKey] = useState(null);
|
||||||
|
const [sortDir, setSortDir] = useState('asc');
|
||||||
|
|
||||||
|
const limparFiltros = () => {
|
||||||
|
setSearch("");
|
||||||
|
setFiltroEspecialidade("Todos");
|
||||||
|
setFiltroAniversariante(false);
|
||||||
|
setShowFiltrosAvancados(false);
|
||||||
|
setFiltroCidade("");
|
||||||
|
setFiltroEstado("");
|
||||||
|
setIdadeMinima("");
|
||||||
|
setIdadeMaxima("");
|
||||||
|
setDataInicial("");
|
||||||
|
setDataFinal("");
|
||||||
|
setPaginaAtual(1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteDoctor = async (id) => {
|
||||||
|
const authHeader = getAuthorizationHeader()
|
||||||
|
console.log(id, 'teu id')
|
||||||
|
|
||||||
|
var myHeaders = new Headers();
|
||||||
|
myHeaders.append('apikey', API_KEY);
|
||||||
|
myHeaders.append("Authorization", authHeader)
|
||||||
|
|
||||||
|
var requestOptions = { method: "DELETE", redirect: "follow", headers: myHeaders };
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await fetch(
|
||||||
|
`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/doctors?id=eq.${id}`,
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
setMedicos((prev) => prev.filter((p) => p.id !== id));
|
||||||
|
console.log(result)
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Deu problema", error);
|
||||||
|
} finally {
|
||||||
|
setShowDeleteModal(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const ehAniversariante = (dataNascimento) => {
|
const ehAniversariante = (dataNascimento) => {
|
||||||
if (!dataNascimento) return false;
|
if (!dataNascimento) return false;
|
||||||
const hoje = new Date();
|
const hoje = new Date();
|
||||||
const nascimento = new Date(dataNascimento);
|
const nascimento = new Date(dataNascimento);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
hoje.getDate() === nascimento.getDate() &&
|
hoje.getDate() === nascimento.getDate() &&
|
||||||
hoje.getMonth() === nascimento.getMonth()
|
hoje.getMonth() === nascimento.getMonth()
|
||||||
@ -46,44 +85,17 @@ function TableDoctor({ setDictInfo }) {
|
|||||||
const nascimento = new Date(dataNascimento);
|
const nascimento = new Date(dataNascimento);
|
||||||
let idade = hoje.getFullYear() - nascimento.getFullYear();
|
let idade = hoje.getFullYear() - nascimento.getFullYear();
|
||||||
const mes = hoje.getMonth() - nascimento.getMonth();
|
const mes = hoje.getMonth() - nascimento.getMonth();
|
||||||
|
|
||||||
if (mes < 0 || (mes === 0 && hoje.getDate() < nascimento.getDate())) {
|
if (mes < 0 || (mes === 0 && hoje.getDate() < nascimento.getDate())) {
|
||||||
idade--;
|
idade--;
|
||||||
}
|
}
|
||||||
return idade;
|
return idade;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ===== FUNÇÕES DE API =====
|
|
||||||
const deleteDoctor = async (id) => {
|
|
||||||
const authHeader = getAuthorizationHeader();
|
|
||||||
var myHeaders = new Headers();
|
|
||||||
myHeaders.append('apikey', API_KEY);
|
|
||||||
myHeaders.append("Authorization", authHeader);
|
|
||||||
var requestOptions = {
|
|
||||||
method: "DELETE",
|
|
||||||
redirect: "follow",
|
|
||||||
headers: myHeaders
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(
|
|
||||||
`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/doctors?id=eq.${id}`,
|
|
||||||
requestOptions
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Erro ${response.status}: ${response.statusText}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
setMedicos((prev) => prev.filter((p) => p.id !== id));
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Erro ao excluir médico:", error);
|
|
||||||
} finally {
|
|
||||||
setShowDeleteModal(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const authHeader = getAuthorizationHeader();
|
const authHeader = getAuthorizationHeader()
|
||||||
|
console.log(authHeader, 'aqui autorização')
|
||||||
|
|
||||||
var myHeaders = new Headers();
|
var myHeaders = new Headers();
|
||||||
myHeaders.append("apikey", API_KEY);
|
myHeaders.append("apikey", API_KEY);
|
||||||
myHeaders.append("Authorization", `${authHeader}`);
|
myHeaders.append("Authorization", `${authHeader}`);
|
||||||
@ -99,20 +111,6 @@ function TableDoctor({ setDictInfo }) {
|
|||||||
.catch(error => console.log('error', error));
|
.catch(error => console.log('error', error));
|
||||||
}, [isAuthenticated, getAuthorizationHeader]);
|
}, [isAuthenticated, getAuthorizationHeader]);
|
||||||
|
|
||||||
// ===== FILTRAGEM =====
|
|
||||||
const limparFiltros = () => {
|
|
||||||
setSearch("");
|
|
||||||
setFiltroEspecialidade("Todos");
|
|
||||||
setFiltroAniversariante(false);
|
|
||||||
setFiltroCidade("");
|
|
||||||
setFiltroEstado("");
|
|
||||||
setIdadeMinima("");
|
|
||||||
setIdadeMaxima("");
|
|
||||||
setDataInicial("");
|
|
||||||
setDataFinal("");
|
|
||||||
setPaginaAtual(1);
|
|
||||||
};
|
|
||||||
|
|
||||||
const medicosFiltrados = Array.isArray(medicos) ? medicos.filter((medico) => {
|
const medicosFiltrados = Array.isArray(medicos) ? medicos.filter((medico) => {
|
||||||
const buscaNome = medico.full_name?.toLowerCase().includes(search.toLowerCase());
|
const buscaNome = medico.full_name?.toLowerCase().includes(search.toLowerCase());
|
||||||
const buscaCPF = medico.cpf?.toLowerCase().includes(search.toLowerCase());
|
const buscaCPF = medico.cpf?.toLowerCase().includes(search.toLowerCase());
|
||||||
@ -120,24 +118,35 @@ function TableDoctor({ setDictInfo }) {
|
|||||||
const passaBusca = search === "" || buscaNome || buscaCPF || buscaEmail;
|
const passaBusca = search === "" || buscaNome || buscaCPF || buscaEmail;
|
||||||
|
|
||||||
const passaEspecialidade = filtroEspecialidade === "Todos" || medico.specialty === filtroEspecialidade;
|
const passaEspecialidade = filtroEspecialidade === "Todos" || medico.specialty === filtroEspecialidade;
|
||||||
const passaAniversario = filtroAniversariante ? ehAniversariante(medico.birth_date) : true;
|
|
||||||
const passaCidade = filtroCidade ? medico.city?.toLowerCase().includes(filtroCidade.toLowerCase()) : true;
|
const passaAniversario = filtroAniversariante
|
||||||
const passaEstado = filtroEstado ? medico.state?.toLowerCase().includes(filtroEstado.toLowerCase()) : true;
|
? ehAniversariante(medico.birth_date)
|
||||||
|
: true;
|
||||||
|
|
||||||
|
const passaCidade = filtroCidade ?
|
||||||
|
medico.city?.toLowerCase().includes(filtroCidade.toLowerCase()) : true;
|
||||||
|
|
||||||
|
const passaEstado = filtroEstado ?
|
||||||
|
medico.state?.toLowerCase().includes(filtroEstado.toLowerCase()) : true;
|
||||||
|
|
||||||
const idade = calcularIdade(medico.birth_date);
|
const idade = calcularIdade(medico.birth_date);
|
||||||
const passaIdadeMinima = idadeMinima ? idade >= parseInt(idadeMinima) : true;
|
const passaIdadeMinima = idadeMinima ? idade >= parseInt(idadeMinima) : true;
|
||||||
const passaIdadeMaxima = idadeMaxima ? idade <= parseInt(idadeMaxima) : true;
|
const passaIdadeMaxima = idadeMaxima ? idade <= parseInt(idadeMaxima) : true;
|
||||||
|
|
||||||
const passaDataInicial = dataInicial ? medico.created_at && new Date(medico.created_at) >= new Date(dataInicial) : true;
|
const passaDataInicial = dataInicial ?
|
||||||
const passaDataFinal = dataFinal ? medico.created_at && new Date(medico.created_at) <= new Date(dataFinal) : true;
|
medico.created_at && new Date(medico.created_at) >= new Date(dataInicial) : true;
|
||||||
|
|
||||||
return passaBusca && passaEspecialidade && passaAniversario &&
|
const passaDataFinal = dataFinal ?
|
||||||
|
medico.created_at && new Date(medico.created_at) <= new Date(dataFinal) : true;
|
||||||
|
|
||||||
|
const resultado = passaBusca && passaEspecialidade && passaAniversario &&
|
||||||
passaCidade && passaEstado && passaIdadeMinima && passaIdadeMaxima &&
|
passaCidade && passaEstado && passaIdadeMinima && passaIdadeMaxima &&
|
||||||
passaDataInicial && passaDataFinal;
|
passaDataInicial && passaDataFinal;
|
||||||
|
|
||||||
|
return resultado;
|
||||||
}) : [];
|
}) : [];
|
||||||
|
|
||||||
// ===== ORDENAÇÃO =====
|
const applySorting = (arr) => {
|
||||||
const aplicarOrdenacao = (arr) => {
|
|
||||||
if (!Array.isArray(arr) || !sortKey) return arr;
|
if (!Array.isArray(arr) || !sortKey) return arr;
|
||||||
const copy = [...arr];
|
const copy = [...arr];
|
||||||
if (sortKey === 'nome') {
|
if (sortKey === 'nome') {
|
||||||
@ -149,25 +158,44 @@ function TableDoctor({ setDictInfo }) {
|
|||||||
return copy;
|
return copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
const medicosOrdenados = aplicarOrdenacao(medicosFiltrados);
|
const medicosOrdenados = applySorting(medicosFiltrados);
|
||||||
|
|
||||||
// ===== PAGINAÇÃO =====
|
|
||||||
const totalPaginas = Math.ceil(medicosFiltrados.length / itensPorPagina);
|
const totalPaginas = Math.ceil(medicosFiltrados.length / itensPorPagina);
|
||||||
const indiceInicial = (paginaAtual - 1) * itensPorPagina;
|
const indiceInicial = (paginaAtual - 1) * itensPorPagina;
|
||||||
const indiceFinal = indiceInicial + itensPorPagina;
|
const indiceFinal = indiceInicial + itensPorPagina;
|
||||||
const medicosPaginados = medicosOrdenados.slice(indiceInicial, indiceFinal);
|
const medicosPaginados = medicosOrdenados.slice(indiceInicial, indiceFinal);
|
||||||
|
|
||||||
const irParaPagina = (pagina) => setPaginaAtual(pagina);
|
|
||||||
const avancarPagina = () => paginaAtual < totalPaginas && setPaginaAtual(p => p + 1);
|
const irParaPagina = (pagina) => {
|
||||||
const voltarPagina = () => paginaAtual > 1 && setPaginaAtual(p => p - 1);
|
setPaginaAtual(pagina);
|
||||||
|
};
|
||||||
|
|
||||||
|
const avancarPagina = () => {
|
||||||
|
if (paginaAtual < totalPaginas) {
|
||||||
|
setPaginaAtual(paginaAtual + 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const voltarPagina = () => {
|
||||||
|
if (paginaAtual > 1) {
|
||||||
|
setPaginaAtual(paginaAtual - 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const gerarNumerosPaginas = () => {
|
const gerarNumerosPaginas = () => {
|
||||||
const paginas = [];
|
const paginas = [];
|
||||||
const paginasParaMostrar = 5;
|
const paginasParaMostrar = 5;
|
||||||
|
|
||||||
let inicio = Math.max(1, paginaAtual - Math.floor(paginasParaMostrar / 2));
|
let inicio = Math.max(1, paginaAtual - Math.floor(paginasParaMostrar / 2));
|
||||||
let fim = Math.min(totalPaginas, inicio + paginasParaMostrar - 1);
|
let fim = Math.min(totalPaginas, inicio + paginasParaMostrar - 1);
|
||||||
|
|
||||||
inicio = Math.max(1, fim - paginasParaMostrar + 1);
|
inicio = Math.max(1, fim - paginasParaMostrar + 1);
|
||||||
for (let i = inicio; i <= fim; i++) paginas.push(i);
|
|
||||||
|
for (let i = inicio; i <= fim; i++) {
|
||||||
|
paginas.push(i);
|
||||||
|
}
|
||||||
|
|
||||||
return paginas;
|
return paginas;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -180,364 +208,359 @@ function TableDoctor({ setDictInfo }) {
|
|||||||
<div className="page-heading">
|
<div className="page-heading">
|
||||||
<h3>Lista de Médicos</h3>
|
<h3>Lista de Médicos</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="page-content table-doctor-container">
|
<div className="page-content table-doctor-container">
|
||||||
<div className="table-doctor-card">
|
<section className="row">
|
||||||
<div className="card-header d-flex justify-content-between align-items-center">
|
<div className="col-12">
|
||||||
<h4 className="card-title mb-0">Médicos Cadastrados</h4>
|
<div className="card table-doctor-card">
|
||||||
<Link to={'cadastro'}>
|
<div className="card-header">
|
||||||
<button className="btn btn-primary">
|
<h4 className="card-title mb-0">Médicos Cadastrados</h4>
|
||||||
<i className="bi bi-plus-circle"></i> Adicionar Médico
|
<Link to={'cadastro'}>
|
||||||
</button>
|
<button className="btn btn-primary">
|
||||||
</Link>
|
<i className="bi bi-plus-circle"></i> Adicionar Médico
|
||||||
</div>
|
</button>
|
||||||
|
</Link>
|
||||||
<div className="card-body">
|
|
||||||
{/* ===== FILTROS PADRONIZADOS ===== */}
|
|
||||||
<div className="table-doctor-filters">
|
|
||||||
<h5 className="mb-3">
|
|
||||||
<i className="bi bi-funnel-fill me-2 text-primary"></i> Filtros
|
|
||||||
</h5>
|
|
||||||
|
|
||||||
{/* Busca */}
|
|
||||||
<div className="mb-3">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control"
|
|
||||||
placeholder="Buscar por nome, CPF ou email..."
|
|
||||||
value={search}
|
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Linha de Filtros Básicos - MESMO PADRÃO DA TABLE PACIENTE */}
|
<div className="card-body">
|
||||||
<div className="d-flex flex-wrap align-items-center gap-3 mb-3">
|
<div className="card p-3 mb-3 table-doctor-filters">
|
||||||
{/* Especialidade */}
|
<h5 className="mb-3">
|
||||||
<div className="d-flex align-items-center gap-2">
|
<i className="bi bi-funnel-fill me-2 text-primary"></i>{" "}
|
||||||
<label className="form-label mb-0 text-muted small">Especialidade:</label>
|
Filtros
|
||||||
<select
|
</h5>
|
||||||
className="form-select form-select-sm compact-select"
|
|
||||||
value={filtroEspecialidade}
|
|
||||||
onChange={(e) => setFiltroEspecialidade(e.target.value)}
|
|
||||||
style={{ minWidth: "180px" }}
|
|
||||||
>
|
|
||||||
<option value="Todos">Todas as Especialidades</option>
|
|
||||||
<option value="Clínica Geral">Clínica Geral</option>
|
|
||||||
<option value="Pediatria">Pediatria</option>
|
|
||||||
<option value="Ginecologia">Ginecologia</option>
|
|
||||||
<option value="Cardiologia">Cardiologia</option>
|
|
||||||
<option value="Ortopedia">Ortopedia</option>
|
|
||||||
<option value="Oftalmologia">Oftalmologia</option>
|
|
||||||
<option value="Otorrinolaringologia">Otorrinolaringologia</option>
|
|
||||||
<option value="Dermatologia">Dermatologia</option>
|
|
||||||
<option value="Neurologia">Neurologia</option>
|
|
||||||
<option value="Psiquiatria">Psiquiatria</option>
|
|
||||||
<option value="Endocrinologia">Endocrinologia</option>
|
|
||||||
<option value="Gastroenterologia">Gastroenterologia</option>
|
|
||||||
<option value="Urologia">Urologia</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Aniversariantes */}
|
<div className="mb-3">
|
||||||
<div className="d-flex align-items-center gap-2">
|
<input
|
||||||
<label className="form-label mb-0 text-muted small">Aniversário:</label>
|
type="text"
|
||||||
<select
|
className="form-control"
|
||||||
className="form-select form-select-sm compact-select"
|
placeholder="Buscar por nome, CPF ou email..."
|
||||||
value={filtroAniversariante ? "hoje" : "todos"}
|
value={search}
|
||||||
onChange={(e) => setFiltroAniversariante(e.target.value === "hoje")}
|
onChange={(e) => setSearch(e.target.value)}
|
||||||
style={{ minWidth: "140px" }}
|
/>
|
||||||
>
|
<small className="text-muted">
|
||||||
<option value="todos">Todos</option>
|
Digite o nome completo, CPF ou email
|
||||||
<option value="hoje">Aniversariantes</option>
|
</small>
|
||||||
</select>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Separador */}
|
<div className="filtros-basicos">
|
||||||
<div className="vr d-none d-md-block" style={{ height: "30px" }} />
|
<select
|
||||||
|
className="form-select filter-especialidade"
|
||||||
|
value={filtroEspecialidade}
|
||||||
|
onChange={(e) => setFiltroEspecialidade(e.target.value)}
|
||||||
|
>
|
||||||
|
<option value="Todos">Todas as Especialidades</option>
|
||||||
|
<option value="Clínica Geral">Clínica médica (clínico geral)</option>
|
||||||
|
<option value="Pediatria">Pediatria</option>
|
||||||
|
<option value="Ginecologia">Ginecologia e obstetrícia</option>
|
||||||
|
<option value="Cardiologia">Cardiologia</option>
|
||||||
|
<option value="Ortopedia">Ortopedia e traumatologia</option>
|
||||||
|
<option value="Oftalmologia">Oftalmologia</option>
|
||||||
|
<option value="Otorrinolaringologia">Otorrinolaringologia</option>
|
||||||
|
<option value="Dermatologia">Dermatologia</option>
|
||||||
|
<option value="Neurologia">Neurologia</option>
|
||||||
|
<option value="Psiquiatria">Psiquiatria</option>
|
||||||
|
<option value="Endocrinologia">Endocrinologia</option>
|
||||||
|
<option value="Gastroenterologia">Gastroenterologia</option>
|
||||||
|
<option value="Urologia">Urologia</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
{/* Ordenação */}
|
<div className="filter-buttons-container">
|
||||||
<div className="d-flex align-items-center gap-2">
|
<button
|
||||||
<label className="form-label mb-0 text-muted small">Ordenar por:</label>
|
className={`btn filter-btn ${filtroAniversariante
|
||||||
<select
|
? "btn-primary"
|
||||||
className="form-select form-select-sm compact-select sort-select"
|
: "btn-outline-primary"
|
||||||
value={sortKey ? `${sortKey}-${sortDir}` : ''}
|
}`}
|
||||||
onChange={(e) => {
|
onClick={() => setFiltroAniversariante(!filtroAniversariante)}
|
||||||
const v = e.target.value;
|
>
|
||||||
if (!v) { setSortKey(null); setSortDir('asc'); return; }
|
<i className="bi bi-calendar me-1"></i> Aniversariantes
|
||||||
const [k, d] = v.split('-');
|
</button>
|
||||||
setSortKey(k);
|
|
||||||
setSortDir(d);
|
|
||||||
}}
|
|
||||||
style={{ minWidth: "180px" }}
|
|
||||||
>
|
|
||||||
<option value="">Sem ordenação</option>
|
|
||||||
<option value="nome-asc">Nome (A-Z)</option>
|
|
||||||
<option value="nome-desc">Nome (Z-A)</option>
|
|
||||||
<option value="idade-asc">Idade (crescente)</option>
|
|
||||||
<option value="idade-desc">Idade (decrescente)</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Linha de Ações */}
|
|
||||||
<div className="d-flex justify-content-between align-items-center">
|
|
||||||
<button
|
|
||||||
className="btn btn-link p-0 text-decoration-none d-flex align-items-center"
|
|
||||||
onClick={() => setShowFiltrosAvancados(!showFiltrosAvancados)}
|
|
||||||
style={{ fontSize: "0.9rem" }}
|
|
||||||
>
|
|
||||||
<i className={`bi bi-chevron-${showFiltrosAvancados ? 'up' : 'down'} me-1`}></i>
|
|
||||||
Filtros Avançados
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
className="btn btn-outline-secondary btn-sm d-flex align-items-center"
|
|
||||||
onClick={limparFiltros}
|
|
||||||
>
|
|
||||||
<i className="bi bi-arrow-clockwise me-1"></i> Limpar Filtros
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Filtros Avançados */}
|
|
||||||
{showFiltrosAvancados && (
|
|
||||||
<div className="mt-3 p-3 border rounded advanced-filters">
|
|
||||||
<h6 className="mb-3">Filtros Avançados</h6>
|
|
||||||
<div className="row g-3">
|
|
||||||
<div className="col-md-6">
|
|
||||||
<label className="form-label fw-bold">Cidade</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
placeholder="Digite a cidade..."
|
|
||||||
value={filtroCidade}
|
|
||||||
onChange={(e) => setFiltroCidade(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-6">
|
|
||||||
<label className="form-label fw-bold">Estado</label>
|
|
||||||
<input
|
<div className="vr mx-2 d-none d-md-block" />
|
||||||
type="text"
|
<div className="d-flex align-items-center gap-2">
|
||||||
className="form-control form-control-sm"
|
<span className="text-muted small">Ordenar por:</span>
|
||||||
placeholder="Ex: Minas Gerais"
|
{(() => {
|
||||||
value={filtroEstado}
|
const sortValue = sortKey ? `${sortKey}-${sortDir}` : '';
|
||||||
onChange={(e) => setFiltroEstado(e.target.value)}
|
return (
|
||||||
/>
|
<select
|
||||||
|
className="form-select compact-select sort-select w-auto"
|
||||||
|
value={sortValue}
|
||||||
|
onChange={(e) => {
|
||||||
|
const v = e.target.value;
|
||||||
|
if (!v) { setSortKey(null); setSortDir('asc'); return; }
|
||||||
|
const [k, d] = v.split('-');
|
||||||
|
setSortKey(k);
|
||||||
|
setSortDir(d);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option value="">Sem ordenação</option>
|
||||||
|
<option value="nome-asc">Nome (A-Z)</option>
|
||||||
|
<option value="nome-desc">Nome (Z-A)</option>
|
||||||
|
<option value="idade-asc">Idade (crescente)</option>
|
||||||
|
<option value="idade-desc">Idade (decrescente)</option>
|
||||||
|
</select>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-6">
|
</div>
|
||||||
<label className="form-label fw-bold">Idade mínima</label>
|
|
||||||
<input
|
<div className="d-flex justify-content-between align-items-center mt-3">
|
||||||
type="number"
|
<button
|
||||||
className="form-control form-control-sm"
|
className="btn btn-link p-0 text-decoration-none"
|
||||||
placeholder="Ex: 25"
|
onClick={() => setShowFiltrosAvancados(!showFiltrosAvancados)}
|
||||||
value={idadeMinima}
|
>
|
||||||
onChange={(e) => setIdadeMinima(e.target.value)}
|
<i className={`bi bi-chevron-${showFiltrosAvancados ? 'up' : 'down'} me-1`}></i>
|
||||||
min="0"
|
Filtros Avançados
|
||||||
max="150"
|
</button>
|
||||||
/>
|
|
||||||
|
<button
|
||||||
|
className="btn btn-outline-secondary btn-sm"
|
||||||
|
onClick={limparFiltros}
|
||||||
|
>
|
||||||
|
<i className="bi bi-arrow-clockwise me-1"></i> Limpar Filtros
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{showFiltrosAvancados && (
|
||||||
|
<div className="mt-3 p-3 border rounded advanced-filters">
|
||||||
|
<h6 className="mb-3">Filtros Avançados</h6>
|
||||||
|
|
||||||
|
<div className="row g-3">
|
||||||
|
<div className="col-md-6">
|
||||||
|
<label className="form-label fw-bold">Cidade</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Digite a cidade..."
|
||||||
|
value={filtroCidade}
|
||||||
|
onChange={(e) => setFiltroCidade(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<label className="form-label fw-bold">Estado</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Ex: Minas Gerais"
|
||||||
|
value={filtroEstado}
|
||||||
|
onChange={(e) => setFiltroEstado(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-md-6">
|
||||||
|
<label className="form-label fw-bold">Idade mínima</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Ex: 25"
|
||||||
|
value={idadeMinima}
|
||||||
|
onChange={(e) => setIdadeMinima(e.target.value)}
|
||||||
|
min="0"
|
||||||
|
max="150"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<label className="form-label fw-bold">Idade máxima</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Ex: 70"
|
||||||
|
value={idadeMaxima}
|
||||||
|
onChange={(e) => setIdadeMaxima(e.target.value)}
|
||||||
|
min="0"
|
||||||
|
max="150"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-md-6">
|
||||||
|
<label className="form-label fw-bold">Data inicial</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
className="form-control"
|
||||||
|
value={dataInicial}
|
||||||
|
onChange={(e) => setDataInicial(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<label className="form-label fw-bold">Data final</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
className="form-control"
|
||||||
|
value={dataFinal}
|
||||||
|
onChange={(e) => setDataFinal(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-6">
|
)}
|
||||||
<label className="form-label fw-bold">Idade máxima</label>
|
|
||||||
<input
|
<div className="mt-3">
|
||||||
type="number"
|
<div className="contador-medicos">
|
||||||
className="form-control form-control-sm"
|
{medicosFiltrados.length} DE {medicos.length} MÉDICOS ENCONTRADOS
|
||||||
placeholder="Ex: 70"
|
|
||||||
value={idadeMaxima}
|
|
||||||
onChange={(e) => setIdadeMaxima(e.target.value)}
|
|
||||||
min="0"
|
|
||||||
max="150"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="col-md-6">
|
|
||||||
<label className="form-label fw-bold">Data inicial</label>
|
|
||||||
<input
|
|
||||||
type="date"
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
value={dataInicial}
|
|
||||||
onChange={(e) => setDataInicial(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="col-md-6">
|
|
||||||
<label className="form-label fw-bold">Data final</label>
|
|
||||||
<input
|
|
||||||
type="date"
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
value={dataFinal}
|
|
||||||
onChange={(e) => setDataFinal(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Contador */}
|
<div className="table-responsive">
|
||||||
<div className="mt-3">
|
<table className="table table-striped table-hover table-doctor-table">
|
||||||
<div className="contador-medicos">
|
<thead>
|
||||||
{medicosFiltrados.length} DE {medicos.length} MÉDICOS ENCONTRADOS
|
<tr>
|
||||||
</div>
|
<th>Nome</th>
|
||||||
</div>
|
<th>CPF</th>
|
||||||
</div>
|
<th>Especialidade</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Ações</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{medicosPaginados.length > 0 ? (
|
||||||
|
medicosPaginados.map((medico) => (
|
||||||
|
<tr key={medico.id}>
|
||||||
|
<td>
|
||||||
|
<div className="d-flex align-items-center">
|
||||||
|
{medico.full_name}
|
||||||
|
{ehAniversariante(medico.birth_date) && (
|
||||||
|
<span className="badge anniversary-badge ms-2" title="Aniversariante do dia">
|
||||||
|
<i className="bi bi-gift"></i>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>{medico.cpf}</td>
|
||||||
|
<td>
|
||||||
|
<span className="badge specialty-badge">
|
||||||
|
{medico.specialty || 'Não informado'}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>{medico.email || 'Não informado'}</td>
|
||||||
|
<td>
|
||||||
|
<div className="d-flex gap-2">
|
||||||
|
<Link to={`details/${medico.id}`}>
|
||||||
|
<button className="btn btn-sm btn-view" onClick={() => setDictInfo({...medico})}>
|
||||||
|
<i className="bi bi-eye me-1"></i> Ver Detalhes
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
|
|
||||||
{/* ===== TABELA SIMPLIFICADA ===== */}
|
<Link to={`edit/${medico.id}`}>
|
||||||
<div className="table-responsive mt-4">
|
<button className="btn btn-sm btn-edit" onClick={() => setDictInfo({...medico})}>
|
||||||
<table className="table table-striped table-hover table-doctor-table">
|
<i className="bi bi-pencil me-1"></i> Editar
|
||||||
<thead>
|
</button>
|
||||||
<tr>
|
</Link>
|
||||||
<th>Nome</th>
|
|
||||||
<th>CPF</th>
|
<button
|
||||||
<th>Especialidade</th>
|
className="btn btn-sm btn-delete"
|
||||||
<th>Email</th>
|
onClick={() => {
|
||||||
<th>Ações</th>
|
setSelectedDoctorId(medico.id);
|
||||||
</tr>
|
setShowDeleteModal(true);
|
||||||
</thead>
|
}}
|
||||||
<tbody>
|
>
|
||||||
{medicosPaginados.length > 0 ? (
|
<i className="bi bi-trash me-1"></i> Excluir
|
||||||
medicosPaginados.map((medico) => (
|
</button>
|
||||||
<tr key={medico.id}>
|
</div>
|
||||||
<td>
|
</td>
|
||||||
<div className="d-flex align-items-center patient-name-container">
|
</tr>
|
||||||
{medico.full_name}
|
))
|
||||||
<div className="d-flex patient-badges ms-2">
|
) : (
|
||||||
{ehAniversariante(medico.birth_date) && (
|
<tr>
|
||||||
<span className="badge anniversary-badge ms-1" title="Aniversariante do dia">
|
<td colSpan="5" className="text-center py-4">
|
||||||
<i className="bi bi-gift me-1"></i>
|
<div className="text-muted">
|
||||||
</span>
|
<i className="bi bi-search display-4"></i>
|
||||||
|
<p className="mt-2">Nenhum médico encontrado com os filtros aplicados.</p>
|
||||||
|
{(search || filtroEspecialidade !== "Todos" || filtroAniversariante ||
|
||||||
|
filtroCidade || filtroEstado || idadeMinima || idadeMaxima || dataInicial || dataFinal) && (
|
||||||
|
<button className="btn btn-outline-primary btn-sm mt-2" onClick={limparFiltros}>
|
||||||
|
Limpar filtros
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
<td>{medico.cpf}</td>
|
)}
|
||||||
<td>
|
</tbody>
|
||||||
<span className="badge specialty-badge">
|
</table>
|
||||||
{medico.specialty || 'Não informado'}
|
|
||||||
</span>
|
{medicosFiltrados.length > 0 && (
|
||||||
</td>
|
<div className="d-flex justify-content-between align-items-center mt-3">
|
||||||
<td>{medico.email || 'Não informado'}</td>
|
<div className="d-flex align-items-center">
|
||||||
<td>
|
<span className="me-2 text-muted">Itens por página:</span>
|
||||||
<div className="d-flex gap-2">
|
<select
|
||||||
<button
|
className="form-select form-select-sm w-auto"
|
||||||
className="btn btn-sm btn-view"
|
value={itensPorPagina}
|
||||||
onClick={() => {
|
onChange={(e) => {
|
||||||
setDictInfo(medico);
|
setItensPorPagina(Number(e.target.value));
|
||||||
navigate('details');
|
setPaginaAtual(1);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<i className="bi bi-eye me-1"></i> Ver
|
<option value={5}>5</option>
|
||||||
</button>
|
<option value={10}>10</option>
|
||||||
<button
|
<option value={25}>25</option>
|
||||||
className="btn btn-sm btn-edit"
|
<option value={50}>50</option>
|
||||||
onClick={() => {
|
</select>
|
||||||
setDictInfo(medico);
|
</div>
|
||||||
navigate('edit');
|
|
||||||
}}
|
<div className="d-flex align-items-center">
|
||||||
>
|
<span className="me-3 text-muted">
|
||||||
<i className="bi bi-pencil me-1"></i> Editar
|
Página {paginaAtual} de {totalPaginas} •
|
||||||
</button>
|
Mostrando {indiceInicial + 1}-{Math.min(indiceFinal, medicosFiltrados.length)} de {medicosFiltrados.length} médicos
|
||||||
<button
|
</span>
|
||||||
className="btn btn-sm btn-delete"
|
|
||||||
onClick={() => {
|
<nav>
|
||||||
setSelectedDoctorId(medico.id);
|
<ul className="pagination pagination-sm mb-0">
|
||||||
setShowDeleteModal(true);
|
<li className={`page-item ${paginaAtual === 1 ? 'disabled' : ''}`}>
|
||||||
}}
|
<button className="page-link" onClick={voltarPagina}>
|
||||||
>
|
<i className="bi bi-chevron-left"></i>
|
||||||
<i className="bi bi-trash me-1"></i> Excluir
|
</button>
|
||||||
</button>
|
</li>
|
||||||
</div>
|
|
||||||
</td>
|
{gerarNumerosPaginas().map(pagina => (
|
||||||
</tr>
|
<li key={pagina} className={`page-item ${pagina === paginaAtual ? 'active' : ''}`}>
|
||||||
))
|
<button className="page-link" onClick={() => irParaPagina(pagina)}>
|
||||||
) : (
|
{pagina}
|
||||||
<tr>
|
</button>
|
||||||
<td colSpan="5" className="text-center py-4">
|
</li>
|
||||||
<div className="text-muted">
|
))}
|
||||||
<i className="bi bi-search display-4"></i>
|
|
||||||
<p className="mt-2">Nenhum médico encontrado com os filtros aplicados.</p>
|
<li className={`page-item ${paginaAtual === totalPaginas ? 'disabled' : ''}`}>
|
||||||
{(search || filtroEspecialidade !== "Todos" || filtroAniversariante ||
|
<button className="page-link" onClick={avancarPagina}>
|
||||||
filtroCidade || filtroEstado || idadeMinima || idadeMaxima || dataInicial || dataFinal) && (
|
<i className="bi bi-chevron-right"></i>
|
||||||
<button className="btn btn-outline-primary btn-sm mt-2" onClick={limparFiltros}>
|
</button>
|
||||||
Limpar filtros
|
</li>
|
||||||
</button>
|
</ul>
|
||||||
)}
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</div>
|
||||||
</tr>
|
|
||||||
)}
|
)}
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{/* ===== PAGINAÇÃO ===== */}
|
|
||||||
{medicosFiltrados.length > 0 && (
|
|
||||||
<div className="d-flex justify-content-between align-items-center mt-3">
|
|
||||||
<div className="d-flex align-items-center">
|
|
||||||
<span className="me-2 text-muted">Itens por página:</span>
|
|
||||||
<select
|
|
||||||
className="form-select form-select-sm w-auto"
|
|
||||||
value={itensPorPagina}
|
|
||||||
onChange={(e) => {
|
|
||||||
setItensPorPagina(Number(e.target.value));
|
|
||||||
setPaginaAtual(1);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<option value={5}>5</option>
|
|
||||||
<option value={10}>10</option>
|
|
||||||
<option value={25}>25</option>
|
|
||||||
<option value={50}>50</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex align-items-center">
|
|
||||||
<span className="me-3 text-muted">
|
|
||||||
Página {paginaAtual} de {totalPaginas} •
|
|
||||||
Mostrando {indiceInicial + 1}-{Math.min(indiceFinal, medicosFiltrados.length)} de {medicosFiltrados.length} médicos
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<nav>
|
|
||||||
<ul className="pagination pagination-sm mb-0">
|
|
||||||
<li className={`page-item ${paginaAtual === 1 ? 'disabled' : ''}`}>
|
|
||||||
<button className="page-link" onClick={voltarPagina}>
|
|
||||||
<i className="bi bi-chevron-left"></i>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{gerarNumerosPaginas().map(pagina => (
|
|
||||||
<li key={pagina} className={`page-item ${pagina === paginaAtual ? 'active' : ''}`}>
|
|
||||||
<button className="page-link" onClick={() => irParaPagina(pagina)}>
|
|
||||||
{pagina}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<li className={`page-item ${paginaAtual === totalPaginas ? 'disabled' : ''}`}>
|
|
||||||
<button className="page-link" onClick={avancarPagina}>
|
|
||||||
<i className="bi bi-chevron-right"></i>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* ===== MODAL DE EXCLUSÃO ===== */}
|
|
||||||
{showDeleteModal && (
|
{showDeleteModal && (
|
||||||
<div
|
<div
|
||||||
className="modal fade show delete-modal"
|
className="modal fade show delete-modal"
|
||||||
style={{ display: "block", backgroundColor: "rgba(0, 0, 0, 0.5)" }}
|
style={{
|
||||||
|
display: "block",
|
||||||
|
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
||||||
|
}}
|
||||||
tabIndex="-1"
|
tabIndex="-1"
|
||||||
onClick={(e) => e.target.classList.contains("modal") && setShowDeleteModal(false)}
|
onClick={(e) =>
|
||||||
|
e.target.classList.contains("modal") && setShowDeleteModal(false)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<div className="modal-dialog modal-dialog-centered">
|
<div className="modal-dialog modal-dialog-centered">
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-header" style={{ backgroundColor: '#dc3545', color: 'white' }}>
|
<div className="modal-header" style={{ backgroundColor: '#dc3545', color: 'white' }}>
|
||||||
<h5 className="modal-title">Confirmação de Exclusão</h5>
|
<h5 className="modal-title">
|
||||||
|
Confirmação de Exclusão
|
||||||
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<p className="mb-0 fs-5">Tem certeza que deseja excluir este médico?</p>
|
<p className="mb-0 fs-5">
|
||||||
<p className="text-muted mt-2">Esta ação não pode ser desfeita.</p>
|
Tem certeza que deseja excluir este médico?
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="modal-footer">
|
<div className="modal-footer">
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import html2pdf from 'html2pdf.js';
|
import html2pdf from 'html2pdf.js';
|
||||||
import TiptapViewer from '../PagesMedico/TiptapViewer'
|
import TiptapViewer from '../PagesMedico/TiptapViewer'
|
||||||
import '../PagesMedico/styleMedico/DoctorRelatorioManager.css';
|
import '../PagesMedico/styleMedico/DoctorRelatorioManager.css';
|
||||||
import './style/TableDoctor.css';
|
|
||||||
|
|
||||||
const LaudoManager = () => {
|
const LaudoManager = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -32,8 +31,6 @@ const LaudoManager = () => {
|
|||||||
|
|
||||||
const [paginaAtual, setPaginaAtual] = useState(1);
|
const [paginaAtual, setPaginaAtual] = useState(1);
|
||||||
const [itensPorPagina, setItensPorPagina] = useState(10);
|
const [itensPorPagina, setItensPorPagina] = useState(10);
|
||||||
const [sortKey, setSortKey] = useState(null);
|
|
||||||
const [sortDir, setSortDir] = useState('asc');
|
|
||||||
|
|
||||||
const [noPermissionText, setNoPermissionText] = useState(null);
|
const [noPermissionText, setNoPermissionText] = useState(null);
|
||||||
|
|
||||||
@ -131,25 +128,9 @@ const LaudoManager = () => {
|
|||||||
const limparFiltros = () => {
|
const limparFiltros = () => {
|
||||||
setTermoPesquisa('');
|
setTermoPesquisa('');
|
||||||
setFiltroExame('');
|
setFiltroExame('');
|
||||||
setSortKey(null);
|
|
||||||
setSortDir('asc');
|
|
||||||
setRelatoriosFinais(relatoriosOriginais);
|
setRelatoriosFinais(relatoriosOriginais);
|
||||||
};
|
};
|
||||||
|
|
||||||
const applySorting = (arr) => {
|
|
||||||
if (!Array.isArray(arr) || !sortKey) return arr;
|
|
||||||
const copy = [...arr];
|
|
||||||
if (sortKey === 'paciente') {
|
|
||||||
copy.sort((a, b) => (a.patient_name || '').localeCompare(b.patient_name || ''));
|
|
||||||
} else if (sortKey === 'exame') {
|
|
||||||
copy.sort((a, b) => (a.exam || a.exame || '').localeCompare(b.exam || b.exame || ''));
|
|
||||||
} else if (sortKey === 'data') {
|
|
||||||
copy.sort((a, b) => new Date(a.created_at || 0) - new Date(b.created_at || 0));
|
|
||||||
}
|
|
||||||
if (sortDir === 'desc') copy.reverse();
|
|
||||||
return copy;
|
|
||||||
};
|
|
||||||
|
|
||||||
const BaixarPDFdoRelatorio = (nome_paciente, idx) => {
|
const BaixarPDFdoRelatorio = (nome_paciente, idx) => {
|
||||||
const elemento = document.getElementById(`folhaA4-${idx}`);
|
const elemento = document.getElementById(`folhaA4-${idx}`);
|
||||||
if (!elemento) {
|
if (!elemento) {
|
||||||
@ -234,11 +215,10 @@ const LaudoManager = () => {
|
|||||||
}
|
}
|
||||||
if (ex) items = items.filter(r => (r.exam || r.exame || '').toLowerCase().includes(ex));
|
if (ex) items = items.filter(r => (r.exam || r.exame || '').toLowerCase().includes(ex));
|
||||||
|
|
||||||
const itemsOrdenados = applySorting(items);
|
setRelatoriosFiltrados(items);
|
||||||
setRelatoriosFiltrados(itemsOrdenados);
|
setRelatoriosFinais(items);
|
||||||
setRelatoriosFinais(itemsOrdenados);
|
|
||||||
setPaginaAtual(1);
|
setPaginaAtual(1);
|
||||||
}, [termoPesquisa, filtroExame, relatoriosOriginais, sortKey, sortDir]);
|
}, [termoPesquisa, filtroExame, relatoriosOriginais]);
|
||||||
|
|
||||||
const irParaPagina = (pagina) => setPaginaAtual(pagina);
|
const irParaPagina = (pagina) => setPaginaAtual(pagina);
|
||||||
const avancarPagina = () => { if (paginaAtual < totalPaginas) setPaginaAtual(paginaAtual + 1); };
|
const avancarPagina = () => { if (paginaAtual < totalPaginas) setPaginaAtual(paginaAtual + 1); };
|
||||||
@ -256,118 +236,76 @@ const LaudoManager = () => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="page-heading"><h3>Lista de Relatórios</h3></div>
|
<div className="page-heading"><h3>Lista de Relatórios</h3></div>
|
||||||
|
<div className="page-content">
|
||||||
<div className="page-content table-doctor-container">
|
<section className="row">
|
||||||
<div className="table-doctor-card">
|
<div className="col-12">
|
||||||
<div className="card-header d-flex justify-content-between align-items-center">
|
<div className="card">
|
||||||
<h4 className="card-title mb-0">Relatórios Cadastrados</h4>
|
<div className="card-header d-flex justify-content-between align-items-center">
|
||||||
<button
|
<h4 className="card-title mb-0">Relatórios Cadastrados</h4>
|
||||||
className="btn btn-primary"
|
<div>
|
||||||
onClick={() => setNoPermissionText('Sem permissão para editar/criar laudo.')}
|
<button
|
||||||
title="Secretaria não pode criar relatórios"
|
className="btn btn-primary"
|
||||||
>
|
onClick={() => setNoPermissionText('Sem permissão para editar/criar laudo.')}
|
||||||
<i className="bi bi-plus-circle"></i> Adicionar Relatório
|
title="Secretaria não pode criar relatórios"
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="card-body">
|
|
||||||
{/* ===== FILTROS PADRONIZADOS ===== */}
|
|
||||||
<div className="table-doctor-filters">
|
|
||||||
<h5 className="mb-3">
|
|
||||||
<i className="bi bi-funnel-fill me-2 text-primary"></i> Filtros
|
|
||||||
</h5>
|
|
||||||
|
|
||||||
{/* Busca */}
|
|
||||||
<div className="mb-3">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control"
|
|
||||||
placeholder="Buscar por nome ou CPF do paciente..."
|
|
||||||
value={termoPesquisa}
|
|
||||||
onChange={(e) => setTermoPesquisa(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Linha de Filtros Básicos */}
|
|
||||||
<div className="d-flex flex-wrap align-items-center gap-3 mb-3">
|
|
||||||
{/* Tipo de Exame */}
|
|
||||||
<div className="d-flex align-items-center gap-2">
|
|
||||||
<label className="form-label mb-0 text-muted small">Tipo de Exame:</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control form-control-sm compact-select"
|
|
||||||
placeholder="Filtrar por exame..."
|
|
||||||
value={filtroExame}
|
|
||||||
onChange={(e) => setFiltroExame(e.target.value)}
|
|
||||||
style={{ minWidth: "180px" }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Separador */}
|
|
||||||
<div className="vr d-none d-md-block" style={{ height: "30px" }} />
|
|
||||||
|
|
||||||
{/* Ordenação */}
|
|
||||||
<div className="d-flex align-items-center gap-2">
|
|
||||||
<label className="form-label mb-0 text-muted small">Ordenar por:</label>
|
|
||||||
<select
|
|
||||||
className="form-select form-select-sm compact-select sort-select"
|
|
||||||
value={sortKey ? `${sortKey}-${sortDir}` : ''}
|
|
||||||
onChange={(e) => {
|
|
||||||
const v = e.target.value;
|
|
||||||
if (!v) {
|
|
||||||
setSortKey(null);
|
|
||||||
setSortDir('asc');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const [k, d] = v.split('-');
|
|
||||||
setSortKey(k);
|
|
||||||
setSortDir(d);
|
|
||||||
}}
|
|
||||||
style={{ minWidth: "180px" }}
|
|
||||||
>
|
>
|
||||||
<option value="">Sem ordenação</option>
|
<i className="bi bi-plus-circle"></i> Adicionar Relatório
|
||||||
<option value="paciente-asc">Paciente (A-Z)</option>
|
</button>
|
||||||
<option value="paciente-desc">Paciente (Z-A)</option>
|
|
||||||
<option value="exame-asc">Exame (A-Z)</option>
|
|
||||||
<option value="exame-desc">Exame (Z-A)</option>
|
|
||||||
<option value="data-asc">Data (mais antiga)</option>
|
|
||||||
<option value="data-desc">Data (mais recente)</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Linha de Ações */}
|
<div className="card-body">
|
||||||
<div className="d-flex justify-content-end align-items-center">
|
<div className="card p-3 mb-3">
|
||||||
<button
|
<h5 className="mb-3">
|
||||||
className="btn btn-outline-secondary btn-sm d-flex align-items-center"
|
<i className="bi bi-funnel-fill me-2 text-primary"></i> Filtros
|
||||||
onClick={limparFiltros}
|
</h5>
|
||||||
>
|
<div className="row">
|
||||||
<i className="bi bi-arrow-clockwise me-1"></i> Limpar Filtros
|
<div className="col-md-5">
|
||||||
</button>
|
<div className="mb-3">
|
||||||
</div>
|
<label className="form-label">Buscar por nome ou CPF do paciente</label>
|
||||||
|
<input
|
||||||
{/* Contador */}
|
type="text"
|
||||||
<div className="mt-3">
|
className="form-control"
|
||||||
<div className="contador-medicos">
|
placeholder="Digite nome ou CPF do paciente..."
|
||||||
{relatoriosFinais.length} DE {relatoriosOriginais.length} RELATÓRIOS ENCONTRADOS
|
value={termoPesquisa}
|
||||||
|
onChange={(e) => setTermoPesquisa(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-5">
|
||||||
|
<div className="mb-3">
|
||||||
|
<label className="form-label">Filtrar por tipo de exame</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Digite o tipo de exame..."
|
||||||
|
value={filtroExame}
|
||||||
|
onChange={(e) => setFiltroExame(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-2 d-flex align-items-end">
|
||||||
|
<button className="btn btn-outline-secondary w-100" onClick={limparFiltros}>
|
||||||
|
<i className="bi bi-arrow-clockwise"></i> Limpar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mt-2">
|
||||||
|
<div className="contador-relatorios">
|
||||||
|
{relatoriosFinais.length} DE {relatoriosOriginais.length} RELATÓRIOS ENCONTRADOS
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* ===== TABELA SIMPLIFICADA ===== */}
|
<div className="table-responsive">
|
||||||
<div className="table-responsive mt-4">
|
<table className="table table-striped table-hover">
|
||||||
|
<thead>
|
||||||
{/* ===== TABELA SIMPLIFICADA ===== */}
|
<tr>
|
||||||
<div className="table-responsive mt-4">
|
<th>Paciente</th>
|
||||||
<table className="table table-striped table-hover table-doctor-table">
|
<th>CPF</th>
|
||||||
<thead>
|
<th>Exame</th>
|
||||||
<tr>
|
<th></th>
|
||||||
<th>Paciente</th>
|
</tr>
|
||||||
<th>CPF</th>
|
</thead>
|
||||||
<th>Exame</th>
|
|
||||||
<th>Ações</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
{relatoriosPaginados.length > 0 ? (
|
{relatoriosPaginados.length > 0 ? (
|
||||||
relatoriosPaginados.map((relatorio, index) => {
|
relatoriosPaginados.map((relatorio, index) => {
|
||||||
@ -387,6 +325,8 @@ const LaudoManager = () => {
|
|||||||
<i className="bi bi-pencil me-1"></i> Editar
|
<i className="bi bi-pencil me-1"></i> Editar
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<button className="btn btn-sm btn-protocolo" onClick={() => handleOpenProtocol(relatorio, index)}>
|
<button className="btn btn-sm btn-protocolo" onClick={() => handleOpenProtocol(relatorio, index)}>
|
||||||
<i className="bi bi-send me-1"></i> Protocolo
|
<i className="bi bi-send me-1"></i> Protocolo
|
||||||
</button>
|
</button>
|
||||||
@ -400,19 +340,11 @@ const LaudoManager = () => {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
) : (
|
) : (
|
||||||
<tr>
|
<tr><td colSpan="4" className="text-center">Nenhum relatório encontrado.</td></tr>
|
||||||
<td colSpan="4" className="text-center py-4">
|
|
||||||
<div className="text-muted">
|
|
||||||
<i className="bi bi-search display-4"></i>
|
|
||||||
<p className="mt-2">Nenhum relatório encontrado.</p>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{/* ===== PAGINAÇÃO ===== */}
|
|
||||||
{relatoriosFinais.length > 0 && (
|
{relatoriosFinais.length > 0 && (
|
||||||
<div className="d-flex justify-content-between align-items-center mt-3">
|
<div className="d-flex justify-content-between align-items-center mt-3">
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
@ -432,13 +364,13 @@ const LaudoManager = () => {
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
<span className="me-3 text-muted">
|
<span className="me-3 text-muted">
|
||||||
Página {paginaAtual} de {totalPaginas} •
|
Página {paginaAtual} de {totalPaginas} •
|
||||||
Mostrando {indiceInicial + 1}-{Math.min(indiceFinal, relatoriosFinais.length)} de {relatoriosFinais.length} relatórios
|
Mostrando {indiceInicial + 1}-{Math.min(indiceFinal, relatoriosFinais.length)} de {relatoriosFinais.length} itens
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<ul className="pagination pagination-sm mb-0">
|
<ul className="pagination pagination-sm mb-0">
|
||||||
<li className={`page-item ${paginaAtual === 1 ? 'disabled' : ''}`}>
|
<li className={`page-item ${paginaAtual === 1 ? 'disabled' : ''}`}>
|
||||||
<button className="page-link" onClick={voltarPagina}>
|
<button className="page-link" onClick={voltarPagina}>
|
||||||
@ -468,7 +400,8 @@ const LaudoManager = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{showModal && relatorioModal && (
|
{showModal && relatorioModal && (
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
import React, { useState, useEffect, useCallback, useRef } from "react";
|
import React, { useState, useEffect, useCallback } from "react";
|
||||||
import { useLocation, useNavigate } from "react-router-dom";
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
import API_KEY from "../components/utils/apiKeys";
|
|
||||||
import { UserInfos } from "../components/utils/Functions-Endpoints/General";
|
|
||||||
import "./style/ProfilePage.css";
|
import "./style/ProfilePage.css";
|
||||||
|
|
||||||
const ROLES = {
|
const ROLES = {
|
||||||
@ -31,9 +29,6 @@ const ProfilePage = () => {
|
|||||||
const [avatarUrl, setAvatarUrl] = useState(null);
|
const [avatarUrl, setAvatarUrl] = useState(null);
|
||||||
const [isEditingName, setIsEditingName] = useState(false);
|
const [isEditingName, setIsEditingName] = useState(false);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
const [userId, setUserId] = useState(null);
|
|
||||||
const [uploadingAvatar, setUploadingAvatar] = useState(false);
|
|
||||||
const fileInputRef = useRef(null);
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -47,62 +42,22 @@ const ProfilePage = () => {
|
|||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadProfileData = async () => {
|
const loadProfileData = () => {
|
||||||
try {
|
const localAvatar = localStorage.getItem('user_avatar');
|
||||||
const token = localStorage.getItem('access_token') || localStorage.getItem('token') || localStorage.getItem('authToken') || sessionStorage.getItem('token');
|
if (localAvatar) {
|
||||||
|
setAvatarUrl(localAvatar);
|
||||||
if (!token) return;
|
|
||||||
|
|
||||||
const userInfo = await UserInfos(`Bearer ${token}`);
|
|
||||||
|
|
||||||
const userIdFromInfo = userInfo?.id || userInfo?.user?.id || userInfo?.sub;
|
|
||||||
const userFullName =
|
|
||||||
userInfo?.full_name ||
|
|
||||||
userInfo?.user?.full_name ||
|
|
||||||
userInfo?.profile?.full_name ||
|
|
||||||
userInfo?.user?.user_metadata?.full_name ||
|
|
||||||
'Usuário';
|
|
||||||
const email = userInfo?.user?.email || userInfo?.email || 'email@example.com';
|
|
||||||
|
|
||||||
setUserId(userIdFromInfo);
|
|
||||||
setUserName(userFullName);
|
|
||||||
setUserEmail(email);
|
|
||||||
|
|
||||||
if (!userIdFromInfo) return;
|
|
||||||
|
|
||||||
const avatarPath = `${userIdFromInfo}/avatar.jpg`;
|
|
||||||
|
|
||||||
const myHeaders = new Headers();
|
|
||||||
myHeaders.append('apikey', API_KEY);
|
|
||||||
myHeaders.append('Authorization', `Bearer ${token}`);
|
|
||||||
|
|
||||||
const response = await fetch(
|
|
||||||
`https://yuanqfswhberkoevtmfr.supabase.co/storage/v1/object/public/avatars/${avatarPath}`,
|
|
||||||
{ method: 'GET', headers: myHeaders, redirect: 'follow' }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
const blob = await response.blob();
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
setAvatarUrl(url);
|
|
||||||
} else {
|
|
||||||
const authResponse = await fetch(
|
|
||||||
`https://yuanqfswhberkoevtmfr.supabase.co/storage/v1/object/avatars/${avatarPath}`,
|
|
||||||
{ method: 'GET', headers: myHeaders, redirect: 'follow' }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (authResponse.ok) {
|
|
||||||
const blob = await authResponse.blob();
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
setAvatarUrl(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.warn('Erro ao carregar perfil:', err);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
loadProfileData();
|
loadProfileData();
|
||||||
|
|
||||||
|
|
||||||
|
const handleStorageChange = () => {
|
||||||
|
loadProfileData();
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('storage', handleStorageChange);
|
||||||
|
return () => window.removeEventListener('storage', handleStorageChange);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleNameSave = () => {
|
const handleNameSave = () => {
|
||||||
@ -126,73 +81,6 @@ const ProfilePage = () => {
|
|||||||
|
|
||||||
const handleClose = () => navigate(-1);
|
const handleClose = () => navigate(-1);
|
||||||
|
|
||||||
const handleAvatarClick = () => {
|
|
||||||
if (fileInputRef.current) {
|
|
||||||
fileInputRef.current.click();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleAvatarUpload = async (event) => {
|
|
||||||
const file = event.target.files?.[0];
|
|
||||||
if (!file) return;
|
|
||||||
|
|
||||||
if (!file.type.startsWith('image/')) {
|
|
||||||
alert('Por favor, selecione um arquivo de imagem válido.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file.size > 5 * 1024 * 1024) {
|
|
||||||
alert('A imagem deve ter no máximo 5MB.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
setUploadingAvatar(true);
|
|
||||||
|
|
||||||
if (!userId) {
|
|
||||||
alert('Usuário não identificado. Faça login novamente.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const avatarPath = `${userId}/avatar.jpg`;
|
|
||||||
const token = localStorage.getItem('access_token') || localStorage.getItem('token') || localStorage.getItem('authToken') || sessionStorage.getItem('token');
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('file', file);
|
|
||||||
|
|
||||||
const myHeaders = new Headers();
|
|
||||||
myHeaders.append('apikey', API_KEY);
|
|
||||||
if (token) myHeaders.append('Authorization', `Bearer ${token}`);
|
|
||||||
|
|
||||||
const response = await fetch(
|
|
||||||
`https://yuanqfswhberkoevtmfr.supabase.co/storage/v1/object/avatars/${avatarPath}`,
|
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
headers: myHeaders,
|
|
||||||
body: formData,
|
|
||||||
redirect: 'follow'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
const url = URL.createObjectURL(file);
|
|
||||||
setAvatarUrl(url);
|
|
||||||
alert('Avatar atualizado com sucesso!');
|
|
||||||
window.dispatchEvent(new Event('storage'));
|
|
||||||
} else {
|
|
||||||
const errorText = await response.text();
|
|
||||||
console.error('Erro ao fazer upload:', errorText);
|
|
||||||
alert('Erro ao fazer upload do avatar. Tente novamente.');
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Erro no upload:', err);
|
|
||||||
alert('Erro ao fazer upload do avatar. Tente novamente.');
|
|
||||||
} finally {
|
|
||||||
setUploadingAvatar(false);
|
|
||||||
if (fileInputRef.current) fileInputRef.current.value = '';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="profile-overlay" role="dialog" aria-modal="true">
|
<div className="profile-overlay" role="dialog" aria-modal="true">
|
||||||
<div className="profile-modal">
|
<div className="profile-modal">
|
||||||
@ -206,53 +94,33 @@ const ProfilePage = () => {
|
|||||||
|
|
||||||
<div className="profile-content">
|
<div className="profile-content">
|
||||||
<div className="profile-left">
|
<div className="profile-left">
|
||||||
<input
|
|
||||||
ref={fileInputRef}
|
|
||||||
type="file"
|
|
||||||
accept="image/*"
|
|
||||||
onChange={handleAvatarUpload}
|
|
||||||
style={{ display: 'none' }}
|
|
||||||
/>
|
|
||||||
<div className="avatar-wrapper">
|
<div className="avatar-wrapper">
|
||||||
<div className="avatar-square">
|
<div className="avatar-square">
|
||||||
{uploadingAvatar ? (
|
{avatarUrl ? (
|
||||||
<div className="avatar-placeholder" style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '24px' }}>
|
|
||||||
<span>⏳</span>
|
|
||||||
</div>
|
|
||||||
) : avatarUrl ? (
|
|
||||||
<img
|
<img
|
||||||
src={avatarUrl}
|
src={avatarUrl}
|
||||||
alt="Avatar do usuário"
|
alt="Avatar do usuário"
|
||||||
className="avatar-img"
|
className="avatar-img"
|
||||||
onError={() => {
|
onError={() => {
|
||||||
setAvatarUrl(null);
|
setAvatarUrl(null);
|
||||||
|
localStorage.removeItem('user_avatar');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="avatar-placeholder">
|
<div className="avatar-placeholder">
|
||||||
{(() => {
|
{userName.split(' ').map(n => n[0]).join('').toUpperCase()}
|
||||||
const words = userName.trim().split(/\s+/).filter(w => w.length > 0);
|
|
||||||
if (words.length >= 2) {
|
|
||||||
return words.slice(0, 2).map(w => w[0]).join('');
|
|
||||||
} else if (words.length === 1 && words[0].length >= 2) {
|
|
||||||
return words[0].substring(0, 2);
|
|
||||||
} else {
|
|
||||||
return words[0]?.[0] || 'U';
|
|
||||||
}
|
|
||||||
})()}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<p style={{
|
||||||
onClick={handleAvatarClick}
|
textAlign: 'center',
|
||||||
className="btn btn-primary mt-3"
|
marginTop: '10px',
|
||||||
style={{ width: '100%' }}
|
fontSize: '0.85rem',
|
||||||
disabled={uploadingAvatar}
|
color: '#666'
|
||||||
>
|
}}>
|
||||||
<i className="bi bi-camera me-2"></i>
|
Gerencie seu avatar no menu do perfil acima
|
||||||
{uploadingAvatar ? 'Enviando...' : 'Alterar Foto'}
|
</p>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -57,7 +57,7 @@
|
|||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-bottom: 2px solid transparent;
|
border-bottom: 2px solid transparent;
|
||||||
padding: 12px 24px;
|
padding: 10px 12px;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #718096;
|
color: #718096;
|
||||||
@ -108,7 +108,9 @@
|
|||||||
font-family: 'Inter', sans-serif;
|
font-family: 'Inter', sans-serif;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.calendar-info-panel { flex: 0 0 300px; border-right: 1px solid #E2E8F0; padding-right: 24px; display: flex; flex-direction: column; }
|
.calendar-info-panel { flex: 0 0 300px; border-right: 1px solid #E2E8F0; padding-right: 24px; display: flex; flex-direction: column; }
|
||||||
|
|
||||||
.info-date-display { background-color: #EDF2F7; border-radius: 8px; padding: 12px; text-align: center; margin-bottom: 16px; }
|
.info-date-display { background-color: #EDF2F7; border-radius: 8px; padding: 12px; text-align: center; margin-bottom: 16px; }
|
||||||
.info-date-display span { font-weight: 600; color: #718096; text-transform: uppercase; font-size: 0.9rem; }
|
.info-date-display span { font-weight: 600; color: #718096; text-transform: uppercase; font-size: 0.9rem; }
|
||||||
.info-date-display strong { display: block; font-size: 2.5rem; font-weight: 700; color: #2D3748; }
|
.info-date-display strong { display: block; font-size: 2.5rem; font-weight: 700; color: #2D3748; }
|
||||||
@ -135,6 +137,7 @@
|
|||||||
.nav-buttons button { padding: 8px 12px; border-radius: 6px; border: 1px solid #CBD5E0; background-color: #fff; font-weight: 600; cursor: pointer; transition: all 0.2s; }
|
.nav-buttons button { padding: 8px 12px; border-radius: 6px; border: 1px solid #CBD5E0; background-color: #fff; font-weight: 600; cursor: pointer; transition: all 0.2s; }
|
||||||
.nav-buttons button:hover { background-color: #EDF2F7; }
|
.nav-buttons button:hover { background-color: #EDF2F7; }
|
||||||
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
|
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
|
||||||
|
|
||||||
.day-header { font-weight: 600; color: #718096; text-align: center; padding: 8px 0; font-size: 0.875rem; }
|
.day-header { font-weight: 600; color: #718096; text-align: center; padding: 8px 0; font-size: 0.875rem; }
|
||||||
.day-cell { min-height: 110px; border-radius: 8px; border: 1px solid #E2E8F0; padding: 8px; transition: background-color 0.2s, border-color 0.2s; cursor: pointer; position: relative; }
|
.day-cell { min-height: 110px; border-radius: 8px; border: 1px solid #E2E8F0; padding: 8px; transition: background-color 0.2s, border-color 0.2s; cursor: pointer; position: relative; }
|
||||||
.day-cell span { font-weight: 600; color: #4A5568; }
|
.day-cell span { font-weight: 600; color: #4A5568; }
|
||||||
@ -181,7 +184,6 @@
|
|||||||
color: #C53030;
|
color: #C53030;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.appointment-item {
|
.appointment-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -224,81 +226,194 @@
|
|||||||
background-color: #C53030;
|
background-color: #C53030;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table-wrapper {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
min-width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.unidade-selecionarprofissional { flex-direction: column; align-items: stretch; gap: 12px; }
|
.busca-atendimento {
|
||||||
.calendar-wrapper { flex-direction: column; padding: 16px; }
|
flex-direction: column;
|
||||||
.calendar-info-panel { flex: 0 0 auto; border-right: none; border-bottom: 1px solid #E2E8F0; padding-right: 0; padding-bottom: 16px; }
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-btns-agenda-fila_esepera {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btns-gerenciamento-e-consulta {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-adicionar-consulta {
|
||||||
|
padding: 8px 12px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
white-space: normal;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unidade-selecionarprofissional {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar-wrapper {
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar-info-panel {
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: 1px solid #E2E8F0;
|
||||||
|
padding-right: 0;
|
||||||
|
padding-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
.calendar-grid { grid-template-columns: repeat(4, 1fr); }
|
.calendar-grid { grid-template-columns: repeat(4, 1fr); }
|
||||||
.calendar-controls { flex-direction: column; align-items: flex-start; gap: 8px; }
|
.calendar-controls { flex-direction: column; align-items: flex-start; gap: 8px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 576px) {
|
@media (max-width: 576px) {
|
||||||
.calendar-grid { grid-template-columns: repeat(2, 1fr); }
|
.calendar-grid { grid-template-columns: 1fr; }
|
||||||
.date-indicator h2 { font-size: 1.25rem; }
|
.date-indicator h2 { font-size: 1.25rem; }
|
||||||
.legend-item { font-size: 0.75rem; padding: 4px 8px; }
|
.legend-item { font-size: 0.75rem; padding: 4px 8px; }
|
||||||
.appointment-item { flex-direction: column; align-items: stretch; gap: 8px; }
|
.appointment-item { flex-direction: column; align-items: stretch; gap: 8px; }
|
||||||
.appointment-actions { width: 100%; }
|
.appointment-actions { width: 100%; }
|
||||||
.btn-action { width: 100%; }
|
.btn-action { width: 100%; }
|
||||||
}
|
}
|
||||||
.btn-adicionar-consulta {
|
|
||||||
background-color: #2a67e2;
|
@media (max-width: 425px) {
|
||||||
color: #fff;
|
.calendar-main {
|
||||||
padding: 10px 24px;
|
overflow-x: auto;
|
||||||
border-radius: 8px;
|
}
|
||||||
border: none;
|
.calendar-grid {
|
||||||
font-weight: 600;
|
min-width: 400px;
|
||||||
font-size: 1rem;
|
grid-template-columns: repeat(7, 1fr);
|
||||||
display: flex;
|
}
|
||||||
align-items: center;
|
.day-cell {
|
||||||
gap: 8px;
|
min-height: 80px;
|
||||||
cursor: pointer;
|
}
|
||||||
transition: background 0.2s;
|
|
||||||
|
|
||||||
|
.table-wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
border: 1px solid #E2E8F0;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
min-width: 600px;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th,
|
||||||
|
table td {
|
||||||
|
padding: 8px;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.btn-adicionar-consulta:hover {
|
|
||||||
background-color: #1d4ed8;
|
|
||||||
}
|
|
||||||
.btn-adicionar-consulta i {
|
|
||||||
font-size: 1.2em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.btn-adicionar-consulta i {
|
|
||||||
font-size: 1.2em;
|
|
||||||
vertical-align: middle;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
}
|
||||||
.container-btns-agenda-fila_esepera {
|
.container-btns-agenda-fila_esepera {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between; /* abas à esquerda, botões à direita */
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 15px 0 20px;
|
gap: 16px; /* opcional: espaço entre os blocos */
|
||||||
color: #fff;
|
width: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
.tabs-agenda-fila {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* garante que os botões fiquem em linha */
|
||||||
.btns-gerenciamento-e-consulta {
|
.btns-gerenciamento-e-consulta {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* em telas muito pequenas, pode empilhar verticalmente */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.container-btns-agenda-fila_esepera {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btns-gerenciamento-e-consulta {
|
||||||
|
justify-content: flex-start; /* ou center se preferir */
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* barra de abas + botões */
|
||||||
.container-btns-agenda-fila_esepera {
|
.container-btns-agenda-fila_esepera {
|
||||||
display: flex;
|
margin-bottom: 0; /* cola com a linha de baixo */
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin: 0 0 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* dá só um respiro pequeno entre as abas e o conteúdo,
|
||||||
|
mas igual para Agenda e Fila de espera */
|
||||||
.calendario-ou-filaespera {
|
.calendario-ou-filaespera {
|
||||||
margin-top: 0;
|
margin-top: 4px; /* aumenta um pouquinho, não 20px */
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* se o título "Fila de Espera" estiver mais distante,
|
||||||
.calendar-wrapper {
|
aproxima só o conteúdo dessa área também */
|
||||||
margin-top: 0;
|
.page-content.table-paciente-container {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
/* 1) container das abas + botões: encostado no topo */
|
||||||
|
.container-btns-agenda-fila_esepera {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2) sempre cria um espaçamento logo DEPOIS das abas,
|
||||||
|
antes de qualquer conteúdo (Agenda ou Fila) */
|
||||||
|
.container-btns-agenda-fila_esepera + .calendario-ou-filaespera {
|
||||||
|
margin-top: 8px; /* aumenta ou diminui aqui */
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 3) garante que o primeiro filho da section não roube/colapse margens */
|
||||||
|
.calendario-ou-filaespera > *:first-child {
|
||||||
|
margin-top: 0 !important;
|
||||||
|
}
|
||||||
|
/* mesmos blocos azuis e quadrados */
|
||||||
|
.btn-consulta-paciente {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center; /* alinha ícone + texto verticalmente */
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px; /* espaço entre ícone e texto */
|
||||||
|
padding: 10px 22px; /* altura/largura parecidas com os azuis */
|
||||||
|
border-radius: 6px; /* se os outros forem 6px, mantém igual */
|
||||||
|
font-weight: 500;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* garante mesma cor dos blocos da secretaria */
|
||||||
|
.btn-consulta-paciente.btn-primary {
|
||||||
|
background-color: #1d4ed8; /* azul escuro do primeiro bloco */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* se quiser hover igual */
|
||||||
|
.btn-consulta-paciente.btn-primary:hover {
|
||||||
|
background-color: #1437a3;
|
||||||
|
}
|
||||||
|
.btn-consulta-paciente {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 10px 22px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-weight: 500;
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
@ -190,6 +190,12 @@ html, body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ===== Fila de Espera ===== */
|
/* ===== Fila de Espera ===== */
|
||||||
|
|
||||||
|
@media (max-width: 992px) {
|
||||||
|
.fila-container {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
.fila-container {
|
.fila-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: none;
|
max-width: none;
|
||||||
@ -286,6 +292,13 @@ html, body {
|
|||||||
transition: border-color 0.2s;
|
transition: border-color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.busca-fila-espera {
|
||||||
|
width: 100%;
|
||||||
|
position: static;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.busca-fila-espera:focus {
|
.busca-fila-espera:focus {
|
||||||
border-color: #888;
|
border-color: #888;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,12 @@
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.summary-card {
|
||||||
|
min-width: 180px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.summary-card {
|
.summary-card {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
@ -232,6 +238,13 @@ html[data-bs-theme="dark"] .btn-delete {
|
|||||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.modal-card {
|
||||||
|
padding: 16px;
|
||||||
|
max-height: 95vh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.modal-header {
|
.modal-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@ -336,6 +349,14 @@ textarea {
|
|||||||
width: 30%;
|
width: 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.financeiro-wrap .input-field:not(.modal-card *),
|
||||||
|
.financeiro-wrap .select-field:not(.modal-card *),
|
||||||
|
.financeiro-wrap textarea:not(.modal-card *) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.modal-card .input-field,
|
.modal-card .input-field,
|
||||||
.modal-card .select-field,
|
.modal-card .select-field,
|
||||||
.modal-card textarea {
|
.modal-card textarea {
|
||||||
|
|||||||
@ -1,3 +1,134 @@
|
|||||||
|
/* Container Principal */
|
||||||
|
|
||||||
|
/* Responsividade */
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.dashboard-container {
|
||||||
|
padding: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.dashboard-container {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-header h1 {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-header p {
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-grid {
|
||||||
|
grid-template-columns: 1fr 1fr; /* 2 colunas em tablets */
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-value {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-icon-wrapper {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-icon {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions-grid {
|
||||||
|
grid-template-columns: 1fr; /* 1 coluna em tablets */
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-icon {
|
||||||
|
font-size: 1.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-title {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appointments-section {
|
||||||
|
padding: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-info {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-time-date {
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 1rem;
|
||||||
|
min-width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-detalhes {
|
||||||
|
min-width: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.dashboard-container {
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-header h1 {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-header p {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-grid {
|
||||||
|
grid-template-columns: 1fr; /* 1 coluna em celulares */
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-value {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-button {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appointments-section {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-item {
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-hora {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-data {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-paciente,
|
||||||
|
.agendamento-medico {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manage-button,
|
||||||
|
.view-all-button {
|
||||||
|
padding: 0.6rem 1.2rem;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Container Principal */
|
/* Container Principal */
|
||||||
.dashboard-container {
|
.dashboard-container {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
|
|||||||
@ -1,114 +1,79 @@
|
|||||||
/* ===== VARIÁVEIS CSS ===== */
|
|
||||||
:root {
|
|
||||||
--primary-color: #1e3a8a;
|
|
||||||
--secondary-color: #3b82f6;
|
|
||||||
--bg-light: #f8f9fa;
|
|
||||||
--border-light: #dee2e6;
|
|
||||||
--text-primary: #495057;
|
|
||||||
--text-muted: #6c757d;
|
|
||||||
--border-radius: 0.375rem;
|
|
||||||
--box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
|
|
||||||
--spacing-sm: 0.5rem;
|
|
||||||
--spacing-md: 1rem;
|
|
||||||
--spacing-lg: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== CONTAINER PRINCIPAL ===== */
|
|
||||||
.table-doctor-container {
|
.table-doctor-container {
|
||||||
padding: 1.5rem;
|
line-height: 2.5;
|
||||||
background-color: white;
|
}
|
||||||
|
|
||||||
|
/* Adiciona responsividade para a tabela */
|
||||||
|
@media (max-width: 992px) {
|
||||||
|
.table-doctor-card {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-doctor-container {
|
||||||
|
line-height: 2.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== CARD ===== */
|
|
||||||
.table-doctor-card {
|
.table-doctor-card {
|
||||||
border: none;
|
border: none;
|
||||||
box-shadow: var(--box-shadow);
|
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
|
||||||
border-radius: var(--border-radius);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-doctor-card .card-header {
|
.table-doctor-card .card-header {
|
||||||
background-color: var(--bg-light);
|
background-color: #f8f9fa;
|
||||||
border-bottom: 1px solid var(--border-light);
|
border-bottom: 1px solid #dee2e6;
|
||||||
padding: 1rem 1.25rem;
|
padding: 1rem 1.25rem;
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-doctor-card .card-header h4 {
|
|
||||||
margin-bottom: 0;
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== FILTROS ===== */
|
|
||||||
.table-doctor-filters {
|
.table-doctor-filters {
|
||||||
background-color: var(--bg-light);
|
background-color: #f8f9fa;
|
||||||
border: 1px solid var(--border-light);
|
border: 1px solid #dee2e6;
|
||||||
border-radius: var(--border-radius);
|
border-radius: 0.375rem;
|
||||||
padding: 1rem;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-doctor-filters h5 {
|
.table-doctor-filters h5 {
|
||||||
color: var(--text-primary);
|
color: #495057;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-bottom: 1rem;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== TABELA ===== */
|
|
||||||
.table-doctor-table {
|
.table-doctor-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-doctor-table th {
|
.table-doctor-table th {
|
||||||
background-color: var(--bg-light);
|
background-color: #f8f9fa;
|
||||||
color: var(--text-primary);
|
color: #495057;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
padding: 15px 8px;
|
padding: 15px 8px;
|
||||||
border-bottom: 2px solid var(--border-light);
|
border-bottom: 2px solid #dee2e6;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
text-align: left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-doctor-table td {
|
.table-doctor-table td {
|
||||||
padding: 15px 8px;
|
padding: 15px 8px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
border-bottom: 1px solid var(--border-light);
|
border-bottom: 1px solid #dee2e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-doctor-table tbody tr:hover {
|
.table-doctor-table tbody tr:hover {
|
||||||
background-color: rgba(0, 0, 0, 0.025);
|
background-color: rgba(0, 0, 0, 0.025);
|
||||||
transition: background-color 0.15s ease-in-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== BADGES ===== */
|
|
||||||
.specialty-badge {
|
.specialty-badge {
|
||||||
background-color: var(--primary-color) !important;
|
background-color: #1e3a8a !important;
|
||||||
color: white !important;
|
color: white !important;
|
||||||
padding: 0.35em 0.65em;
|
padding: 0.35em 0.65em;
|
||||||
font-size: 0.75em;
|
font-size: 0.75em;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-radius: 0.25rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-badge {
|
.results-badge {
|
||||||
padding: 0.35em 0.65em;
|
background-color: #1e3a8a;
|
||||||
font-size: 0.75em;
|
color: white;
|
||||||
|
padding: 0.5em 0.75em;
|
||||||
|
font-size: 0.875em;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-radius: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vip-badge {
|
|
||||||
background-color: #ffc107;
|
|
||||||
color: #000;
|
|
||||||
padding: 0.35em 0.65em;
|
|
||||||
font-size: 0.75em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.anniversary-badge {
|
.anniversary-badge {
|
||||||
@ -118,22 +83,12 @@
|
|||||||
font-size: 0.75em;
|
font-size: 0.75em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.results-badge {
|
|
||||||
background-color: var(--primary-color);
|
|
||||||
color: white;
|
|
||||||
padding: 0.5em 0.75em;
|
|
||||||
font-size: 0.875em;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== BOTÕES DE AÇÃO ===== */
|
|
||||||
.btn-view {
|
.btn-view {
|
||||||
background-color: #E6F2FF !important;
|
background-color: #E6F2FF !important;
|
||||||
color: #004085 !important;
|
color: #004085 !important;
|
||||||
border: 1px solid #B8D4F0;
|
border: 1px solid #B8D4F0;
|
||||||
padding: 0.375rem 0.75rem;
|
padding: 0.375rem 0.75rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
transition: all 0.15s ease-in-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-view:hover {
|
.btn-view:hover {
|
||||||
@ -147,7 +102,6 @@
|
|||||||
border: 1px solid #FFEAA7;
|
border: 1px solid #FFEAA7;
|
||||||
padding: 0.375rem 0.75rem;
|
padding: 0.375rem 0.75rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
transition: all 0.15s ease-in-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-edit:hover {
|
.btn-edit:hover {
|
||||||
@ -161,7 +115,6 @@
|
|||||||
border: 1px solid #F5C6CB;
|
border: 1px solid #F5C6CB;
|
||||||
padding: 0.375rem 0.75rem;
|
padding: 0.375rem 0.75rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
transition: all 0.15s ease-in-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-delete:hover {
|
.btn-delete:hover {
|
||||||
@ -169,71 +122,22 @@
|
|||||||
border-color: #ED969E;
|
border-color: #ED969E;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== CONTADOR ===== */
|
|
||||||
.contador-medicos {
|
|
||||||
background-color: var(--primary-color);
|
|
||||||
color: white;
|
|
||||||
padding: 0.5em 0.75em;
|
|
||||||
font-size: 0.875em;
|
|
||||||
font-weight: 500;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
text-align: center;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== PAGINAÇÃO ===== */
|
|
||||||
.pagination {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-link {
|
|
||||||
color: var(--text-primary);
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
padding: 0.375rem 0.75rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-link:hover {
|
|
||||||
color: var(--primary-color);
|
|
||||||
background-color: #e9ecef;
|
|
||||||
border-color: var(--border-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-item.active .page-link {
|
|
||||||
background-color: var(--primary-color);
|
|
||||||
border-color: var(--primary-color);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-item.disabled .page-link {
|
|
||||||
color: var(--text-muted);
|
|
||||||
background-color: var(--bg-light);
|
|
||||||
border-color: var(--border-light);
|
|
||||||
}
|
|
||||||
/* ===== FILTROS AVANÇADOS ===== */
|
|
||||||
.advanced-filters {
|
.advanced-filters {
|
||||||
border: 1px solid var(--border-light) !important;
|
border: 1px solid #dee2e6;
|
||||||
border-radius: var(--border-radius);
|
border-radius: 0.375rem;
|
||||||
background-color: var(--bg-light);
|
background-color: white;
|
||||||
padding: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.advanced-filters h6 {
|
.advanced-filters h6 {
|
||||||
color: var(--text-primary);
|
color: #495057;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 0.9rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.advanced-filters .form-control-sm {
|
|
||||||
font-size: 0.825rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-label.fw-bold {
|
.form-label.fw-bold {
|
||||||
color: var(--text-primary);
|
color: #495057;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== MODAL DE EXCLUSÃO ===== */
|
|
||||||
.delete-modal .modal-header {
|
.delete-modal .modal-header {
|
||||||
background-color: rgba(220, 53, 69, 0.1);
|
background-color: rgba(220, 53, 69, 0.1);
|
||||||
border-bottom: 1px solid rgba(220, 53, 69, 0.2);
|
border-bottom: 1px solid rgba(220, 53, 69, 0.2);
|
||||||
@ -244,7 +148,6 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== FILTROS ESPECÍFICOS ===== */
|
|
||||||
.filter-especialidade {
|
.filter-especialidade {
|
||||||
min-width: 180px !important;
|
min-width: 180px !important;
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
@ -268,41 +171,59 @@
|
|||||||
gap: 0.75rem;
|
gap: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== SELECTS COMPACTOS ===== */
|
@media (max-width: 576px) {
|
||||||
.form-select-sm.compact-select {
|
.table-doctor-card .card-header { padding: 0.75rem 1rem; }
|
||||||
min-width: 150px;
|
.table-doctor-table th, .table-doctor-table td { padding: 8px 6px; }
|
||||||
border: 1px solid var(--border-light);
|
.table-doctor-table thead th:nth-child(2),
|
||||||
border-radius: var(--border-radius);
|
.table-doctor-table thead th:nth-child(4),
|
||||||
|
.table-doctor-table tbody td:nth-child(2),
|
||||||
|
.table-doctor-table tbody td:nth-child(4) { display: none; }
|
||||||
|
.filter-buttons-container { width: 100%; }
|
||||||
|
.filter-btn { width: 100%; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-select.form-select-sm.w-auto {
|
@media (max-width: 768px) {
|
||||||
border: 1px solid var(--border-light);
|
.table-doctor-table {
|
||||||
border-radius: var(--border-radius);
|
font-size: 0.875rem;
|
||||||
font-size: 0.875rem;
|
}
|
||||||
|
|
||||||
|
.table-doctor-table th,
|
||||||
|
.table-doctor-table td {
|
||||||
|
padding: 10px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-view,
|
||||||
|
.btn-edit,
|
||||||
|
.btn-delete {
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filtros-basicos {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-especialidade {
|
||||||
|
min-width: 100% !important;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-buttons-container {
|
||||||
|
justify-content: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-btn {
|
||||||
|
flex: 1;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-select-sm:focus {
|
|
||||||
border-color: var(--primary-color);
|
|
||||||
box-shadow: 0 0 0 0.2rem rgba(30, 58, 138, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-outline-secondary.btn-sm {
|
|
||||||
border-color: var(--text-muted);
|
|
||||||
color: var(--text-muted);
|
|
||||||
font-size: 0.8rem;
|
|
||||||
padding: 0.35rem 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-outline-secondary.btn-sm:hover {
|
|
||||||
background-color: var(--text-muted);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== ESTADOS VAZIOS ===== */
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: var(--text-muted);
|
color: #6c757d;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-state td {
|
.empty-state td {
|
||||||
@ -310,6 +231,72 @@
|
|||||||
padding: 2rem !important;
|
padding: 2rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filters-active .badge {
|
||||||
|
font-size: 0.75em;
|
||||||
|
padding: 0.4em 0.65em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-doctor-table tbody tr {
|
||||||
|
transition: background-color 0.15s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-view,
|
||||||
|
.btn-edit,
|
||||||
|
.btn-delete {
|
||||||
|
transition: all 0.15s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.contador-medicos {
|
||||||
|
background-color: #1e3a8a;
|
||||||
|
color: white;
|
||||||
|
padding: 0.5em 0.75em;
|
||||||
|
font-size: 0.875em;
|
||||||
|
font-weight: 500;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
text-align: center;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-link {
|
||||||
|
color: #495057;
|
||||||
|
border: 1px solid #dee2e6;
|
||||||
|
padding: 0.375rem 0.75rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-link:hover {
|
||||||
|
color: #1e3a8a;
|
||||||
|
background-color: #e9ecef;
|
||||||
|
border-color: #dee2e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-item.active .page-link {
|
||||||
|
background-color: #1e3a8a;
|
||||||
|
border-color: #1e3a8a;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-item.disabled .page-link {
|
||||||
|
color: #6c757d;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border-color: #dee2e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.d-flex.justify-content-between.align-items-center {
|
||||||
|
border-top: 1px solid #dee2e6;
|
||||||
|
padding-top: 1rem;
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.text-center.py-4 .text-muted {
|
.text-center.py-4 .text-muted {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
}
|
}
|
||||||
@ -329,104 +316,8 @@
|
|||||||
padding: 2rem !important;
|
padding: 2rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== BADGES DE FILTROS ATIVOS ===== */
|
|
||||||
.filters-active .badge {
|
|
||||||
font-size: 0.75em;
|
|
||||||
padding: 0.4em 0.65em;
|
|
||||||
margin-bottom: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== SEÇÃO DE PAGINAÇÃO ===== */
|
|
||||||
.d-flex.justify-content-between.align-items-center {
|
|
||||||
border-top: 1px solid var(--border-light);
|
|
||||||
padding-top: 1rem;
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== NOME DE PACIENTE/MÉDICO COM BADGES ===== */
|
|
||||||
.patient-name-container,
|
|
||||||
.doctor-name-container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.patient-badges,
|
|
||||||
.doctor-badges {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.25rem;
|
|
||||||
margin-left: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== TRANSIÇÕES ===== */
|
|
||||||
.table-doctor-table tbody tr {
|
|
||||||
transition: background-color 0.15s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== RESPONSIVIDADE ===== */
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.table-doctor-container {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-doctor-card .card-header {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1rem;
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-doctor-filters .d-flex.flex-wrap.align-items-center.gap-3 {
|
|
||||||
gap: 1rem !important;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-doctor-filters .d-flex.align-items-center.gap-2 {
|
|
||||||
width: 100%;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-doctor-filters .form-select-sm.compact-select {
|
|
||||||
min-width: 100% !important;
|
|
||||||
margin-top: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vr.d-none.d-md-block {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-doctor-table {
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-doctor-table th,
|
|
||||||
.table-doctor-table td {
|
|
||||||
padding: 10px 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-view,
|
|
||||||
.btn-edit,
|
|
||||||
.btn-delete {
|
|
||||||
padding: 0.25rem 0.5rem;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-doctor-filters .d-flex {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-doctor-filters .form-select {
|
|
||||||
min-width: 100% !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.patient-name-container,
|
|
||||||
.doctor-name-container {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start !important;
|
|
||||||
gap: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.d-flex.justify-content-between.align-items-center {
|
.d-flex.justify-content-between.align-items-center {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
@ -452,63 +343,17 @@
|
|||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
padding: 0.4em 0.6em;
|
padding: 0.4em 0.6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filtros-basicos {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: stretch;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-especialidade {
|
|
||||||
min-width: 100% !important;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-buttons-container {
|
|
||||||
justify-content: stretch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-btn {
|
|
||||||
flex: 1;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ocultar colunas em mobile */
|
|
||||||
.table-doctor-table thead th:nth-child(3),
|
|
||||||
.table-doctor-table thead th:nth-child(4),
|
|
||||||
.table-doctor-table tbody td:nth-child(3),
|
|
||||||
.table-doctor-table tbody td:nth-child(4) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 576px) {
|
.form-select.form-select-sm.w-auto {
|
||||||
.table-doctor-card .card-header {
|
border: 1px solid #dee2e6;
|
||||||
padding: 0.75rem 1rem;
|
border-radius: 0.375rem;
|
||||||
}
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
.table-doctor-table th,
|
|
||||||
.table-doctor-table td {
|
|
||||||
padding: 8px 6px;
|
.filters-active .badge {
|
||||||
}
|
font-size: 0.75em;
|
||||||
|
padding: 0.4em 0.65em;
|
||||||
.table-doctor-filters .btn-sm {
|
margin-bottom: 0.25rem;
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-buttons-container {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-btn {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ocultar mais colunas em telas muito pequenas */
|
|
||||||
.table-doctor-table thead th:nth-child(2),
|
|
||||||
.table-doctor-table thead th:nth-child(5),
|
|
||||||
.table-doctor-table tbody td:nth-child(2),
|
|
||||||
.table-doctor-table tbody td:nth-child(5) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,29 +1,14 @@
|
|||||||
/* ===== VARIÁVEIS CSS PADRONIZADAS ===== */
|
.table-paciente-container {
|
||||||
:root {
|
line-height: 2.5;
|
||||||
--primary-blue: #1e3a8a;
|
}
|
||||||
--light-blue: #E6F2FF;
|
|
||||||
--medium-blue: #D1E7FF;
|
/* Adiciona responsividade para a tabela */
|
||||||
--border-blue: #B8D4F0;
|
@media (max-width: 992px) {
|
||||||
--warning-light: #FFF3CD;
|
.table-paciente-card {
|
||||||
--warning-dark: #856404;
|
overflow-x: auto;
|
||||||
--warning-border: #FFEAA7;
|
}
|
||||||
--danger-light: #F8D7DA;
|
|
||||||
--danger-dark: #721C24;
|
|
||||||
--danger-border: #F5C6CB;
|
|
||||||
--success-light: #d1edff;
|
|
||||||
--success-dark: #0d6efd;
|
|
||||||
--bg-light: #f1f4fb;
|
|
||||||
--border-light: #dee2e6;
|
|
||||||
--text-muted: #6c757d;
|
|
||||||
--text-dark: #495057;
|
|
||||||
--spacing-xs: 0.25rem;
|
|
||||||
--spacing-sm: 0.5rem;
|
|
||||||
--spacing-md: 1rem;
|
|
||||||
--spacing-lg: 1.5rem;
|
|
||||||
--border-radius: 0.375rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== ESTILOS EXISTENTES MANTIDOS ===== */
|
|
||||||
.table-paciente-container {
|
.table-paciente-container {
|
||||||
line-height: 2.5;
|
line-height: 2.5;
|
||||||
}
|
}
|
||||||
@ -37,71 +22,65 @@
|
|||||||
background-color: #f8f9fa;
|
background-color: #f8f9fa;
|
||||||
border-bottom: 1px solid #dee2e6;
|
border-bottom: 1px solid #dee2e6;
|
||||||
padding: 1rem 1.25rem;
|
padding: 1rem 1.25rem;
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== ESTILOS PADRONIZADOS DA TABELA ===== */
|
|
||||||
.table-paciente-filters {
|
.table-paciente-filters {
|
||||||
background-color: var(--bg-light);
|
background-color: #f8f9fa;
|
||||||
border: 1px solid var(--border-light);
|
border: 1px solid #dee2e6;
|
||||||
border-radius: var(--border-radius);
|
border-radius: 0.375rem;
|
||||||
padding: var(--spacing-md);
|
|
||||||
margin-bottom: var(--spacing-md);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-paciente-filters h5 {
|
.table-paciente-filters h5 {
|
||||||
color: var(--text-dark);
|
color: #495057;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-paciente-table {
|
.table-paciente-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-paciente-table th {
|
.table-paciente-table th {
|
||||||
background-color: var(--bg-light);
|
background-color: #f8f9fa;
|
||||||
color: var(--text-dark);
|
color: #495057;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
padding: 12px 8px;
|
padding: 15px 8px;
|
||||||
border-bottom: 2px solid var(--border-light);
|
border-bottom: 2px solid #dee2e6;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
font-size: 0.9rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-paciente-table td {
|
.table-paciente-table td {
|
||||||
padding: 12px 8px;
|
padding: 15px 8px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
border-bottom: 1px solid var(--border-light);
|
border-bottom: 1px solid #dee2e6;
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-paciente-table tbody tr:hover {
|
.table-paciente-table tbody tr:hover {
|
||||||
background-color: rgba(0, 0, 0, 0.025);
|
background-color: rgba(0, 0, 0, 0.025);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== BADGES E STATUS ===== */
|
|
||||||
.insurance-badge {
|
.insurance-badge {
|
||||||
background-color: transparent !important;
|
background-color: #6c757d !important;
|
||||||
color: var(--text-dark) !important;
|
|
||||||
padding: 0.35em 0.65em;
|
|
||||||
font-size: 0.75em;
|
|
||||||
font-weight: 500;
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
.vip-badge {
|
|
||||||
background-color: var(--primary-blue) !important;
|
|
||||||
color: white !important;
|
color: white !important;
|
||||||
padding: 0.35em 0.65em;
|
padding: 0.35em 0.65em;
|
||||||
font-size: 0.75em;
|
font-size: 0.75em;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-radius: var(--border-radius);
|
}
|
||||||
|
|
||||||
|
.vip-badge {
|
||||||
|
background-color: #1e3a8a !important;
|
||||||
|
color: white !important;
|
||||||
|
padding: 0.35em 0.65em;
|
||||||
|
font-size: 0.75em;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-badge {
|
||||||
|
background-color: #1e3a8a;
|
||||||
|
color: white;
|
||||||
|
padding: 0.5em 0.75em;
|
||||||
|
font-size: 0.875em;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.anniversary-badge {
|
.anniversary-badge {
|
||||||
@ -109,52 +88,27 @@
|
|||||||
color: #000;
|
color: #000;
|
||||||
padding: 0.35em 0.65em;
|
padding: 0.35em 0.65em;
|
||||||
font-size: 0.75em;
|
font-size: 0.75em;
|
||||||
border-radius: 50%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-badge {
|
|
||||||
padding: 0.35em 0.65em;
|
|
||||||
font-size: 0.75em;
|
|
||||||
font-weight: 500;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
display: inline-block;
|
|
||||||
text-transform: capitalize;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-badge.ativo {
|
|
||||||
background-color: var(--primary-blue);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-badge.inativo {
|
|
||||||
background-color: var(--text-muted);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== BOTÕES DE AÇÃO ===== */
|
|
||||||
.btn-view {
|
.btn-view {
|
||||||
background-color: var(--light-blue) !important;
|
background-color: #E6F2FF !important;
|
||||||
color: #004085 !important;
|
color: #004085 !important;
|
||||||
border: 1px solid var(--border-blue);
|
border: 1px solid #B8D4F0;
|
||||||
padding: 0.375rem 0.75rem;
|
padding: 0.375rem 0.75rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
border-radius: var(--border-radius);
|
|
||||||
transition: all 0.15s ease-in-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-view:hover {
|
.btn-view:hover {
|
||||||
background-color: var(--medium-blue) !important;
|
background-color: #D1E7FF !important;
|
||||||
border-color: #9EC5FE;
|
border-color: #9EC5FE;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-edit {
|
.btn-edit {
|
||||||
background-color: var(--warning-light) !important;
|
background-color: #FFF3CD !important;
|
||||||
color: var(--warning-dark) !important;
|
color: #856404 !important;
|
||||||
border: 1px solid var(--warning-border);
|
border: 1px solid #FFEAA7;
|
||||||
padding: 0.375rem 0.75rem;
|
padding: 0.375rem 0.75rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
border-radius: var(--border-radius);
|
|
||||||
transition: all 0.15s ease-in-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-edit:hover {
|
.btn-edit:hover {
|
||||||
@ -163,13 +117,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-delete {
|
.btn-delete {
|
||||||
background-color: var(--danger-light) !important;
|
background-color: #F8D7DA !important;
|
||||||
color: var(--danger-dark) !important;
|
color: #721C24 !important;
|
||||||
border: 1px solid var(--danger-border);
|
border: 1px solid #F5C6CB;
|
||||||
padding: 0.375rem 0.75rem;
|
padding: 0.375rem 0.75rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
border-radius: var(--border-radius);
|
|
||||||
transition: all 0.15s ease-in-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-delete:hover {
|
.btn-delete:hover {
|
||||||
@ -177,25 +129,22 @@
|
|||||||
border-color: #ED969E;
|
border-color: #ED969E;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== FILTROS AVANÇADOS ===== */
|
|
||||||
.advanced-filters {
|
.advanced-filters {
|
||||||
border: 1px solid var(--border-light);
|
border: 1px solid #dee2e6;
|
||||||
border-radius: var(--border-radius);
|
border-radius: 0.375rem;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.advanced-filters h6 {
|
.advanced-filters h6 {
|
||||||
color: var(--text-dark);
|
color: #495057;
|
||||||
font-size: 0.9rem;
|
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-label.fw-bold {
|
.form-label.fw-bold {
|
||||||
color: var(--text-dark);
|
color: #495057;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== MODAL DE EXCLUSÃO ===== */
|
|
||||||
.delete-modal .modal-header {
|
.delete-modal .modal-header {
|
||||||
background-color: rgba(220, 53, 69, 0.1);
|
background-color: rgba(220, 53, 69, 0.1);
|
||||||
border-bottom: 1px solid rgba(220, 53, 69, 0.2);
|
border-bottom: 1px solid rgba(220, 53, 69, 0.2);
|
||||||
@ -206,103 +155,6 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== CONTADOR DE PACIENTES ===== */
|
|
||||||
.contador-pacientes {
|
|
||||||
background-color: var(--primary-blue);
|
|
||||||
color: white;
|
|
||||||
padding: 0.5em 0.75em;
|
|
||||||
font-size: 0.875em;
|
|
||||||
font-weight: 500;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
text-align: center;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== PAGINAÇÃO ===== */
|
|
||||||
.pagination {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-link {
|
|
||||||
color: var(--text-dark);
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
padding: 0.375rem 0.75rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-link:hover {
|
|
||||||
color: var(--primary-blue);
|
|
||||||
background-color: #e9ecef;
|
|
||||||
border-color: var(--border-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-item.active .page-link {
|
|
||||||
background-color: var(--primary-blue);
|
|
||||||
border-color: var(--primary-blue);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-item.disabled .page-link {
|
|
||||||
color: var(--text-muted);
|
|
||||||
background-color: var(--bg-light);
|
|
||||||
border-color: var(--border-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== AJUSTES ESPECÍFICOS PARA OS FILTROS ===== */
|
|
||||||
.table-paciente-filters .form-select-sm {
|
|
||||||
font-size: 0.825rem;
|
|
||||||
padding: 0.35rem 0.5rem;
|
|
||||||
border-radius: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .form-label.small {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
font-weight: 500;
|
|
||||||
color: #6c757d;
|
|
||||||
min-width: auto;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Alinhamento dos grupos de filtro */
|
|
||||||
.table-paciente-filters .d-flex.align-items-center.gap-2 {
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ajuste do contador */
|
|
||||||
.contador-pacientes {
|
|
||||||
background-color: #1e3a8a;
|
|
||||||
color: white;
|
|
||||||
padding: 0.4rem 0.8rem;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
font-weight: 600;
|
|
||||||
border-radius: 0.375rem;
|
|
||||||
text-align: center;
|
|
||||||
display: inline-block;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Botão de filtros avançados */
|
|
||||||
.btn-link {
|
|
||||||
color: #1e3a8a !important;
|
|
||||||
font-weight: 500;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-link:hover {
|
|
||||||
color: #162d6b !important;
|
|
||||||
transform: translateY(-1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Selects compactos */
|
|
||||||
.compact-select {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
padding: 0.45rem 0.5rem;
|
|
||||||
min-width: 150px;
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== ESTADOS VAZIOS ===== */
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -314,57 +166,22 @@
|
|||||||
padding: 2rem !important;
|
padding: 2rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-center.py-4 .text-muted {
|
.filters-active .badge {
|
||||||
padding: 2rem;
|
font-size: 0.75em;
|
||||||
|
padding: 0.4em 0.65em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-center.py-4 .bi-search {
|
.table-paciente-table tbody tr {
|
||||||
font-size: 3rem;
|
transition: background-color 0.15s ease-in-out;
|
||||||
opacity: 0.5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-center.py-4 p {
|
.btn-view,
|
||||||
margin-bottom: 0.5rem;
|
.btn-edit,
|
||||||
font-size: 1.1rem;
|
.btn-delete {
|
||||||
|
transition: all 0.15s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-center.py-4 td {
|
|
||||||
border-bottom: none;
|
|
||||||
padding: 2rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== RESPONSIVIDADE ===== */
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.table-paciente-container {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-card .card-header {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1rem;
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .d-flex.flex-wrap.align-items-center.gap-3 {
|
|
||||||
gap: 1rem !important;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .d-flex.align-items-center.gap-2 {
|
|
||||||
width: 100%;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .form-select-sm.compact-select {
|
|
||||||
min-width: 100% !important;
|
|
||||||
margin-top: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vr.d-none.d-md-block {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-table {
|
.table-paciente-table {
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
@ -396,75 +213,71 @@
|
|||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.d-flex.justify-content-between.align-items-center {
|
.patient-badges {
|
||||||
flex-direction: column;
|
margin-left: 0 !important;
|
||||||
gap: 1rem;
|
|
||||||
align-items: stretch !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ocultar colunas em mobile */
|
|
||||||
.table-paciente-table thead th:nth-child(3),
|
|
||||||
.table-paciente-table thead th:nth-child(4),
|
|
||||||
.table-paciente-table tbody td:nth-child(3),
|
|
||||||
.table-paciente-table tbody td:nth-child(4) {
|
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 576px) {
|
.compact-select {
|
||||||
.table-paciente-card .card-header {
|
font-size: 1.0rem;
|
||||||
padding: 0.75rem 1rem;
|
padding: 0.45rem 0.5rem;
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-table th,
|
|
||||||
.table-paciente-table td {
|
|
||||||
padding: 8px 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-paciente-filters .btn-sm {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ocultar mais colunas em telas muito pequenas */
|
|
||||||
.table-paciente-table thead th:nth-child(2),
|
|
||||||
.table-paciente-table thead th:nth-child(5),
|
|
||||||
.table-paciente-table tbody td:nth-child(2),
|
|
||||||
.table-paciente-table tbody td:nth-child(5) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== MELHORIAS VISUAIS ===== */
|
.compact-select option {
|
||||||
.form-select-sm:focus {
|
font-size: 0.875rem;
|
||||||
border-color: #1e3a8a;
|
|
||||||
box-shadow: 0 0 0 0.2rem rgba(30, 58, 138, 0.25);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-outline-secondary.btn-sm {
|
.table-paciente-filters .btn-sm {
|
||||||
border-color: #6c757d;
|
|
||||||
color: #6c757d;
|
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
padding: 0.35rem 0.75rem;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-outline-secondary.btn-sm:hover {
|
.table-paciente-filters .d-flex {
|
||||||
background-color: #6c757d;
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== ESTILOS PARA PAGINAÇÃO ===== */
|
||||||
|
|
||||||
|
.contador-pacientes {
|
||||||
|
background-color: #1e3a8a;
|
||||||
|
color: white;
|
||||||
|
padding: 0.5em 0.75em;
|
||||||
|
font-size: 0.875em;
|
||||||
|
font-weight: 500;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
text-align: center;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Estilos para a paginação */
|
||||||
|
.pagination {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-link {
|
||||||
|
color: #495057;
|
||||||
|
border: 1px solid #dee2e6;
|
||||||
|
padding: 0.375rem 0.75rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-link:hover {
|
||||||
|
color: #1e3a8a;
|
||||||
|
background-color: #e9ecef;
|
||||||
|
border-color: #dee2e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-item.active .page-link {
|
||||||
|
background-color: #1e3a8a;
|
||||||
|
border-color: #1e3a8a;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.advanced-filters {
|
.page-item.disabled .page-link {
|
||||||
background-color: var(--bg-light);
|
color: #6c757d;
|
||||||
border: 1px solid #dee2e6 !important;
|
background-color: #f8f9fa;
|
||||||
}
|
border-color: #dee2e6;
|
||||||
|
|
||||||
.advanced-filters .form-control-sm {
|
|
||||||
font-size: 0.825rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.advanced-filters h6 {
|
|
||||||
color: #495057;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ajustes para a seção de paginação */
|
/* Ajustes para a seção de paginação */
|
||||||
@ -474,6 +287,26 @@
|
|||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Estilos para empty state */
|
||||||
|
.text-center.py-4 .text-muted {
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-center.py-4 .bi-search {
|
||||||
|
font-size: 3rem;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-center.py-4 p {
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-center.py-4 td {
|
||||||
|
border-bottom: none;
|
||||||
|
padding: 2rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* Responsividade para paginação */
|
/* Responsividade para paginação */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.d-flex.justify-content-between.align-items-center {
|
.d-flex.justify-content-between.align-items-center {
|
||||||
@ -510,26 +343,19 @@
|
|||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Melhorar a aparência dos badges de paciente */
|
/* Melhorar a aparência dos badges de filtros ativos */
|
||||||
.patient-badges {
|
.filters-active .badge {
|
||||||
display: flex;
|
font-size: 0.75em;
|
||||||
gap: 0.25rem;
|
padding: 0.4em 0.65em;
|
||||||
margin-left: 0.5rem;
|
margin-bottom: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.patient-name-container {
|
@media (max-width: 576px) {
|
||||||
display: flex;
|
.table-paciente-card .card-header { padding: 0.75rem 1rem; }
|
||||||
align-items: center;
|
.table-paciente-table th, .table-paciente-table td { padding: 8px 6px; }
|
||||||
flex-wrap: wrap;
|
.table-paciente-table thead th:nth-child(2),
|
||||||
}
|
.table-paciente-table thead th:nth-child(4),
|
||||||
|
.table-paciente-table tbody td:nth-child(2),
|
||||||
/* Transições suaves */
|
.table-paciente-table tbody td:nth-child(4) { display: none; }
|
||||||
.table-paciente-table tbody tr {
|
.table-paciente-filters .btn-sm { width: 100%; }
|
||||||
transition: background-color 0.15s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-view,
|
|
||||||
.btn-edit,
|
|
||||||
.btn-delete {
|
|
||||||
transition: all 0.15s ease-in-out;
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user