|
1 | 1 | const db = require("../configs/mysql_config");
|
2 | 2 | const asyncHandler = require("../middlewares/asyncHandler");
|
3 | 3 |
|
| 4 | +//Get data for preview cards |
| 5 | + |
4 | 6 | const getpreviewformsData_sql = `SELECT
|
5 | 7 | forms.id,
|
6 | 8 | forms.form_type,
|
@@ -37,6 +39,7 @@ exports.getpreviewformsData = asyncHandler(async (req, res) => {
|
37 | 39 | }
|
38 | 40 | });
|
39 | 41 |
|
| 42 | +// Get specific form data for preview |
40 | 43 |
|
41 | 44 | const getbasicdetails_sql = `SELECT
|
42 | 45 | forms.id AS form_id,
|
@@ -190,7 +193,7 @@ exports.getpreviewspecificformData = asyncHandler( async (req, res) => {
|
190 | 193 | const connection = await db.getConnection();
|
191 | 194 |
|
192 | 195 | try {
|
193 |
| - // 1. Fetch common form data from respective tables |
| 196 | + // Fetch common form data from respective tables |
194 | 197 | const [[bankDetails]] = await connection.execute(
|
195 | 198 | getbankdetails_sql,
|
196 | 199 | [id]
|
@@ -244,26 +247,26 @@ exports.getpreviewspecificformData = asyncHandler( async (req, res) => {
|
244 | 247 |
|
245 | 248 |
|
246 | 249 |
|
247 |
| - // 2. Fetch submitted files from separate table |
248 |
| - // const [[submittedFiles]] = await connection.execute( |
249 |
| - // 'SELECT * FROM submitted_files WHERE form_id = ?', |
250 |
| - // [id] |
251 |
| - // ); |
| 250 | + // Fetch submitted files from separate table |
| 251 | + const [[submittedFiles]] = await connection.execute( |
| 252 | + 'SELECT * FROM files WHERE form_id = ?', |
| 253 | + [id] |
| 254 | + ); |
252 | 255 |
|
253 |
| - // 3. Handle if any main block is missing |
254 |
| - // if (!bankDetails || !basicDetails || !landDevelopment || !landOwnership) { |
255 |
| - // return res.status(404).json({ error: 'Form data not found' }); |
256 |
| - // } |
| 256 | + //Handle if any main block is missing |
| 257 | + if (!bankDetails || !basicDetails || !landDevelopment || !landOwnership) { |
| 258 | + return res.status(404).json({ error: 'Form data not found' }); |
| 259 | + } |
257 | 260 |
|
258 |
| - // 4. Insert submittedFiles into bankDetails |
259 |
| - // bankDetails.submittedFiles = { |
260 |
| - // bankPassbook: submittedFiles?.bankPassbook || null, |
261 |
| - // farmerPhoto: submittedFiles?.farmerPhoto || null, |
262 |
| - // fmb: submittedFiles?.fmb || null, |
263 |
| - // geoTag: submittedFiles?.geoTag || null, |
264 |
| - // idCard: submittedFiles?.idCard || null, |
265 |
| - // patta: submittedFiles?.patta || null, |
266 |
| - // }; |
| 261 | + //Insert submittedFiles into bankDetails |
| 262 | + bankDetails.submittedFiles = { |
| 263 | + bankPassbook: submittedFiles?.bankPassbook || null, |
| 264 | + farmerPhoto: submittedFiles?.farmerPhoto || null, |
| 265 | + fmb: submittedFiles?.fmb || null, |
| 266 | + geoTag: submittedFiles?.geoTag || null, |
| 267 | + idCard: submittedFiles?.idCard || null, |
| 268 | + patta: submittedFiles?.patta || null, |
| 269 | + }; |
267 | 270 |
|
268 | 271 | // 5. Final combined response
|
269 | 272 | const result = {
|
|
0 commit comments